code
stringlengths
52
7.75k
docs
stringlengths
1
5.85k
def _handle_class_instance(self, klass): if (klass in self.blacklisted_plugins or not self.instantiate_classes or klass == IPlugin): return elif self.unique_instances and self._unique_class(klass): self.plugins.append(klass()) elif...
handles class instances. If a class is blacklisted, returns. If uniuqe_instances is True and the class is unique, instantiates the class and adds the new object to plugins. If not unique_instances, creates and adds new instance to plugin state
def _unique_class(self, cls): return not any(isinstance(obj, cls) for obj in self.plugins)
internal method to check if any of the plugins are instances of a given cls
def add_blacklisted_plugins(self, plugins): plugins = util.return_list(plugins) self.blacklisted_plugins.extend(plugins)
add blacklisted plugins. `plugins` may be a single object or iterable.
def set_blacklisted_plugins(self, plugins): plugins = util.return_list(plugins) self.blacklisted_plugins = plugins
sets blacklisted plugins. `plugins` may be a single object or iterable.
def load_modules(self, filepaths): # removes filepaths from processed if they are not in sys.modules self._update_loaded_modules() filepaths = util.return_set(filepaths) modules = [] for filepath in filepaths: filepath = self._clean_filepath(filepath) ...
Loads the modules from their `filepaths`. A filepath may be a directory filepath if there is an `__init__.py` file in the directory. If a filepath errors, the exception will be caught and logged in the logger. Returns a list of modules.
def collect_plugins(self, modules=None): if modules is None: modules = self.get_loaded_modules() else: modules = util.return_list(modules) plugins = [] for module in modules: module_plugins = [(item[1], item[0]) ...
Collects all the plugins from `modules`. If modules is None, collects the plugins from the loaded modules. All plugins are passed through the module filters, if any are any, and returned as a list.
def set_module_plugin_filters(self, module_plugin_filters): module_plugin_filters = util.return_list(module_plugin_filters) self.module_plugin_filters = module_plugin_filters
Sets the internal module filters to `module_plugin_filters` `module_plugin_filters` may be a single object or an iterable. Every module filters must be a callable and take in a list of plugins and their associated names.
def add_module_plugin_filters(self, module_plugin_filters): module_plugin_filters = util.return_list(module_plugin_filters) self.module_plugin_filters.extend(module_plugin_filters)
Adds `module_plugin_filters` to the internal module filters. May be a single object or an iterable. Every module filters must be a callable and take in a list of plugins and their associated names.
def _get_modules(self, names): loaded_modules = [] for name in names: loaded_modules.append(sys.modules[name]) return loaded_modules
An internal method that gets the `names` from sys.modules and returns them as a list
def add_to_loaded_modules(self, modules): modules = util.return_set(modules) for module in modules: if not isinstance(module, str): module = module.__name__ self.loaded_modules.add(module)
Manually add in `modules` to be tracked by the module manager. `modules` may be a single object or an iterable.
def _filter_modules(self, plugins, names): if self.module_plugin_filters: # check to make sure the number of plugins isn't changing original_length_plugins = len(plugins) module_plugins = set() for module_filter in self.module_plugin_filters: ...
Internal helper method to parse all of the plugins and names through each of the module filters
def _clean_filepath(self, filepath): if (os.path.isdir(filepath) and os.path.isfile(os.path.join(filepath, '__init__.py'))): filepath = os.path.join(filepath, '__init__.py') if (not filepath.endswith('.py') and os.path.isfile(filepath + '.py')): ...
processes the filepath by checking if it is a directory or not and adding `.py` if not present.
def _processed_filepath(self, filepath): processed = False if filepath in self.processed_filepaths.values(): processed = True return processed
checks to see if the filepath has already been processed
def _update_loaded_modules(self): system_modules = sys.modules.keys() for module in list(self.loaded_modules): if module not in system_modules: self.processed_filepaths.pop(module) self.loaded_modules.remove(module)
Updates the loaded modules by checking if they are still in sys.modules
def clear(self): self.axes.cla() self.conf.ntrace = 0 self.conf.xlabel = '' self.conf.ylabel = '' self.conf.title = ''
clear plot
def unzoom_all(self, event=None): if len(self.conf.zoom_lims) > 0: self.conf.zoom_lims = [self.conf.zoom_lims[0]] self.unzoom(event)
zoom out full data range
def unzoom(self, event=None, set_bounds=True): lims = None if len(self.conf.zoom_lims) > 1: lims = self.conf.zoom_lims.pop() ax = self.axes # print 'base unzoom ', lims, set_bounds if lims is None: # auto scale self.conf.zoom_lims = [None] ...
zoom out 1 level, or to full data range
def get_right_axes(self): "create, if needed, and return right-hand y axes" if len(self.fig.get_axes()) < 2: ax = self.axes.twinx() return self.fig.get_axes()[1f get_right_axes(self): "create, if needed, and return right-hand y axes" if len(self.fig.get_axes()) < 2: ...
create, if needed, and return right-hand y axes
def set_title(self, s, delay_draw=False): "set plot title" self.conf.relabel(title=s, delay_draw=delay_drawf set_title(self, s, delay_draw=False): "set plot title" self.conf.relabel(title=s, delay_draw=delay_draw)
set plot title
def set_xlabel(self, s, delay_draw=False): "set plot xlabel" self.conf.relabel(xlabel=s, delay_draw=delay_drawf set_xlabel(self, s, delay_draw=False): "set plot xlabel" self.conf.relabel(xlabel=s, delay_draw=delay_draw)
set plot xlabel
def set_ylabel(self, s, delay_draw=False): "set plot ylabel" self.conf.relabel(ylabel=s, delay_draw=delay_drawf set_ylabel(self, s, delay_draw=False): "set plot ylabel" self.conf.relabel(ylabel=s, delay_draw=delay_draw)
set plot ylabel
def set_y2label(self, s, delay_draw=False): "set plot ylabel" self.conf.relabel(y2label=s, delay_draw=delay_drawf set_y2label(self, s, delay_draw=False): "set plot ylabel" self.conf.relabel(y2label=s, delay_draw=delay_draw)
set plot ylabel
def save_figure(self, event=None, transparent=False, dpi=600): file_choices = "PNG (*.png)|*.png|SVG (*.svg)|*.svg|PDF (*.pdf)|*.pdf" try: ofile = self.conf.title.strip() except: ofile = 'Image' if len(ofile) > 64: ofile = ofile[:63].strip() ...
save figure image to file
def onLeftDown(self, event=None): if event is None: return self.cursor_mode_action('leftdown', event=event) self.ForwardEvent(event=event.guiEvent)
left button down: report x,y coords, start zooming mode
def onLeftUp(self, event=None): if event is None: return self.cursor_mode_action('leftup', event=event) self.canvas.draw_idle() self.canvas.draw() self.ForwardEvent(event=event.guiEvent)
left button up
def ForwardEvent(self, event=None): if event is not None: event.Skip() if self.HasCapture(): try: self.ReleaseMouse() except: pass
finish wx event, forward it to other wx objects
def onRightDown(self, event=None): if event is None: return # note that the matplotlib event location have to be converted if event.inaxes is not None and self.popup_menu is not None: pos = event.guiEvent.GetPosition() wx.CallAfter(self.PopupMenu, sel...
right button down: show pop-up
def onRightUp(self, event=None): if event is None: return self.cursor_mode_action('rightup', event=event) self.ForwardEvent(event=event.guiEvent)
right button up: put back to cursor mode
def __date_format(self, x): if x < 1: x = 1 span = self.axes.xaxis.get_view_interval() tmin = max(1.0, span[0]) tmax = max(2.0, span[1]) tmin = time.mktime(dates.num2date(tmin).timetuple()) tmax = time.mktime(dates.num2date(tmax).timetuple()) nhours = (...
formatter for date x-data. primitive, and probably needs improvement, following matplotlib's date methods.
def xformatter(self, x, pos): " x-axis formatter " if self.use_dates: return self.__date_format(x) else: return self.__format(x, type='x'f xformatter(self, x, pos): " x-axis formatter " if self.use_dates: return self.__date_format(x) el...
x-axis formatter
def __onKeyEvent(self, event=None): if event is None: return key = event.guiEvent.GetKeyCode() if (key < wx.WXK_SPACE or key > 255): return ckey = chr(key) mod = event.guiEvent.ControlDown() if self.is_macosx: mod = event.gui...
handles key events on canvas
def __onMouseButtonEvent(self, event=None): if event is None: return button = event.button or 1 handlers = {(1, 'button_press_event'): self.onLeftDown, (1, 'button_release_event'): self.onLeftUp, (3, 'button_press_event'): self.on...
general mouse press/release events. Here, event is a MplEvent from matplotlib. This routine just dispatches to the appropriate onLeftDown, onLeftUp, onRightDown, onRightUp.... methods.
def zoom_motion(self, event=None): try: x, y = event.x, event.y except: return self.report_motion(event=event) if self.zoom_ini is None: return ini_x, ini_y, ini_xd, ini_yd = self.zoom_ini if event.xdata is not None: ...
motion event handler for zoom mode
def zoom_leftdown(self, event=None): self.x_lastmove, self.y_lastmove = None, None self.zoom_ini = (event.x, event.y, event.xdata, event.ydata) self.report_leftdown(event=event)
leftdown event handler for zoom mode
def lasso_leftdown(self, event=None): try: self.report_leftdown(event=event) except: return if event.inaxes: # set lasso color color='goldenrod' cmap = getattr(self.conf, 'cmap', None) if isinstance(cmap, dict): ...
leftdown event handler for lasso mode
def rename(self, new_folder_name): headers = self.headers endpoint = 'https://outlook.office.com/api/v2.0/me/MailFolders/' + self.id payload = '{ "DisplayName": "' + new_folder_name + '"}' r = requests.patch(endpoint, headers=headers, data=payload) if check_response(r)...
Renames the Folder to the provided name. Args: new_folder_name: A string of the replacement name. Raises: AuthError: Raised if Outlook returns a 401, generally caused by an invalid or expired access token. Returns: A new Folder representing the folder with ...
def get_subfolders(self): headers = self.headers endpoint = 'https://outlook.office.com/api/v2.0/me/MailFolders/' + self.id + '/childfolders' r = requests.get(endpoint, headers=headers) if check_response(r): return self._json_to_folders(self.account, r.json())
Retrieve all child Folders inside of this Folder. Raises: AuthError: Raised if Outlook returns a 401, generally caused by an invalid or expired access token. Returns: List[:class:`Folder <pyOutlook.core.folder.Folder>`]
def delete(self): headers = self.headers endpoint = 'https://outlook.office.com/api/v2.0/me/MailFolders/' + self.id r = requests.delete(endpoint, headers=headers) check_response(r)
Deletes this Folder. Raises: AuthError: Raised if Outlook returns a 401, generally caused by an invalid or expired access token.
def move_into(self, destination_folder): # type: (Folder) -> None headers = self.headers endpoint = 'https://outlook.office.com/api/v2.0/me/MailFolders/' + self.id + '/move' payload = '{ "DestinationId": "' + destination_folder.id + '"}' r = requests.post(endpoint, head...
Move the Folder into a different folder. This makes the Folder provided a child folder of the destination_folder. Raises: AuthError: Raised if Outlook returns a 401, generally caused by an invalid or expired access token. Args: destination_folder: A :class:`Folder <pyO...
def create_child_folder(self, folder_name): headers = self.headers endpoint = 'https://outlook.office.com/api/v2.0/me/MailFolders/' + self.id + '/childfolders' payload = '{ "DisplayName": "' + folder_name + '"}' r = requests.post(endpoint, headers=headers, data=payload) ...
Creates a child folder within the Folder it is called from and returns the new Folder object. Args: folder_name: The name of the folder to create Returns: :class:`Folder <pyOutlook.core.folder.Folder>`
def messages(self): headers = self.headers r = requests.get('https://outlook.office.com/api/v2.0/me/MailFolders/' + self.id + '/messages', headers=headers) check_response(r) return Message._json_to_messages(self.account, r.json())
Retrieves the messages in this Folder, returning a list of :class:`Messages <pyOutlook.core.message.Message>`.
def gformat(val, length=11): try: expon = int(log10(abs(val))) except (OverflowError, ValueError): expon = 0 length = max(length, 7) form = 'e' prec = length - 7 if abs(expon) > 99: prec -= 1 elif ((expon > 0 and expon < (prec+4)) or (expon <= 0 and -ex...
Format a number with '%g'-like format, except that a) the length of the output string will be the requested length. b) positive numbers will have a leading blank. b) the precision will be as high as possible. c) trailing zeros will not be trimmed. The precision will typically be le...
def pack(window, sizer, expand=1.1): "simple wxPython pack function" tsize = window.GetSize() msize = window.GetMinSize() window.SetSizer(sizer) sizer.Fit(window) nsize = (10*int(expand*(max(msize[0], tsize[0])/10)), 10*int(expand*(max(msize[1], tsize[1])/10.))) window.SetSize...
simple wxPython pack function
def MenuItem(parent, menu, label='', longtext='', action=None, default=True, **kws): item = menu.Append(-1, label, longtext, **kws) kind = item.GetKind() if kind == wx.ITEM_CHECK: item.Check(default) if callable(action): parent.Bind(wx.EVT_MENU, action, item) return...
Add Item to a Menu, with action m = Menu(parent, menu, label, longtext, action=None)
def Setup(self, event=None): if hasattr(self, 'printerData'): data = wx.PageSetupDialogData() data.SetPrintData(self.printerData) else: data = wx.PageSetupDialogData() data.SetMarginTopLeft( (15, 15) ) data.SetMarginBottomRight( (15, 15) ) ...
set up figure for printing. Using the standard wx Printer Setup Dialog.
def Preview(self, title=None, event=None): if title is None: title = self.title if self.canvas is None: self.canvas = self.parent.canvas po1 = PrintoutWx(self.parent.canvas, title=title, width=self.pwidth, margin=self.pmargin) ...
generate Print Preview with wx Print mechanism
def Print(self, title=None, event=None): pdd = wx.PrintDialogData() pdd.SetPrintData(self.printerData) pdd.SetToPage(1) printer = wx.Printer(pdd) if title is None: title = self.title printout = PrintoutWx(self.parent.canvas, title=title, ...
Print figure using wx Print mechanism
def set_float(val): out = None if not val in (None, ''): try: out = float(val) except ValueError: return None if numpy.isnan(out): out = default return out
utility to set a floating value, useful for converting from strings
def SetAction(self, action, **kws): "set callback action" if hasattr(action,'__call__'): self.__action = Closure(action, **kwsf SetAction(self, action, **kws): "set callback action" if hasattr(action,'__call__'): self.__action = Closure(action, **kws)
set callback action
def __GetMark(self): " keep track of cursor position within text" try: self.__mark = min(wx.TextCtrl.GetSelection(self)[0], len(wx.TextCtrl.GetValue(self).strip())) except: self.__mark = f __GetMark(self): " keep track of cursor posit...
keep track of cursor position within text
def __SetMark(self, mark=None): "set mark for later" if mark is None: mark = self.__mark self.SetSelection(mark, markf __SetMark(self, mark=None): "set mark for later" if mark is None: mark = self.__mark self.SetSelection(mark, mark)
set mark for later
def SetValue(self, value=None, act=True): " main method to set value " if value is None: value = wx.TextCtrl.GetValue(self).strip() self.__CheckValid(value) self.__GetMark() if value is not None: wx.TextCtrl.SetValue(self, self.format % set_float(value)) ...
main method to set value
def OnChar(self, event): key = event.GetKeyCode() entry = wx.TextCtrl.GetValue(self).strip() pos = wx.TextCtrl.GetSelection(self) # really, the order here is important: # 1. return sends to ValidateEntry if key == wx.WXK_RETURN: if not self.is_val...
on Character event
def OnText(self, event=None): "text event" try: if event.GetString() != '': self.__CheckValid(event.GetString()) except: pass event.Skip(f OnText(self, event=None): "text event" try: if event.GetString() != '': ...
text event
def __CheckValid(self, value): "check for validity of value" val = self.__val self.is_valid = True try: val = set_float(value) if self.__min is not None and (val < self.__min): self.is_valid = False val = self.__min if s...
check for validity of value
def plot(self, xdata, ydata, side='left', title=None, xlabel=None, ylabel=None, y2label=None, use_dates=False, **kws): allaxes = self.fig.get_axes() if len(allaxes) > 1: for ax in allaxes[1:]: if ax in self.data_range: se...
plot (that is, create a new plot: clear, then oplot)
def plot_many(self, datalist, side='left', title=None, xlabel=None, ylabel=None, **kws): def unpack_tracedata(tdat, **kws): if (isinstance(tdat, dict) and 'xdata' in tdat and 'ydata' in tdat): xdata = tdat.pop('xdata') ydata ...
plot many traces at once, taking a list of (x, y) pairs
def add_text(self, text, x, y, side='left', size=None, rotation=None, ha='left', va='center', family=None, **kws): axes = self.axes if side == 'right': axes = self.get_right_axes() dynamic_size = False if size is None: si...
add text at supplied x, y position
def add_arrow(self, x1, y1, x2, y2, side='left', shape='full', color='black', width=0.01, head_width=0.03, overhang=0, **kws): dx, dy = x2-x1, y2-y1 axes = self.axes if side == 'right': axes = self.get_right_axes() axes.arrow(x1,...
add arrow supplied x, y position
def set_xylims(self, limits, axes=None, side='left'): "set user-defined limits and apply them" if axes is None: axes = self.axes if side == 'right': axes = self.get_right_axes() self.conf.user_limits[axes] = limits self.unzoom_all(f set_xylims(self...
set user-defined limits and apply them
def clear(self): for ax in self.fig.get_axes(): ax.cla() self.conf.ntrace = 0 self.conf.xlabel = '' self.conf.ylabel = '' self.conf.y2label = '' self.conf.title = '' self.conf.data_save = {}
clear plot
def toggle_deriv(self, evt=None, value=None): "toggle derivative of data" if value is None: self.conf.data_deriv = not self.conf.data_deriv expr = self.conf.data_expr or '' if self.conf.data_deriv: expr = "deriv(%s)" % expr self.write_mess...
toggle derivative of data
def set_logscale(self, event=None, xscale='linear', yscale='linear', delay_draw=False): "set log or linear scale for x, y axis" self.conf.set_logscale(xscale=xscale, yscale=yscale, delay_draw=delay_drawf set_logscale(self, event=None, xscale='linear', ...
set log or linear scale for x, y axis
def toggle_legend(self, evt=None, show=None): "toggle legend display" if show is None: show = not self.conf.show_legend self.conf.show_legend = show self.conf.draw_legend(f toggle_legend(self, evt=None, show=None): "toggle legend display" if show is None: ...
toggle legend display
def toggle_grid(self, evt=None, show=None): "toggle grid display" if show is None: show = not self.conf.show_grid self.conf.enable_grid(showf toggle_grid(self, evt=None, show=None): "toggle grid display" if show is None: show = not self.conf.show_grid ...
toggle grid display
def configure(self, event=None): if self.win_config is not None: try: self.win_config.Raise() except: self.win_config = None if self.win_config is None: self.win_config = PlotConfigFrame(parent=self, ...
show configuration frame
def BuildPanel(self): self.fig = Figure(self.figsize, dpi=self.dpi) # 1 axes for now self.gridspec = GridSpec(1,1) kwargs = {'facecolor': self.conf.bgcolor} if matplotlib.__version__ < "2.0": kwargs = {'axisbg': self.conf.bgcolor} self.axes = self...
builds basic GUI panel and popup menu
def _updateCanvasDraw(self): fn = self.canvas.draw def draw2(*a,**k): self._updateGridSpec() return fn(*a,**k) self.canvas.draw = draw2
Overload of the draw function that update axes position before each draw
def get_default_margins(self): trans = self.fig.transFigure.inverted().transform # Static margins l, t, r, b = self.axesmargins (l, b), (r, t) = trans(((l, b), (r, t))) # Extent dl, dt, dr, db = 0, 0, 0, 0 for i, ax in enumerate(self.fig.get_axes()): ...
get default margins
def autoset_margins(self): if not self.conf.auto_margins: return # coordinates in px -> [0,1] in figure coordinates trans = self.fig.transFigure.inverted().transform # Static margins if not self.use_dates: self.conf.margins = l, t, r, b = self.ge...
auto-set margins left, bottom, right, top according to the specified margins (in pixels) and axes extent (taking into account labels, title, axis)
def update_line(self, trace, xdata, ydata, side='left', draw=False, update_limits=True): x = self.conf.get_mpl_line(trace) x.set_data(xdata, ydata) datarange = [xdata.min(), xdata.max(), ydata.min(), ydata.max()] self.conf.set_trace_datarange(datarange, trac...
update a single trace, for faster redraw
def __onPickEvent(self, event=None): legline = event.artist trace = self.conf.legend_map.get(legline, None) visible = True if trace is not None and self.conf.hidewith_legend: line, legline, legtext = trace visible = not line.get_visible() line...
pick events
def get_userid_by_email(self, email): ''' get userid by email ''' response, status_code = self.__pod__.Users.get_v2_user( sessionToken=self.__session__, email=email ).result() self.logger.debug('%s: %s' % (status_code, response)) return status_code, respon...
get userid by email
def get_user_id_by_user(self, username): ''' get user id by username ''' response, status_code = self.__pod__.Users.get_v2_user( sessionToken=self.__session__, username=username ).result() self.logger.debug('%s: %s' % (status_code, response)) return status...
get user id by username
def get_user_by_userid(self, userid): ''' get user by user id ''' response, status_code = self.__pod__.Users.get_v2_user( sessionToken=self.__session__, uid=userid ).result() self.logger.debug('%s: %s' % (status_code, response)) return status_code, respons...
get user by user id
def get_user_presence(self, userid): ''' check on presence of a user ''' response, status_code = self.__pod__.Presence.get_v2_user_uid_presence( sessionToken=self.__session__, uid=userid ).result() self.logger.debug('%s: %s' % (status_code, response)) retu...
check on presence of a user
def set_user_presence(self, userid, presence): ''' set presence of user ''' response, status_code = self.__pod__.Presence.post_v2_user_uid_presence( sessionToken=self.__session__, uid=userid, presence=presence ).result() self.logger.debug('%s: %s' % (s...
set presence of user
def search_user(self, search_str, search_filter, local): ''' add a user to a stream ''' response, status_code = self.__pod__.Users.post_v1_user_search( sessionToken=self.__session__, searchRequest={'query': search_str, 'filters': search_filter} ...
add a user to a stream
def p12parse(self): ''' parse p12 cert and get the cert / priv key for requests module ''' # open it, using password. Supply/read your own from stdin. p12 = crypto.load_pkcs12(open(self.p12, 'rb').read(), self.pwd) # grab the certs / keys p12cert = p12.get_certificate() # (si...
parse p12 cert and get the cert / priv key for requests module
def list_features(self): ''' list features the pod supports ''' response, status_code = self.__pod__.System.get_v1_admin_system_features_list( sessionToken=self.__session__ ).result() self.logger.debug('%s: %s' % (status_code, response)) return status_code, responsf l...
list features the pod supports
def user_feature_update(self, userid, payload): ''' update features by user id ''' response, status_code = self.__pod__.User.post_v1_admin_user_uid_features_update( sessionToken=self.__session__, uid=userid, payload=payload ).result() self.logger.debug...
update features by user id
def get_user_avatar(self, userid): ''' get avatar by user id ''' response, status_code = self.__pod__.User.get_v1_admin_user_uid_avatar( sessionToken=self.__session, uid=userid ).result() self.logger.debug('%s: %s' % (status_code, response)) return status_...
get avatar by user id
def user_avatar_update(self, userid, payload): ''' updated avatar by userid ''' response, status_code = self.__pod__.User.post_v1_admin_user_uid_avatar_update( sessionToken=self.__session, uid=userid, payload=payload ).result() self.logger.debug('%s: %...
updated avatar by userid
def list_apps(self): ''' list apps ''' response, status_code = self.__pod__.AppEntitlement.get_v1_admin_app_entitlement_list( sessionToken=self.__session__ ).result() self.logger.debug('%s: %s' % (status_code, response)) return status_code, responsf list_apps(self): ...
list apps
def stream_members(self, stream_id): ''' get stream members ''' response, status_code = self.__pod__.Streams.get_v1_admin_stream_id_membership_list( sessionToken=self.__session__, id=stream_id ).result() self.logger.debug('%s: %s' % (status_code, response)) ...
get stream members
def sessioninfo(self): ''' session info ''' response, status_code = self.__pod__.Session.get_v2_sessioninfo( sessionToken=self.__session__ ).result() self.logger.debug('%s: %s' % (status_code, response)) return status_code, responsf sessioninfo(self): ''' sess...
session info
def list_connections(self, status=None): ''' list connections ''' if status is None: status = 'ALL' response, status_code = self.__pod__.Connection.get_v1_connection_list( sessionToken=self.__session__, status=status ).result() self.logger.debu...
list connections
def connection_status(self, userid): ''' get connection status ''' response, status_code = self.__pod__.Connection.get_v1_connection_user_userId_info( sessionToken=self.__session__, userId=userid ).result() self.logger.debug('%s: %s' % (status_code, response)) ...
get connection status
def create_connection(self, userid): ''' create connection ''' req_hook = 'pod/v1/connection/create' req_args = '{ "userId": %s }' % userid status_code, response = self.__rest__.POST_query(req_hook, req_args) self.logger.debug('%s: %s' % (status_code, response)) return st...
create connection
def PKCS_GET_query(self, req_hook, req_args): ''' Generic GET query method ''' # GET request methods only require sessionTokens headers = {'content-type': 'application/json', 'sessionToken': self.__session__} # HTTP GET query method using requests module try: ...
Generic GET query method
def ib_group_member_list(self, group_id): ''' ib group member list ''' req_hook = 'pod/v1/admin/group/' + group_id + '/membership/list' req_args = None status_code, response = self.__rest__.GET_query(req_hook, req_args) self.logger.debug('%s: %s' % (status_code, response)) ...
ib group member list
def ib_group_member_add(self, group_id, userids): ''' ib group member add ''' req_hook = 'pod/v1/admin/group/' + group_id + '/membership/add' req_args = {'usersListId': userids} req_args = json.dumps(req_args) status_code, response = self.__rest__.POST_query(req_hook, req_args) ...
ib group member add
def ib_group_policy_list(self): ''' ib group policy list ''' req_hook = 'pod/v1/admin/policy/list' req_args = None status_code, response = self.__rest__.GET_query(req_hook, req_args) self.logger.debug('%s: %s' % (status_code, response)) return status_code, responsf ib_gro...
ib group policy list
def start_monitoring(self): if self.__monitoring is False: self.__monitoring = True self.__monitoring_action()
Enable periodically monitoring.
def GET_query(self, req_hook, req_args): ''' Generic GET query method ''' # GET request methods only require sessionTokens headers = {'content-type': 'application/json', 'sessionToken': self.__session__} # HTTP GET query method using requests module try: ...
Generic GET query method
def POST_query(self, req_hook, req_args): ''' Generic POST query method ''' # HTTP POST queries require keyManagerTokens and sessionTokens headers = {'Content-Type': 'application/json', 'sessionToken': self.__session__, 'keyManagerToken': self.__keymngr__} ...
Generic POST query method
def parse_MML(self, mml): ''' parse the MML structure ''' hashes_c = [] mentions_c = [] soup = BeautifulSoup(mml, "lxml") hashes = soup.find_all('hash', {"tag": True}) for hashe in hashes: hashes_c.append(hashe['tag']) mentions = soup.find_all('mention...
parse the MML structure
def parse_msg(self, datafeed): ''' parse messages ''' message_parsed = [] for message in datafeed: mid = message['id'] streamId = message['streamId'] mstring = message['message'] fromuser = message['fromUserId'] timestamp = message['tim...
parse messages
def member_add(self, stream_id, user_id): ''' add a user to a stream ''' req_hook = 'pod/v1/room/' + str(stream_id) + '/membership/add' req_args = '{ "id": %s }' % user_id status_code, response = self.__rest__.POST_query(req_hook, req_args) self.logger.debug('%s: %s' % (status_co...
add a user to a stream
def create_room(self, payload): ''' create a stream in a non-inclusive manner ''' response, status_code = self.__pod__.Streams.post_v2_room_create( # V2RoomAttributes payload=payload ).result() self.logger.debug('%s: %s' % (status_code, response)) return s...
create a stream in a non-inclusive manner