repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_documentation_string
stringlengths
1
47.2k
func_code_url
stringlengths
85
339
indico/indico-plugins
livesync/indico_livesync/models/queue.py
LiveSyncQueueEntry.object
def object(self): """Return the changed object.""" if self.type == EntryType.category: return self.category elif self.type == EntryType.event: return self.event elif self.type == EntryType.session: return self.session elif self.type == EntryTyp...
python
def object(self): """Return the changed object.""" if self.type == EntryType.category: return self.category elif self.type == EntryType.event: return self.event elif self.type == EntryType.session: return self.session elif self.type == EntryTyp...
Return the changed object.
https://github.com/indico/indico-plugins/blob/fe50085cc63be9b8161b09539e662e7b04e4b38e/livesync/indico_livesync/models/queue.py#L213-L224
indico/indico-plugins
livesync/indico_livesync/models/queue.py
LiveSyncQueueEntry.object_ref
def object_ref(self): """Return the reference of the changed object.""" return ImmutableDict(type=self.type, category_id=self.category_id, event_id=self.event_id, session_id=self.session_id, contrib_id=self.contrib_id, subcontrib_id=self.subcontrib_id)
python
def object_ref(self): """Return the reference of the changed object.""" return ImmutableDict(type=self.type, category_id=self.category_id, event_id=self.event_id, session_id=self.session_id, contrib_id=self.contrib_id, subcontrib_id=self.subcontrib_id)
Return the reference of the changed object.
https://github.com/indico/indico-plugins/blob/fe50085cc63be9b8161b09539e662e7b04e4b38e/livesync/indico_livesync/models/queue.py#L227-L230
indico/indico-plugins
livesync/indico_livesync/models/queue.py
LiveSyncQueueEntry.create
def create(cls, changes, ref, excluded_categories=set()): """Create a new change in all queues. :param changes: the change types, an iterable containing :class:`ChangeType` :param ref: the object reference (returned by `obj_ref`) of the changed ob...
python
def create(cls, changes, ref, excluded_categories=set()): """Create a new change in all queues. :param changes: the change types, an iterable containing :class:`ChangeType` :param ref: the object reference (returned by `obj_ref`) of the changed ob...
Create a new change in all queues. :param changes: the change types, an iterable containing :class:`ChangeType` :param ref: the object reference (returned by `obj_ref`) of the changed object :param excluded_categories: set of categories (IDs) whos...
https://github.com/indico/indico-plugins/blob/fe50085cc63be9b8161b09539e662e7b04e4b38e/livesync/indico_livesync/models/queue.py#L238-L271
sbg/sevenbridges-python
sevenbridges/models/async_jobs.py
AsyncJob.get_file_copy_job
def get_file_copy_job(cls, id, api=None): """ Retrieve file copy async job :param id: Async job identifier :param api: Api instance :return: """ id = Transform.to_async_job(id) api = api if api else cls._API async_job = api.get( url=cl...
python
def get_file_copy_job(cls, id, api=None): """ Retrieve file copy async job :param id: Async job identifier :param api: Api instance :return: """ id = Transform.to_async_job(id) api = api if api else cls._API async_job = api.get( url=cl...
Retrieve file copy async job :param id: Async job identifier :param api: Api instance :return:
https://github.com/sbg/sevenbridges-python/blob/f62640d1018d959f0b686f2dbe5e183085336607/sevenbridges/models/async_jobs.py#L72-L85
sbg/sevenbridges-python
sevenbridges/models/async_jobs.py
AsyncJob.get_result
def get_result(self, api=None): """ Get async job result in bulk format :return: List of AsyncFileBulkRecord objects """ api = api or self._API if not self.result: return [] return AsyncFileBulkRecord.parse_records( result=self.result, ...
python
def get_result(self, api=None): """ Get async job result in bulk format :return: List of AsyncFileBulkRecord objects """ api = api or self._API if not self.result: return [] return AsyncFileBulkRecord.parse_records( result=self.result, ...
Get async job result in bulk format :return: List of AsyncFileBulkRecord objects
https://github.com/sbg/sevenbridges-python/blob/f62640d1018d959f0b686f2dbe5e183085336607/sevenbridges/models/async_jobs.py#L102-L113
sbg/sevenbridges-python
sevenbridges/models/async_jobs.py
AsyncJob.list_file_jobs
def list_file_jobs(cls, offset=None, limit=None, api=None): """Query ( List ) async jobs :param offset: Pagination offset :param limit: Pagination limit :param api: Api instance :return: Collection object """ api = api or cls._API return super(AsyncJob, cl...
python
def list_file_jobs(cls, offset=None, limit=None, api=None): """Query ( List ) async jobs :param offset: Pagination offset :param limit: Pagination limit :param api: Api instance :return: Collection object """ api = api or cls._API return super(AsyncJob, cl...
Query ( List ) async jobs :param offset: Pagination offset :param limit: Pagination limit :param api: Api instance :return: Collection object
https://github.com/sbg/sevenbridges-python/blob/f62640d1018d959f0b686f2dbe5e183085336607/sevenbridges/models/async_jobs.py#L116-L129
indico/indico-plugins
importer_invenio/indico_importer_invenio/connector.py
decompose_code
def decompose_code(code): """ Decomposes a MARC "code" into tag, ind1, ind2, subcode """ code = "%-6s" % code ind1 = code[3:4] if ind1 == " ": ind1 = "_" ind2 = code[4:5] if ind2 == " ": ind2 = "_" subcode = code[5:6] if subcode == " ": subcode = None return (code[0:3], ind1,...
python
def decompose_code(code): """ Decomposes a MARC "code" into tag, ind1, ind2, subcode """ code = "%-6s" % code ind1 = code[3:4] if ind1 == " ": ind1 = "_" ind2 = code[4:5] if ind2 == " ": ind2 = "_" subcode = code[5:6] if subcode == " ": subcode = None return (code[0:3], ind1,...
Decomposes a MARC "code" into tag, ind1, ind2, subcode
https://github.com/indico/indico-plugins/blob/fe50085cc63be9b8161b09539e662e7b04e4b38e/importer_invenio/indico_importer_invenio/connector.py#L642-L653
indico/indico-plugins
importer_invenio/indico_importer_invenio/connector.py
InvenioConnector._init_browser
def _init_browser(self): """ Ovveride this method with the appropriate way to prepare a logged in browser. """ self.browser = mechanize.Browser() self.browser.set_handle_robots(False) self.browser.open(self.server_url + "/youraccount/login") self.browser.s...
python
def _init_browser(self): """ Ovveride this method with the appropriate way to prepare a logged in browser. """ self.browser = mechanize.Browser() self.browser.set_handle_robots(False) self.browser.open(self.server_url + "/youraccount/login") self.browser.s...
Ovveride this method with the appropriate way to prepare a logged in browser.
https://github.com/indico/indico-plugins/blob/fe50085cc63be9b8161b09539e662e7b04e4b38e/importer_invenio/indico_importer_invenio/connector.py#L193-L211
indico/indico-plugins
importer_invenio/indico_importer_invenio/connector.py
InvenioConnector.search
def search(self, read_cache=True, **kwparams): """ Returns records corresponding to the given search query. See docstring of invenio.legacy.search_engine.perform_request_search() for an overview of available parameters. @raise InvenioConnectorAuthError: if authentication fails ...
python
def search(self, read_cache=True, **kwparams): """ Returns records corresponding to the given search query. See docstring of invenio.legacy.search_engine.perform_request_search() for an overview of available parameters. @raise InvenioConnectorAuthError: if authentication fails ...
Returns records corresponding to the given search query. See docstring of invenio.legacy.search_engine.perform_request_search() for an overview of available parameters. @raise InvenioConnectorAuthError: if authentication fails
https://github.com/indico/indico-plugins/blob/fe50085cc63be9b8161b09539e662e7b04e4b38e/importer_invenio/indico_importer_invenio/connector.py#L218-L292
indico/indico-plugins
importer_invenio/indico_importer_invenio/connector.py
InvenioConnector.search_with_retry
def search_with_retry(self, sleeptime=3.0, retrycount=3, **params): """ This function performs a search given a dictionary of search(..) parameters. It accounts for server timeouts as necessary and will retry some number of times. @param sleeptime: number of seconds to sleep bet...
python
def search_with_retry(self, sleeptime=3.0, retrycount=3, **params): """ This function performs a search given a dictionary of search(..) parameters. It accounts for server timeouts as necessary and will retry some number of times. @param sleeptime: number of seconds to sleep bet...
This function performs a search given a dictionary of search(..) parameters. It accounts for server timeouts as necessary and will retry some number of times. @param sleeptime: number of seconds to sleep between retries @type sleeptime: float @param retrycount: number of times ...
https://github.com/indico/indico-plugins/blob/fe50085cc63be9b8161b09539e662e7b04e4b38e/importer_invenio/indico_importer_invenio/connector.py#L294-L324
indico/indico-plugins
importer_invenio/indico_importer_invenio/connector.py
InvenioConnector.get_records_from_basket
def get_records_from_basket(self, bskid, group_basket=False, read_cache=True): """ Returns the records from the (public) basket with given bskid """ if bskid not in self.cached_baskets or not read_cache: if self.user: if group_basket: group...
python
def get_records_from_basket(self, bskid, group_basket=False, read_cache=True): """ Returns the records from the (public) basket with given bskid """ if bskid not in self.cached_baskets or not read_cache: if self.user: if group_basket: group...
Returns the records from the (public) basket with given bskid
https://github.com/indico/indico-plugins/blob/fe50085cc63be9b8161b09539e662e7b04e4b38e/importer_invenio/indico_importer_invenio/connector.py#L338-L358
indico/indico-plugins
importer_invenio/indico_importer_invenio/connector.py
InvenioConnector.get_record
def get_record(self, recid, read_cache=True): """ Returns the record with given recid """ if recid in self.cached_records or not read_cache: return self.cached_records[recid] else: return self.search(p="recid:" + str(recid))
python
def get_record(self, recid, read_cache=True): """ Returns the record with given recid """ if recid in self.cached_records or not read_cache: return self.cached_records[recid] else: return self.search(p="recid:" + str(recid))
Returns the record with given recid
https://github.com/indico/indico-plugins/blob/fe50085cc63be9b8161b09539e662e7b04e4b38e/importer_invenio/indico_importer_invenio/connector.py#L360-L367
indico/indico-plugins
importer_invenio/indico_importer_invenio/connector.py
InvenioConnector.upload_marcxml
def upload_marcxml(self, marcxml, mode): """ Uploads a record to the server Parameters: marcxml - *str* the XML to upload. mode - *str* the mode to use for the upload. "-i" insert new records "-r" replace existing records ...
python
def upload_marcxml(self, marcxml, mode): """ Uploads a record to the server Parameters: marcxml - *str* the XML to upload. mode - *str* the mode to use for the upload. "-i" insert new records "-r" replace existing records ...
Uploads a record to the server Parameters: marcxml - *str* the XML to upload. mode - *str* the mode to use for the upload. "-i" insert new records "-r" replace existing records "-c" correct fields of records ...
https://github.com/indico/indico-plugins/blob/fe50085cc63be9b8161b09539e662e7b04e4b38e/importer_invenio/indico_importer_invenio/connector.py#L369-L400
indico/indico-plugins
importer_invenio/indico_importer_invenio/connector.py
InvenioConnector._parse_results
def _parse_results(self, results, cached_records): """ Parses the given results (in MARCXML format). The given "cached_records" list is a pool of already existing parsed records (in order to avoid keeping several times the same records in memory) """ parser = xml...
python
def _parse_results(self, results, cached_records): """ Parses the given results (in MARCXML format). The given "cached_records" list is a pool of already existing parsed records (in order to avoid keeping several times the same records in memory) """ parser = xml...
Parses the given results (in MARCXML format). The given "cached_records" list is a pool of already existing parsed records (in order to avoid keeping several times the same records in memory)
https://github.com/indico/indico-plugins/blob/fe50085cc63be9b8161b09539e662e7b04e4b38e/importer_invenio/indico_importer_invenio/connector.py#L402-L414
indico/indico-plugins
importer_invenio/indico_importer_invenio/connector.py
InvenioConnector._validate_server_url
def _validate_server_url(self): """Validates self.server_url""" try: request = requests.head(self.server_url) if request.status_code >= 400: raise InvenioConnectorServerError( "Unexpected status code '%d' accessing URL: %s" ...
python
def _validate_server_url(self): """Validates self.server_url""" try: request = requests.head(self.server_url) if request.status_code >= 400: raise InvenioConnectorServerError( "Unexpected status code '%d' accessing URL: %s" ...
Validates self.server_url
https://github.com/indico/indico-plugins/blob/fe50085cc63be9b8161b09539e662e7b04e4b38e/importer_invenio/indico_importer_invenio/connector.py#L416-L438
indico/indico-plugins
piwik/indico_piwik/queries/metrics.py
PiwikQueryReportEventMetricDownloads._get_cumulative_results
def _get_cumulative_results(self, results): """ Returns a dictionary of {'total': x, 'unique': y} for the date range. """ hits = {'total': 0, 'unique': 0} day_hits = list(hits[0] for hits in results.values() if hits) for metrics in day_hits: hits['tot...
python
def _get_cumulative_results(self, results): """ Returns a dictionary of {'total': x, 'unique': y} for the date range. """ hits = {'total': 0, 'unique': 0} day_hits = list(hits[0] for hits in results.values() if hits) for metrics in day_hits: hits['tot...
Returns a dictionary of {'total': x, 'unique': y} for the date range.
https://github.com/indico/indico-plugins/blob/fe50085cc63be9b8161b09539e662e7b04e4b38e/piwik/indico_piwik/queries/metrics.py#L69-L81
indico/indico-plugins
piwik/indico_piwik/queries/metrics.py
PiwikQueryReportEventMetricReferrers.get_result
def get_result(self): """Perform the call and return a list of referrers""" result = get_json_from_remote_server(self.call) referrers = list(result) for referrer in referrers: referrer['sum_visit_length'] = stringify_seconds(referrer['sum_visit_length']) return sorted...
python
def get_result(self): """Perform the call and return a list of referrers""" result = get_json_from_remote_server(self.call) referrers = list(result) for referrer in referrers: referrer['sum_visit_length'] = stringify_seconds(referrer['sum_visit_length']) return sorted...
Perform the call and return a list of referrers
https://github.com/indico/indico-plugins/blob/fe50085cc63be9b8161b09539e662e7b04e4b38e/piwik/indico_piwik/queries/metrics.py#L89-L95
indico/indico-plugins
piwik/indico_piwik/queries/metrics.py
PiwikQueryReportEventMetricVisitDuration.get_result
def get_result(self): """Perform the call and return a string with the time in hh:mm:ss""" result = get_json_from_remote_server(self.call) seconds = self._get_average_duration(result) if result else 0 return stringify_seconds(seconds)
python
def get_result(self): """Perform the call and return a string with the time in hh:mm:ss""" result = get_json_from_remote_server(self.call) seconds = self._get_average_duration(result) if result else 0 return stringify_seconds(seconds)
Perform the call and return a string with the time in hh:mm:ss
https://github.com/indico/indico-plugins/blob/fe50085cc63be9b8161b09539e662e7b04e4b38e/piwik/indico_piwik/queries/metrics.py#L113-L117
indico/indico-plugins
piwik/indico_piwik/queries/metrics.py
PiwikQueryReportEventMetricPeakDateAndVisitors.get_result
def get_result(self): """Perform the call and return the peak date and how many users""" result = get_json_from_remote_server(self.call) if result: date, value = max(result.iteritems(), key=itemgetter(1)) return {'date': date, 'users': value} else: ret...
python
def get_result(self): """Perform the call and return the peak date and how many users""" result = get_json_from_remote_server(self.call) if result: date, value = max(result.iteritems(), key=itemgetter(1)) return {'date': date, 'users': value} else: ret...
Perform the call and return the peak date and how many users
https://github.com/indico/indico-plugins/blob/fe50085cc63be9b8161b09539e662e7b04e4b38e/piwik/indico_piwik/queries/metrics.py#L135-L142
indico/indico-plugins
piwik/indico_piwik/piwik.py
PiwikRequest.call
def call(self, default_response=None, **query_params): """Perform a query to the Piwik server and return the response. :param default_response: Return value in case the query fails :param query_params: Dictionary with the parameters of the query """ query_url = self.get_query_ur...
python
def call(self, default_response=None, **query_params): """Perform a query to the Piwik server and return the response. :param default_response: Return value in case the query fails :param query_params: Dictionary with the parameters of the query """ query_url = self.get_query_ur...
Perform a query to the Piwik server and return the response. :param default_response: Return value in case the query fails :param query_params: Dictionary with the parameters of the query
https://github.com/indico/indico-plugins/blob/fe50085cc63be9b8161b09539e662e7b04e4b38e/piwik/indico_piwik/piwik.py#L45-L52
indico/indico-plugins
piwik/indico_piwik/piwik.py
PiwikRequest.get_query
def get_query(self, query_params=None): """Return a query string""" if query_params is None: query_params = {} query = '' query_params['idSite'] = self.site_id if self.api_token is not None: query_params['token_auth'] = self.api_token for key, valu...
python
def get_query(self, query_params=None): """Return a query string""" if query_params is None: query_params = {} query = '' query_params['idSite'] = self.site_id if self.api_token is not None: query_params['token_auth'] = self.api_token for key, valu...
Return a query string
https://github.com/indico/indico-plugins/blob/fe50085cc63be9b8161b09539e662e7b04e4b38e/piwik/indico_piwik/piwik.py#L54-L66
indico/indico-plugins
piwik/indico_piwik/piwik.py
PiwikRequest._perform_call
def _perform_call(self, query_url, default_response=None, timeout=10): """Returns the raw results from the API""" try: response = requests.get(query_url, timeout=timeout) except socket.timeout: current_plugin.logger.warning("Timeout contacting Piwik server") r...
python
def _perform_call(self, query_url, default_response=None, timeout=10): """Returns the raw results from the API""" try: response = requests.get(query_url, timeout=timeout) except socket.timeout: current_plugin.logger.warning("Timeout contacting Piwik server") r...
Returns the raw results from the API
https://github.com/indico/indico-plugins/blob/fe50085cc63be9b8161b09539e662e7b04e4b38e/piwik/indico_piwik/piwik.py#L72-L82
indico/indico-plugins
livesync/indico_livesync/uploader.py
Uploader.run
def run(self, records): """Runs the batch upload :param records: an iterable containing queue entries """ self_name = type(self).__name__ for i, batch in enumerate(grouper(records, self.BATCH_SIZE, skip_missing=True), 1): self.logger.info('%s processing batch %d', se...
python
def run(self, records): """Runs the batch upload :param records: an iterable containing queue entries """ self_name = type(self).__name__ for i, batch in enumerate(grouper(records, self.BATCH_SIZE, skip_missing=True), 1): self.logger.info('%s processing batch %d', se...
Runs the batch upload :param records: an iterable containing queue entries
https://github.com/indico/indico-plugins/blob/fe50085cc63be9b8161b09539e662e7b04e4b38e/livesync/indico_livesync/uploader.py#L37-L55
indico/indico-plugins
livesync/indico_livesync/uploader.py
Uploader.run_initial
def run_initial(self, events): """Runs the initial batch upload :param events: an iterable containing events """ self_name = type(self).__name__ for i, batch in enumerate(grouper(events, self.INITIAL_BATCH_SIZE, skip_missing=True), 1): self.logger.debug('%s processin...
python
def run_initial(self, events): """Runs the initial batch upload :param events: an iterable containing events """ self_name = type(self).__name__ for i, batch in enumerate(grouper(events, self.INITIAL_BATCH_SIZE, skip_missing=True), 1): self.logger.debug('%s processin...
Runs the initial batch upload :param events: an iterable containing events
https://github.com/indico/indico-plugins/blob/fe50085cc63be9b8161b09539e662e7b04e4b38e/livesync/indico_livesync/uploader.py#L57-L69
indico/indico-plugins
livesync/indico_livesync/uploader.py
Uploader.processed_records
def processed_records(self, records): """Executed after successfully uploading a batch of records from the queue. :param records: a list of queue entries """ for record in records: self.logger.debug('Marking as processed: %s', record) record.processed = True ...
python
def processed_records(self, records): """Executed after successfully uploading a batch of records from the queue. :param records: a list of queue entries """ for record in records: self.logger.debug('Marking as processed: %s', record) record.processed = True ...
Executed after successfully uploading a batch of records from the queue. :param records: a list of queue entries
https://github.com/indico/indico-plugins/blob/fe50085cc63be9b8161b09539e662e7b04e4b38e/livesync/indico_livesync/uploader.py#L80-L88
indico/indico-plugins
storage_s3/indico_storage_s3/migrate.py
cli
def cli(): """Migrate data to S3. Use the `copy` subcommand to copy data to S3. This can be done safely while Indico is running. At the end it will show you what you need to add to your `indico.conf`. Once you updated your config with the new storage backends, you can use the `apply` subcomman...
python
def cli(): """Migrate data to S3. Use the `copy` subcommand to copy data to S3. This can be done safely while Indico is running. At the end it will show you what you need to add to your `indico.conf`. Once you updated your config with the new storage backends, you can use the `apply` subcomman...
Migrate data to S3. Use the `copy` subcommand to copy data to S3. This can be done safely while Indico is running. At the end it will show you what you need to add to your `indico.conf`. Once you updated your config with the new storage backends, you can use the `apply` subcommand to update your d...
https://github.com/indico/indico-plugins/blob/fe50085cc63be9b8161b09539e662e7b04e4b38e/storage_s3/indico_storage_s3/migrate.py#L385-L403
indico/indico-plugins
storage_s3/indico_storage_s3/migrate.py
copy
def copy(source_backend_names, bucket_names, static_bucket_name, s3_endpoint, s3_profile, s3_bucket_policy_file, rclone, output): """Copy files to S3. This command copies files to S3 and records the necessary database changes in a JSONL file. Multiple bucket names can be specified; in that ca...
python
def copy(source_backend_names, bucket_names, static_bucket_name, s3_endpoint, s3_profile, s3_bucket_policy_file, rclone, output): """Copy files to S3. This command copies files to S3 and records the necessary database changes in a JSONL file. Multiple bucket names can be specified; in that ca...
Copy files to S3. This command copies files to S3 and records the necessary database changes in a JSONL file. Multiple bucket names can be specified; in that case the bucket name can change based on the year a file was created in. The last bucket name will be the default, while any other bucket na...
https://github.com/indico/indico-plugins/blob/fe50085cc63be9b8161b09539e662e7b04e4b38e/storage_s3/indico_storage_s3/migrate.py#L421-L491
Kane610/deconz
pydeconz/__init__.py
DeconzSession.start
def start(self) -> None: """Connect websocket to deCONZ.""" if self.config: self.websocket = self.ws_client( self.loop, self.session, self.host, self.config.websocketport, self.async_session_handler) self.websocket.start() else: ...
python
def start(self) -> None: """Connect websocket to deCONZ.""" if self.config: self.websocket = self.ws_client( self.loop, self.session, self.host, self.config.websocketport, self.async_session_handler) self.websocket.start() else: ...
Connect websocket to deCONZ.
https://github.com/Kane610/deconz/blob/8a9498dbbc8c168d4a081173ad6c3b1e17fffdf6/pydeconz/__init__.py#L38-L46
Kane610/deconz
pydeconz/__init__.py
DeconzSession.async_load_parameters
async def async_load_parameters(self) -> bool: """Load deCONZ parameters. Returns lists of indices of which devices was added. """ data = await self.async_get_state('') _LOGGER.debug(pformat(data)) config = data.get('config', {}) groups = data.get('groups', {})...
python
async def async_load_parameters(self) -> bool: """Load deCONZ parameters. Returns lists of indices of which devices was added. """ data = await self.async_get_state('') _LOGGER.debug(pformat(data)) config = data.get('config', {}) groups = data.get('groups', {})...
Load deCONZ parameters. Returns lists of indices of which devices was added.
https://github.com/Kane610/deconz/blob/8a9498dbbc8c168d4a081173ad6c3b1e17fffdf6/pydeconz/__init__.py#L54-L101
Kane610/deconz
pydeconz/__init__.py
DeconzSession.async_put_state
async def async_put_state(self, field: str, data: dict) -> dict: """Set state of object in deCONZ. Field is a string representing a specific device in deCONZ e.g. field='/lights/1/state'. Data is a json object with what data you want to alter e.g. data={'on': True}. See ...
python
async def async_put_state(self, field: str, data: dict) -> dict: """Set state of object in deCONZ. Field is a string representing a specific device in deCONZ e.g. field='/lights/1/state'. Data is a json object with what data you want to alter e.g. data={'on': True}. See ...
Set state of object in deCONZ. Field is a string representing a specific device in deCONZ e.g. field='/lights/1/state'. Data is a json object with what data you want to alter e.g. data={'on': True}. See Dresden Elektroniks REST API documentation for details: http://dresd...
https://github.com/Kane610/deconz/blob/8a9498dbbc8c168d4a081173ad6c3b1e17fffdf6/pydeconz/__init__.py#L103-L117
Kane610/deconz
pydeconz/__init__.py
DeconzSession.async_get_state
async def async_get_state(self, field: str) -> dict: """Get state of object in deCONZ. Field is a string representing an API endpoint or lower e.g. field='/lights'. See Dresden Elektroniks REST API documentation for details: http://dresden-elektronik.github.io/deconz-rest-doc/re...
python
async def async_get_state(self, field: str) -> dict: """Get state of object in deCONZ. Field is a string representing an API endpoint or lower e.g. field='/lights'. See Dresden Elektroniks REST API documentation for details: http://dresden-elektronik.github.io/deconz-rest-doc/re...
Get state of object in deCONZ. Field is a string representing an API endpoint or lower e.g. field='/lights'. See Dresden Elektroniks REST API documentation for details: http://dresden-elektronik.github.io/deconz-rest-doc/rest/
https://github.com/Kane610/deconz/blob/8a9498dbbc8c168d4a081173ad6c3b1e17fffdf6/pydeconz/__init__.py#L119-L130
Kane610/deconz
pydeconz/__init__.py
DeconzSession.async_session_handler
def async_session_handler(self, signal: str) -> None: """Signalling from websocket. data - new data available for processing. state - network state has changed. """ if signal == 'data': self.async_event_handler(self.websocket.data) elif signal == 'state...
python
def async_session_handler(self, signal: str) -> None: """Signalling from websocket. data - new data available for processing. state - network state has changed. """ if signal == 'data': self.async_event_handler(self.websocket.data) elif signal == 'state...
Signalling from websocket. data - new data available for processing. state - network state has changed.
https://github.com/Kane610/deconz/blob/8a9498dbbc8c168d4a081173ad6c3b1e17fffdf6/pydeconz/__init__.py#L132-L143
Kane610/deconz
pydeconz/__init__.py
DeconzSession.async_event_handler
def async_event_handler(self, event: dict) -> None: """Receive event from websocket and identifies where the event belong. { "t": "event", "e": "changed", "r": "sensors", "id": "12", "state": { "buttonevent": 2002 } } """ ...
python
def async_event_handler(self, event: dict) -> None: """Receive event from websocket and identifies where the event belong. { "t": "event", "e": "changed", "r": "sensors", "id": "12", "state": { "buttonevent": 2002 } } """ ...
Receive event from websocket and identifies where the event belong. { "t": "event", "e": "changed", "r": "sensors", "id": "12", "state": { "buttonevent": 2002 } }
https://github.com/Kane610/deconz/blob/8a9498dbbc8c168d4a081173ad6c3b1e17fffdf6/pydeconz/__init__.py#L145-L198
Kane610/deconz
pydeconz/__init__.py
DeconzSession.update_group_color
def update_group_color(self, lights: list) -> None: """Update group colors based on light states. deCONZ group updates don't contain any information about the current state of the lights in the group. This method updates the color properties of the group to the current color of the ligh...
python
def update_group_color(self, lights: list) -> None: """Update group colors based on light states. deCONZ group updates don't contain any information about the current state of the lights in the group. This method updates the color properties of the group to the current color of the ligh...
Update group colors based on light states. deCONZ group updates don't contain any information about the current state of the lights in the group. This method updates the color properties of the group to the current color of the lights in the group. For groups where the lights h...
https://github.com/Kane610/deconz/blob/8a9498dbbc8c168d4a081173ad6c3b1e17fffdf6/pydeconz/__init__.py#L200-L225
sbg/sevenbridges-python
sevenbridges/models/storage_export.py
Export.submit_export
def submit_export(cls, file, volume, location, properties=None, overwrite=False, copy_only=False, api=None): """ Submit new export job. :param file: File to be exported. :param volume: Volume identifier. :param location: Volume location. :param prop...
python
def submit_export(cls, file, volume, location, properties=None, overwrite=False, copy_only=False, api=None): """ Submit new export job. :param file: File to be exported. :param volume: Volume identifier. :param location: Volume location. :param prop...
Submit new export job. :param file: File to be exported. :param volume: Volume identifier. :param location: Volume location. :param properties: Properties dictionary. :param overwrite: If true it will overwrite file if exists :param copy_only: If true files are kept on Se...
https://github.com/sbg/sevenbridges-python/blob/f62640d1018d959f0b686f2dbe5e183085336607/sevenbridges/models/storage_export.py#L74-L122
sbg/sevenbridges-python
sevenbridges/models/storage_export.py
Export.query
def query(cls, volume=None, state=None, offset=None, limit=None, api=None): """ Query (List) exports. :param volume: Optional volume identifier. :param state: Optional import sate. :param api: Api instance. :return: Collection object. """ ap...
python
def query(cls, volume=None, state=None, offset=None, limit=None, api=None): """ Query (List) exports. :param volume: Optional volume identifier. :param state: Optional import sate. :param api: Api instance. :return: Collection object. """ ap...
Query (List) exports. :param volume: Optional volume identifier. :param state: Optional import sate. :param api: Api instance. :return: Collection object.
https://github.com/sbg/sevenbridges-python/blob/f62640d1018d959f0b686f2dbe5e183085336607/sevenbridges/models/storage_export.py#L125-L143
sbg/sevenbridges-python
sevenbridges/models/storage_export.py
Export.bulk_get
def bulk_get(cls, exports, api=None): """ Retrieve exports in bulk. :param exports: Exports to be retrieved. :param api: Api instance. :return: list of ExportBulkRecord objects. """ api = api or cls._API export_ids = [Transform.to_export(export) for export...
python
def bulk_get(cls, exports, api=None): """ Retrieve exports in bulk. :param exports: Exports to be retrieved. :param api: Api instance. :return: list of ExportBulkRecord objects. """ api = api or cls._API export_ids = [Transform.to_export(export) for export...
Retrieve exports in bulk. :param exports: Exports to be retrieved. :param api: Api instance. :return: list of ExportBulkRecord objects.
https://github.com/sbg/sevenbridges-python/blob/f62640d1018d959f0b686f2dbe5e183085336607/sevenbridges/models/storage_export.py#L146-L158
sbg/sevenbridges-python
sevenbridges/models/storage_export.py
Export.bulk_submit
def bulk_submit(cls, exports, copy_only=False, api=None): """ Create exports in bulk. :param exports: Exports to be submitted in bulk. :param copy_only: If true files are kept on SevenBridges bucket. :param api: Api instance. :return: list of ExportBulkRecord objects. ...
python
def bulk_submit(cls, exports, copy_only=False, api=None): """ Create exports in bulk. :param exports: Exports to be submitted in bulk. :param copy_only: If true files are kept on SevenBridges bucket. :param api: Api instance. :return: list of ExportBulkRecord objects. ...
Create exports in bulk. :param exports: Exports to be submitted in bulk. :param copy_only: If true files are kept on SevenBridges bucket. :param api: Api instance. :return: list of ExportBulkRecord objects.
https://github.com/sbg/sevenbridges-python/blob/f62640d1018d959f0b686f2dbe5e183085336607/sevenbridges/models/storage_export.py#L161-L202
sbg/sevenbridges-python
sevenbridges/models/division.py
Division.query
def query(cls, offset=None, limit=None, api=None): """ Query (List) divisions. :param offset: Pagination offset. :param limit: Pagination limit. :param api: Api instance. :return: Collection object. """ api = api if api else cls._API return super(...
python
def query(cls, offset=None, limit=None, api=None): """ Query (List) divisions. :param offset: Pagination offset. :param limit: Pagination limit. :param api: Api instance. :return: Collection object. """ api = api if api else cls._API return super(...
Query (List) divisions. :param offset: Pagination offset. :param limit: Pagination limit. :param api: Api instance. :return: Collection object.
https://github.com/sbg/sevenbridges-python/blob/f62640d1018d959f0b686f2dbe5e183085336607/sevenbridges/models/division.py#L34-L47
Kane610/deconz
pydeconz/utils.py
async_get_api_key
async def async_get_api_key(session, host, port, username=None, password=None, **kwargs): """Get a new API key for devicetype.""" url = 'http://{host}:{port}/api'.format(host=host, port=str(port)) auth = None if username and password: auth = aiohttp.BasicAuth(username, password=password) d...
python
async def async_get_api_key(session, host, port, username=None, password=None, **kwargs): """Get a new API key for devicetype.""" url = 'http://{host}:{port}/api'.format(host=host, port=str(port)) auth = None if username and password: auth = aiohttp.BasicAuth(username, password=password) d...
Get a new API key for devicetype.
https://github.com/Kane610/deconz/blob/8a9498dbbc8c168d4a081173ad6c3b1e17fffdf6/pydeconz/utils.py#L14-L27
Kane610/deconz
pydeconz/utils.py
async_delete_api_key
async def async_delete_api_key(session, host, port, api_key): """Delete API key from deCONZ.""" url = 'http://{host}:{port}/api/{api_key}/config/whitelist/{api_key}'.format( host=host, port=str(port), api_key=api_key) response = await async_request(session.delete, url) _LOGGER.info(response)
python
async def async_delete_api_key(session, host, port, api_key): """Delete API key from deCONZ.""" url = 'http://{host}:{port}/api/{api_key}/config/whitelist/{api_key}'.format( host=host, port=str(port), api_key=api_key) response = await async_request(session.delete, url) _LOGGER.info(response)
Delete API key from deCONZ.
https://github.com/Kane610/deconz/blob/8a9498dbbc8c168d4a081173ad6c3b1e17fffdf6/pydeconz/utils.py#L30-L37
Kane610/deconz
pydeconz/utils.py
async_delete_all_keys
async def async_delete_all_keys(session, host, port, api_key, api_keys=[]): """Delete all API keys except for the ones provided to the method.""" url = 'http://{}:{}/api/{}/config'.format(host, str(port), api_key) response = await async_request(session.get, url) api_keys.append(api_key) for key in...
python
async def async_delete_all_keys(session, host, port, api_key, api_keys=[]): """Delete all API keys except for the ones provided to the method.""" url = 'http://{}:{}/api/{}/config'.format(host, str(port), api_key) response = await async_request(session.get, url) api_keys.append(api_key) for key in...
Delete all API keys except for the ones provided to the method.
https://github.com/Kane610/deconz/blob/8a9498dbbc8c168d4a081173ad6c3b1e17fffdf6/pydeconz/utils.py#L40-L49
Kane610/deconz
pydeconz/utils.py
async_get_bridgeid
async def async_get_bridgeid(session, host, port, api_key, **kwargs): """Get bridge id for bridge.""" url = 'http://{}:{}/api/{}/config'.format(host, str(port), api_key) response = await async_request(session.get, url) bridgeid = response['bridgeid'] _LOGGER.info("Bridge id: %s", bridgeid) ret...
python
async def async_get_bridgeid(session, host, port, api_key, **kwargs): """Get bridge id for bridge.""" url = 'http://{}:{}/api/{}/config'.format(host, str(port), api_key) response = await async_request(session.get, url) bridgeid = response['bridgeid'] _LOGGER.info("Bridge id: %s", bridgeid) ret...
Get bridge id for bridge.
https://github.com/Kane610/deconz/blob/8a9498dbbc8c168d4a081173ad6c3b1e17fffdf6/pydeconz/utils.py#L52-L60
Kane610/deconz
pydeconz/utils.py
async_discovery
async def async_discovery(session): """Find bridges allowing gateway discovery.""" bridges = [] response = await async_request(session.get, URL_DISCOVER) if not response: _LOGGER.info("No discoverable bridges available.") return bridges for bridge in response: bridges.appen...
python
async def async_discovery(session): """Find bridges allowing gateway discovery.""" bridges = [] response = await async_request(session.get, URL_DISCOVER) if not response: _LOGGER.info("No discoverable bridges available.") return bridges for bridge in response: bridges.appen...
Find bridges allowing gateway discovery.
https://github.com/Kane610/deconz/blob/8a9498dbbc8c168d4a081173ad6c3b1e17fffdf6/pydeconz/utils.py#L63-L79
Kane610/deconz
pydeconz/utils.py
async_request
async def async_request(session, url, **kwargs): """Do a web request and manage response.""" _LOGGER.debug("Sending %s to %s", kwargs, url) try: res = await session(url, **kwargs) if res.content_type != 'application/json': raise ResponseError( "Invalid content t...
python
async def async_request(session, url, **kwargs): """Do a web request and manage response.""" _LOGGER.debug("Sending %s to %s", kwargs, url) try: res = await session(url, **kwargs) if res.content_type != 'application/json': raise ResponseError( "Invalid content t...
Do a web request and manage response.
https://github.com/Kane610/deconz/blob/8a9498dbbc8c168d4a081173ad6c3b1e17fffdf6/pydeconz/utils.py#L82-L103
Kane610/deconz
pydeconz/websocket.py
AIOWSClient.running
async def running(self): """Start websocket connection.""" url = 'http://{}:{}'.format(self.host, self.port) try: async with self.session.ws_connect(url) as ws: self.state = STATE_RUNNING async for msg in ws: if self.state == STATE_...
python
async def running(self): """Start websocket connection.""" url = 'http://{}:{}'.format(self.host, self.port) try: async with self.session.ws_connect(url) as ws: self.state = STATE_RUNNING async for msg in ws: if self.state == STATE_...
Start websocket connection.
https://github.com/Kane610/deconz/blob/8a9498dbbc8c168d4a081173ad6c3b1e17fffdf6/pydeconz/websocket.py#L56-L82
Kane610/deconz
pydeconz/websocket.py
AIOWSClient.retry
def retry(self): """Retry to connect to deCONZ.""" self.state = STATE_STARTING self.loop.call_later(RETRY_TIMER, self.start) _LOGGER.debug('Reconnecting to deCONZ in %i.', RETRY_TIMER)
python
def retry(self): """Retry to connect to deCONZ.""" self.state = STATE_STARTING self.loop.call_later(RETRY_TIMER, self.start) _LOGGER.debug('Reconnecting to deCONZ in %i.', RETRY_TIMER)
Retry to connect to deCONZ.
https://github.com/Kane610/deconz/blob/8a9498dbbc8c168d4a081173ad6c3b1e17fffdf6/pydeconz/websocket.py#L88-L92
Kane610/deconz
pydeconz/websocket.py
WSClient.start
def start(self): """Start websocket connection.""" if self.state != STATE_RUNNING: conn = self.loop.create_connection( lambda: self, self.host, self.port) task = self.loop.create_task(conn) task.add_done_callback(self.init_done) self.state ...
python
def start(self): """Start websocket connection.""" if self.state != STATE_RUNNING: conn = self.loop.create_connection( lambda: self, self.host, self.port) task = self.loop.create_task(conn) task.add_done_callback(self.init_done) self.state ...
Start websocket connection.
https://github.com/Kane610/deconz/blob/8a9498dbbc8c168d4a081173ad6c3b1e17fffdf6/pydeconz/websocket.py#L109-L116
Kane610/deconz
pydeconz/websocket.py
WSClient.init_done
def init_done(self, fut): """Server ready. If we get OSError during init the device is not available. """ try: if fut.exception(): fut.result() except OSError as err: _LOGGER.debug('Got exception %s', err) self.retry()
python
def init_done(self, fut): """Server ready. If we get OSError during init the device is not available. """ try: if fut.exception(): fut.result() except OSError as err: _LOGGER.debug('Got exception %s', err) self.retry()
Server ready. If we get OSError during init the device is not available.
https://github.com/Kane610/deconz/blob/8a9498dbbc8c168d4a081173ad6c3b1e17fffdf6/pydeconz/websocket.py#L118-L128
Kane610/deconz
pydeconz/websocket.py
WSClient.stop
def stop(self): """Close websocket connection.""" self.state = STATE_STOPPED if self.transport: self.transport.close()
python
def stop(self): """Close websocket connection.""" self.state = STATE_STOPPED if self.transport: self.transport.close()
Close websocket connection.
https://github.com/Kane610/deconz/blob/8a9498dbbc8c168d4a081173ad6c3b1e17fffdf6/pydeconz/websocket.py#L146-L150
Kane610/deconz
pydeconz/websocket.py
WSClient.connection_made
def connection_made(self, transport): """Do the websocket handshake. According to https://tools.ietf.org/html/rfc6455 """ randomness = os.urandom(16) key = base64encode(randomness).decode('utf-8').strip() self.transport = transport message = "GET / HTTP/1.1\r\n" ...
python
def connection_made(self, transport): """Do the websocket handshake. According to https://tools.ietf.org/html/rfc6455 """ randomness = os.urandom(16) key = base64encode(randomness).decode('utf-8').strip() self.transport = transport message = "GET / HTTP/1.1\r\n" ...
Do the websocket handshake. According to https://tools.ietf.org/html/rfc6455
https://github.com/Kane610/deconz/blob/8a9498dbbc8c168d4a081173ad6c3b1e17fffdf6/pydeconz/websocket.py#L157-L174
Kane610/deconz
pydeconz/websocket.py
WSClient.data_received
def data_received(self, data): """Data received over websocket. First received data will allways be handshake accepting connection. We need to check how big the header is so we can send event data as a proper json object. """ if self.state == STATE_STARTING: ...
python
def data_received(self, data): """Data received over websocket. First received data will allways be handshake accepting connection. We need to check how big the header is so we can send event data as a proper json object. """ if self.state == STATE_STARTING: ...
Data received over websocket. First received data will allways be handshake accepting connection. We need to check how big the header is so we can send event data as a proper json object.
https://github.com/Kane610/deconz/blob/8a9498dbbc8c168d4a081173ad6c3b1e17fffdf6/pydeconz/websocket.py#L176-L194
Kane610/deconz
pydeconz/websocket.py
WSClient.connection_lost
def connection_lost(self, exc): """Happen when device closes connection or stop() has been called.""" if self.state == STATE_RUNNING: _LOGGER.warning('Lost connection to deCONZ') self.retry()
python
def connection_lost(self, exc): """Happen when device closes connection or stop() has been called.""" if self.state == STATE_RUNNING: _LOGGER.warning('Lost connection to deCONZ') self.retry()
Happen when device closes connection or stop() has been called.
https://github.com/Kane610/deconz/blob/8a9498dbbc8c168d4a081173ad6c3b1e17fffdf6/pydeconz/websocket.py#L196-L200
Kane610/deconz
pydeconz/websocket.py
WSClient.get_payload
def get_payload(self, data): """Parse length of payload and return it.""" start = 2 length = ord(data[1:2]) if length == 126: # Payload information are an extra 2 bytes. start = 4 length, = unpack(">H", data[2:4]) elif length == 127: ...
python
def get_payload(self, data): """Parse length of payload and return it.""" start = 2 length = ord(data[1:2]) if length == 126: # Payload information are an extra 2 bytes. start = 4 length, = unpack(">H", data[2:4]) elif length == 127: ...
Parse length of payload and return it.
https://github.com/Kane610/deconz/blob/8a9498dbbc8c168d4a081173ad6c3b1e17fffdf6/pydeconz/websocket.py#L202-L217
indico/indico-plugins
vc_vidyo/indico_vc_vidyo/task.py
find_old_vidyo_rooms
def find_old_vidyo_rooms(max_room_event_age): """Finds all Vidyo rooms that are: - linked to no events - linked only to events whose start date precedes today - max_room_event_age days """ recently_used = (db.session.query(VCRoom.id) .filter(VCRoom.type == 'vidyo', ...
python
def find_old_vidyo_rooms(max_room_event_age): """Finds all Vidyo rooms that are: - linked to no events - linked only to events whose start date precedes today - max_room_event_age days """ recently_used = (db.session.query(VCRoom.id) .filter(VCRoom.type == 'vidyo', ...
Finds all Vidyo rooms that are: - linked to no events - linked only to events whose start date precedes today - max_room_event_age days
https://github.com/indico/indico-plugins/blob/fe50085cc63be9b8161b09539e662e7b04e4b38e/vc_vidyo/indico_vc_vidyo/task.py#L35-L48
indico/indico-plugins
vc_vidyo/indico_vc_vidyo/task.py
notify_owner
def notify_owner(plugin, vc_room): """Notifies about the deletion of a Vidyo room from the Vidyo server.""" user = vc_room.vidyo_extension.owned_by_user tpl = get_plugin_template_module('emails/remote_deleted.html', plugin=plugin, vc_room=vc_room, event=None, vc_room_eve...
python
def notify_owner(plugin, vc_room): """Notifies about the deletion of a Vidyo room from the Vidyo server.""" user = vc_room.vidyo_extension.owned_by_user tpl = get_plugin_template_module('emails/remote_deleted.html', plugin=plugin, vc_room=vc_room, event=None, vc_room_eve...
Notifies about the deletion of a Vidyo room from the Vidyo server.
https://github.com/indico/indico-plugins/blob/fe50085cc63be9b8161b09539e662e7b04e4b38e/vc_vidyo/indico_vc_vidyo/task.py#L51-L56
indico/indico-plugins
vc_vidyo/indico_vc_vidyo/cli.py
rooms
def rooms(status=None): """Lists all Vidyo rooms""" room_query = VCRoom.find(type='vidyo') table_data = [['ID', 'Name', 'Status', 'Vidyo ID', 'Extension']] if status: room_query = room_query.filter(VCRoom.status == VCRoomStatus.get(status)) for room in room_query: table_data.appen...
python
def rooms(status=None): """Lists all Vidyo rooms""" room_query = VCRoom.find(type='vidyo') table_data = [['ID', 'Name', 'Status', 'Vidyo ID', 'Extension']] if status: room_query = room_query.filter(VCRoom.status == VCRoomStatus.get(status)) for room in room_query: table_data.appen...
Lists all Vidyo rooms
https://github.com/indico/indico-plugins/blob/fe50085cc63be9b8161b09539e662e7b04e4b38e/vc_vidyo/indico_vc_vidyo/cli.py#L33-L49
sbg/sevenbridges-python
sevenbridges/http/client.py
config_vars
def config_vars(profiles, advance_access): """ Utility method to fetch config vars using ini section profile :param profiles: profile name. :param advance_access: advance_access flag. :return: """ for profile in profiles: try: config = Config(profile, advance_access=advan...
python
def config_vars(profiles, advance_access): """ Utility method to fetch config vars using ini section profile :param profiles: profile name. :param advance_access: advance_access flag. :return: """ for profile in profiles: try: config = Config(profile, advance_access=advan...
Utility method to fetch config vars using ini section profile :param profiles: profile name. :param advance_access: advance_access flag. :return:
https://github.com/sbg/sevenbridges-python/blob/f62640d1018d959f0b686f2dbe5e183085336607/sevenbridges/http/client.py#L63-L80
sbg/sevenbridges-python
sevenbridges/http/client.py
RequestSession.send
def send(self, request, **kwargs): """Send prepared request :param request: Prepared request to be sent :param kwargs: request keyword arguments :return: Request response """ if len(request.url) > self.MAX_URL_LENGTH: raise URITooLong( message=...
python
def send(self, request, **kwargs): """Send prepared request :param request: Prepared request to be sent :param kwargs: request keyword arguments :return: Request response """ if len(request.url) > self.MAX_URL_LENGTH: raise URITooLong( message=...
Send prepared request :param request: Prepared request to be sent :param kwargs: request keyword arguments :return: Request response
https://github.com/sbg/sevenbridges-python/blob/f62640d1018d959f0b686f2dbe5e183085336607/sevenbridges/http/client.py#L35-L48
indico/indico-plugins
search/indico_search/util.py
render_engine_or_search_template
def render_engine_or_search_template(template_name, **context): """Renders a template from the engine plugin or the search plugin If the template is available in the engine plugin, it's taken from there, otherwise the template from this plugin is used. :param template_name: name of the template :p...
python
def render_engine_or_search_template(template_name, **context): """Renders a template from the engine plugin or the search plugin If the template is available in the engine plugin, it's taken from there, otherwise the template from this plugin is used. :param template_name: name of the template :p...
Renders a template from the engine plugin or the search plugin If the template is available in the engine plugin, it's taken from there, otherwise the template from this plugin is used. :param template_name: name of the template :param context: the variables that should be available in the ...
https://github.com/indico/indico-plugins/blob/fe50085cc63be9b8161b09539e662e7b04e4b38e/search/indico_search/util.py#L22-L37
indico/indico-plugins
vc_vidyo/indico_vc_vidyo/util.py
iter_user_identities
def iter_user_identities(user): """Iterates over all existing user identities that can be used with Vidyo""" from indico_vc_vidyo.plugin import VidyoPlugin providers = authenticators_re.split(VidyoPlugin.settings.get('authenticators')) done = set() for provider in providers: for _, identifie...
python
def iter_user_identities(user): """Iterates over all existing user identities that can be used with Vidyo""" from indico_vc_vidyo.plugin import VidyoPlugin providers = authenticators_re.split(VidyoPlugin.settings.get('authenticators')) done = set() for provider in providers: for _, identifie...
Iterates over all existing user identities that can be used with Vidyo
https://github.com/indico/indico-plugins/blob/fe50085cc63be9b8161b09539e662e7b04e4b38e/vc_vidyo/indico_vc_vidyo/util.py#L32-L42
indico/indico-plugins
vc_vidyo/indico_vc_vidyo/util.py
get_user_from_identifier
def get_user_from_identifier(settings, identifier): """Get an actual User object from an identifier""" providers = list(auth.strip() for auth in settings.get('authenticators').split(',')) identities = Identity.find_all(Identity.provider.in_(providers), Identity.identifier == identifier) if identities: ...
python
def get_user_from_identifier(settings, identifier): """Get an actual User object from an identifier""" providers = list(auth.strip() for auth in settings.get('authenticators').split(',')) identities = Identity.find_all(Identity.provider.in_(providers), Identity.identifier == identifier) if identities: ...
Get an actual User object from an identifier
https://github.com/indico/indico-plugins/blob/fe50085cc63be9b8161b09539e662e7b04e4b38e/vc_vidyo/indico_vc_vidyo/util.py#L45-L65
indico/indico-plugins
vc_vidyo/indico_vc_vidyo/util.py
iter_extensions
def iter_extensions(prefix, event_id): """Return extension (prefix + event_id) with an optional suffix which is incremented step by step in case of collision """ extension = '{prefix}{event_id}'.format(prefix=prefix, event_id=event_id) yield extension suffix = 1 while True: yield ...
python
def iter_extensions(prefix, event_id): """Return extension (prefix + event_id) with an optional suffix which is incremented step by step in case of collision """ extension = '{prefix}{event_id}'.format(prefix=prefix, event_id=event_id) yield extension suffix = 1 while True: yield ...
Return extension (prefix + event_id) with an optional suffix which is incremented step by step in case of collision
https://github.com/indico/indico-plugins/blob/fe50085cc63be9b8161b09539e662e7b04e4b38e/vc_vidyo/indico_vc_vidyo/util.py#L68-L77
indico/indico-plugins
vc_vidyo/indico_vc_vidyo/util.py
update_room_from_obj
def update_room_from_obj(settings, vc_room, room_obj): """Updates a VCRoom DB object using a SOAP room object returned by the API""" vc_room.name = room_obj.name if room_obj.ownerName != vc_room.data['owner_identity']: owner = get_user_from_identifier(settings, room_obj.ownerName) or User.get_system...
python
def update_room_from_obj(settings, vc_room, room_obj): """Updates a VCRoom DB object using a SOAP room object returned by the API""" vc_room.name = room_obj.name if room_obj.ownerName != vc_room.data['owner_identity']: owner = get_user_from_identifier(settings, room_obj.ownerName) or User.get_system...
Updates a VCRoom DB object using a SOAP room object returned by the API
https://github.com/indico/indico-plugins/blob/fe50085cc63be9b8161b09539e662e7b04e4b38e/vc_vidyo/indico_vc_vidyo/util.py#L80-L95
sbg/sevenbridges-python
sevenbridges/models/endpoints.py
Endpoints.get
def get(cls, api=None, **kwargs): """ Get api links. :param api: Api instance. :return: Endpoints object. """ api = api if api else cls._API extra = { 'resource': cls.__name__, 'query': {} } logger.info('Getting resources', ...
python
def get(cls, api=None, **kwargs): """ Get api links. :param api: Api instance. :return: Endpoints object. """ api = api if api else cls._API extra = { 'resource': cls.__name__, 'query': {} } logger.info('Getting resources', ...
Get api links. :param api: Api instance. :return: Endpoints object.
https://github.com/sbg/sevenbridges-python/blob/f62640d1018d959f0b686f2dbe5e183085336607/sevenbridges/models/endpoints.py#L30-L43
CygnusNetworks/pypureomapi
pypureomapi.py
parse_chain
def parse_chain(*args): """Creates a new parser that executes the passed parsers (args) with the previous results and yields a tuple of the results. >>> list(parse_chain(lambda: (None, 1), lambda one: (None, 2))) [None, None, (1, 2)] @param args: parsers @returns: parser """ items = [] for parser in args: ...
python
def parse_chain(*args): """Creates a new parser that executes the passed parsers (args) with the previous results and yields a tuple of the results. >>> list(parse_chain(lambda: (None, 1), lambda one: (None, 2))) [None, None, (1, 2)] @param args: parsers @returns: parser """ items = [] for parser in args: ...
Creates a new parser that executes the passed parsers (args) with the previous results and yields a tuple of the results. >>> list(parse_chain(lambda: (None, 1), lambda one: (None, 2))) [None, None, (1, 2)] @param args: parsers @returns: parser
https://github.com/CygnusNetworks/pypureomapi/blob/ff4459678ec023fd56e64ce518a86860efec26bf/pypureomapi.py#L567-L585
CygnusNetworks/pypureomapi
pypureomapi.py
pack_ip
def pack_ip(ipstr): """Converts an ip address given in dotted notation to a four byte string in network byte order. >>> len(pack_ip("127.0.0.1")) 4 >>> pack_ip("foo") Traceback (most recent call last): ... ValueError: given ip address has an invalid number of dots @type ipstr: str @rtype: bytes @raises Val...
python
def pack_ip(ipstr): """Converts an ip address given in dotted notation to a four byte string in network byte order. >>> len(pack_ip("127.0.0.1")) 4 >>> pack_ip("foo") Traceback (most recent call last): ... ValueError: given ip address has an invalid number of dots @type ipstr: str @rtype: bytes @raises Val...
Converts an ip address given in dotted notation to a four byte string in network byte order. >>> len(pack_ip("127.0.0.1")) 4 >>> pack_ip("foo") Traceback (most recent call last): ... ValueError: given ip address has an invalid number of dots @type ipstr: str @rtype: bytes @raises ValueError: for badly forma...
https://github.com/CygnusNetworks/pypureomapi/blob/ff4459678ec023fd56e64ce518a86860efec26bf/pypureomapi.py#L724-L745
CygnusNetworks/pypureomapi
pypureomapi.py
unpack_ip
def unpack_ip(fourbytes): """Converts an ip address given in a four byte string in network byte order to a string in dotted notation. >>> unpack_ip(b"dead") '100.101.97.100' >>> unpack_ip(b"alive") Traceback (most recent call last): ... ValueError: given buffer is not exactly four bytes long @type fourbytes:...
python
def unpack_ip(fourbytes): """Converts an ip address given in a four byte string in network byte order to a string in dotted notation. >>> unpack_ip(b"dead") '100.101.97.100' >>> unpack_ip(b"alive") Traceback (most recent call last): ... ValueError: given buffer is not exactly four bytes long @type fourbytes:...
Converts an ip address given in a four byte string in network byte order to a string in dotted notation. >>> unpack_ip(b"dead") '100.101.97.100' >>> unpack_ip(b"alive") Traceback (most recent call last): ... ValueError: given buffer is not exactly four bytes long @type fourbytes: bytes @rtype: str @raises V...
https://github.com/CygnusNetworks/pypureomapi/blob/ff4459678ec023fd56e64ce518a86860efec26bf/pypureomapi.py#L751-L770
CygnusNetworks/pypureomapi
pypureomapi.py
pack_mac
def pack_mac(macstr): """Converts a mac address given in colon delimited notation to a six byte string in network byte order. >>> pack_mac("30:31:32:33:34:35") == b'012345' True >>> pack_mac("bad") Traceback (most recent call last): ... ValueError: given mac addresses has an invalid number of colons @type m...
python
def pack_mac(macstr): """Converts a mac address given in colon delimited notation to a six byte string in network byte order. >>> pack_mac("30:31:32:33:34:35") == b'012345' True >>> pack_mac("bad") Traceback (most recent call last): ... ValueError: given mac addresses has an invalid number of colons @type m...
Converts a mac address given in colon delimited notation to a six byte string in network byte order. >>> pack_mac("30:31:32:33:34:35") == b'012345' True >>> pack_mac("bad") Traceback (most recent call last): ... ValueError: given mac addresses has an invalid number of colons @type macstr: str @rtype: bytes ...
https://github.com/CygnusNetworks/pypureomapi/blob/ff4459678ec023fd56e64ce518a86860efec26bf/pypureomapi.py#L776-L798
CygnusNetworks/pypureomapi
pypureomapi.py
unpack_mac
def unpack_mac(sixbytes): """Converts a mac address given in a six byte string in network byte order to a string in colon delimited notation. >>> unpack_mac(b"012345") '30:31:32:33:34:35' >>> unpack_mac(b"bad") Traceback (most recent call last): ... ValueError: given buffer is not exactly six bytes long @typ...
python
def unpack_mac(sixbytes): """Converts a mac address given in a six byte string in network byte order to a string in colon delimited notation. >>> unpack_mac(b"012345") '30:31:32:33:34:35' >>> unpack_mac(b"bad") Traceback (most recent call last): ... ValueError: given buffer is not exactly six bytes long @typ...
Converts a mac address given in a six byte string in network byte order to a string in colon delimited notation. >>> unpack_mac(b"012345") '30:31:32:33:34:35' >>> unpack_mac(b"bad") Traceback (most recent call last): ... ValueError: given buffer is not exactly six bytes long @type sixbytes: bytes @rtype: str...
https://github.com/CygnusNetworks/pypureomapi/blob/ff4459678ec023fd56e64ce518a86860efec26bf/pypureomapi.py#L804-L823
CygnusNetworks/pypureomapi
pypureomapi.py
OutBuffer.add
def add(self, data): """ >>> ob = OutBuffer().add(OutBuffer.sizelimit * b"x") >>> ob.add(b"y") # doctest: +ELLIPSIS Traceback (most recent call last): ... OmapiSizeLimitError: ... @type data: bytes @returns: self @raises OmapiSizeLimitError: """ if len(self) + len(data) > self.sizelimit: raise...
python
def add(self, data): """ >>> ob = OutBuffer().add(OutBuffer.sizelimit * b"x") >>> ob.add(b"y") # doctest: +ELLIPSIS Traceback (most recent call last): ... OmapiSizeLimitError: ... @type data: bytes @returns: self @raises OmapiSizeLimitError: """ if len(self) + len(data) > self.sizelimit: raise...
>>> ob = OutBuffer().add(OutBuffer.sizelimit * b"x") >>> ob.add(b"y") # doctest: +ELLIPSIS Traceback (most recent call last): ... OmapiSizeLimitError: ... @type data: bytes @returns: self @raises OmapiSizeLimitError:
https://github.com/CygnusNetworks/pypureomapi/blob/ff4459678ec023fd56e64ce518a86860efec26bf/pypureomapi.py#L131-L146
CygnusNetworks/pypureomapi
pypureomapi.py
OutBuffer.add_net32string
def add_net32string(self, string): """ >>> r = b'\\x00\\x00\\x00\\x01x' >>> OutBuffer().add_net32string(b"x").getvalue() == r True @type string: bytes @param string: maximum length must fit in a 32bit integer @returns: self @raises OmapiSizeLimitError: """ if len(string) >= (1 << 32): raise Valu...
python
def add_net32string(self, string): """ >>> r = b'\\x00\\x00\\x00\\x01x' >>> OutBuffer().add_net32string(b"x").getvalue() == r True @type string: bytes @param string: maximum length must fit in a 32bit integer @returns: self @raises OmapiSizeLimitError: """ if len(string) >= (1 << 32): raise Valu...
>>> r = b'\\x00\\x00\\x00\\x01x' >>> OutBuffer().add_net32string(b"x").getvalue() == r True @type string: bytes @param string: maximum length must fit in a 32bit integer @returns: self @raises OmapiSizeLimitError:
https://github.com/CygnusNetworks/pypureomapi/blob/ff4459678ec023fd56e64ce518a86860efec26bf/pypureomapi.py#L170-L183
CygnusNetworks/pypureomapi
pypureomapi.py
OutBuffer.add_net16string
def add_net16string(self, string): """ >>> OutBuffer().add_net16string(b"x").getvalue() == b'\\x00\\x01x' True @type string: bytes @param string: maximum length must fit in a 16bit integer @returns: self @raises OmapiSizeLimitError: """ if len(string) >= (1 << 16): raise ValueError("string too lon...
python
def add_net16string(self, string): """ >>> OutBuffer().add_net16string(b"x").getvalue() == b'\\x00\\x01x' True @type string: bytes @param string: maximum length must fit in a 16bit integer @returns: self @raises OmapiSizeLimitError: """ if len(string) >= (1 << 16): raise ValueError("string too lon...
>>> OutBuffer().add_net16string(b"x").getvalue() == b'\\x00\\x01x' True @type string: bytes @param string: maximum length must fit in a 16bit integer @returns: self @raises OmapiSizeLimitError:
https://github.com/CygnusNetworks/pypureomapi/blob/ff4459678ec023fd56e64ce518a86860efec26bf/pypureomapi.py#L185-L197
CygnusNetworks/pypureomapi
pypureomapi.py
OutBuffer.add_bindict
def add_bindict(self, items): """ >>> r = b'\\x00\\x03foo\\x00\\x00\\x00\\x03bar\\x00\\x00' >>> OutBuffer().add_bindict({b"foo": b"bar"}).getvalue() == r True @type items: [(bytes, bytes)] or {bytes: bytes} @returns: self @raises OmapiSizeLimitError: """ if not isinstance(items, list): items = ite...
python
def add_bindict(self, items): """ >>> r = b'\\x00\\x03foo\\x00\\x00\\x00\\x03bar\\x00\\x00' >>> OutBuffer().add_bindict({b"foo": b"bar"}).getvalue() == r True @type items: [(bytes, bytes)] or {bytes: bytes} @returns: self @raises OmapiSizeLimitError: """ if not isinstance(items, list): items = ite...
>>> r = b'\\x00\\x03foo\\x00\\x00\\x00\\x03bar\\x00\\x00' >>> OutBuffer().add_bindict({b"foo": b"bar"}).getvalue() == r True @type items: [(bytes, bytes)] or {bytes: bytes} @returns: self @raises OmapiSizeLimitError:
https://github.com/CygnusNetworks/pypureomapi/blob/ff4459678ec023fd56e64ce518a86860efec26bf/pypureomapi.py#L199-L213
CygnusNetworks/pypureomapi
pypureomapi.py
OutBuffer.consume
def consume(self, length): """ >>> OutBuffer().add(b"spam").consume(2).getvalue() == b"am" True @type length: int @returns: self """ self.buff = io.BytesIO(self.getvalue()[length:]) return self
python
def consume(self, length): """ >>> OutBuffer().add(b"spam").consume(2).getvalue() == b"am" True @type length: int @returns: self """ self.buff = io.BytesIO(self.getvalue()[length:]) return self
>>> OutBuffer().add(b"spam").consume(2).getvalue() == b"am" True @type length: int @returns: self
https://github.com/CygnusNetworks/pypureomapi/blob/ff4459678ec023fd56e64ce518a86860efec26bf/pypureomapi.py#L224-L233
CygnusNetworks/pypureomapi
pypureomapi.py
OmapiStartupMessage.validate
def validate(self): """Checks whether this OmapiStartupMessage matches the implementation. @raises OmapiError: """ if self.implemented_protocol_version != self.protocol_version: raise OmapiError("protocol mismatch") if self.implemented_header_size != self.header_size: raise OmapiError("header size misma...
python
def validate(self): """Checks whether this OmapiStartupMessage matches the implementation. @raises OmapiError: """ if self.implemented_protocol_version != self.protocol_version: raise OmapiError("protocol mismatch") if self.implemented_header_size != self.header_size: raise OmapiError("header size misma...
Checks whether this OmapiStartupMessage matches the implementation. @raises OmapiError:
https://github.com/CygnusNetworks/pypureomapi/blob/ff4459678ec023fd56e64ce518a86860efec26bf/pypureomapi.py#L263-L270
CygnusNetworks/pypureomapi
pypureomapi.py
OmapiStartupMessage.serialize
def serialize(self, outbuffer): """Serialize this OmapiStartupMessage to the given outbuffer. @type outbuffer: OutBuffer """ outbuffer.add_net32int(self.protocol_version) outbuffer.add_net32int(self.header_size)
python
def serialize(self, outbuffer): """Serialize this OmapiStartupMessage to the given outbuffer. @type outbuffer: OutBuffer """ outbuffer.add_net32int(self.protocol_version) outbuffer.add_net32int(self.header_size)
Serialize this OmapiStartupMessage to the given outbuffer. @type outbuffer: OutBuffer
https://github.com/CygnusNetworks/pypureomapi/blob/ff4459678ec023fd56e64ce518a86860efec26bf/pypureomapi.py#L280-L285
CygnusNetworks/pypureomapi
pypureomapi.py
OmapiHMACMD5Authenticator.sign
def sign(self, message): """ >>> authlen = OmapiHMACMD5Authenticator.authlen >>> len(OmapiHMACMD5Authenticator(b"foo", 16*b"x").sign(b"baz")) == authlen True @type message: bytes @rtype: bytes @returns: a signature of length self.authlen """ return hmac.HMAC(self.key, message, digestmod=hashlib.md5)....
python
def sign(self, message): """ >>> authlen = OmapiHMACMD5Authenticator.authlen >>> len(OmapiHMACMD5Authenticator(b"foo", 16*b"x").sign(b"baz")) == authlen True @type message: bytes @rtype: bytes @returns: a signature of length self.authlen """ return hmac.HMAC(self.key, message, digestmod=hashlib.md5)....
>>> authlen = OmapiHMACMD5Authenticator.authlen >>> len(OmapiHMACMD5Authenticator(b"foo", 16*b"x").sign(b"baz")) == authlen True @type message: bytes @rtype: bytes @returns: a signature of length self.authlen
https://github.com/CygnusNetworks/pypureomapi/blob/ff4459678ec023fd56e64ce518a86860efec26bf/pypureomapi.py#L361-L371
CygnusNetworks/pypureomapi
pypureomapi.py
OmapiMessage.as_string
def as_string(self, forsigning=False): """ >>> len(OmapiMessage().as_string(True)) >= 24 True @type forsigning: bool @rtype: bytes @raises OmapiSizeLimitError: """ ret = OutBuffer() self.serialize(ret, forsigning) return ret.getvalue()
python
def as_string(self, forsigning=False): """ >>> len(OmapiMessage().as_string(True)) >= 24 True @type forsigning: bool @rtype: bytes @raises OmapiSizeLimitError: """ ret = OutBuffer() self.serialize(ret, forsigning) return ret.getvalue()
>>> len(OmapiMessage().as_string(True)) >= 24 True @type forsigning: bool @rtype: bytes @raises OmapiSizeLimitError:
https://github.com/CygnusNetworks/pypureomapi/blob/ff4459678ec023fd56e64ce518a86860efec26bf/pypureomapi.py#L449-L460
CygnusNetworks/pypureomapi
pypureomapi.py
OmapiMessage.sign
def sign(self, authenticator): """Sign this OMAPI message. @type authenticator: OmapiAuthenticatorBase """ self.authid = authenticator.authid self.signature = b"\0" * authenticator.authlen # provide authlen self.signature = authenticator.sign(self.as_string(forsigning=True)) assert len(self.signature) ==...
python
def sign(self, authenticator): """Sign this OMAPI message. @type authenticator: OmapiAuthenticatorBase """ self.authid = authenticator.authid self.signature = b"\0" * authenticator.authlen # provide authlen self.signature = authenticator.sign(self.as_string(forsigning=True)) assert len(self.signature) ==...
Sign this OMAPI message. @type authenticator: OmapiAuthenticatorBase
https://github.com/CygnusNetworks/pypureomapi/blob/ff4459678ec023fd56e64ce518a86860efec26bf/pypureomapi.py#L462-L469
CygnusNetworks/pypureomapi
pypureomapi.py
OmapiMessage.verify
def verify(self, authenticators): """Verify this OMAPI message. >>> a1 = OmapiHMACMD5Authenticator(b"egg", b"spam") >>> a2 = OmapiHMACMD5Authenticator(b"egg", b"tomatoes") >>> a1.authid = a2.authid = 5 >>> m = OmapiMessage.open(b"host") >>> m.verify({a1.authid: a1}) False >>> m.sign(a1) >>> m.verify(...
python
def verify(self, authenticators): """Verify this OMAPI message. >>> a1 = OmapiHMACMD5Authenticator(b"egg", b"spam") >>> a2 = OmapiHMACMD5Authenticator(b"egg", b"tomatoes") >>> a1.authid = a2.authid = 5 >>> m = OmapiMessage.open(b"host") >>> m.verify({a1.authid: a1}) False >>> m.sign(a1) >>> m.verify(...
Verify this OMAPI message. >>> a1 = OmapiHMACMD5Authenticator(b"egg", b"spam") >>> a2 = OmapiHMACMD5Authenticator(b"egg", b"tomatoes") >>> a1.authid = a2.authid = 5 >>> m = OmapiMessage.open(b"host") >>> m.verify({a1.authid: a1}) False >>> m.sign(a1) >>> m.verify({a1.authid: a1}) True >>> m.sign(a2...
https://github.com/CygnusNetworks/pypureomapi/blob/ff4459678ec023fd56e64ce518a86860efec26bf/pypureomapi.py#L471-L493
CygnusNetworks/pypureomapi
pypureomapi.py
OmapiMessage.open
def open(cls, typename): """Create an OMAPI open message with given typename. @type typename: bytes @rtype: OmapiMessage """ return cls(opcode=OMAPI_OP_OPEN, message=[(b"type", typename)], tid=-1)
python
def open(cls, typename): """Create an OMAPI open message with given typename. @type typename: bytes @rtype: OmapiMessage """ return cls(opcode=OMAPI_OP_OPEN, message=[(b"type", typename)], tid=-1)
Create an OMAPI open message with given typename. @type typename: bytes @rtype: OmapiMessage
https://github.com/CygnusNetworks/pypureomapi/blob/ff4459678ec023fd56e64ce518a86860efec26bf/pypureomapi.py#L496-L501
CygnusNetworks/pypureomapi
pypureomapi.py
InBuffer.parse_net16string
def parse_net16string(self): """ >>> next(InBuffer(b"\\0\\x03eggs").parse_net16string()) == b'egg' True """ return parse_map(operator.itemgetter(1), parse_chain(self.parse_net16int, self.parse_fixedbuffer))
python
def parse_net16string(self): """ >>> next(InBuffer(b"\\0\\x03eggs").parse_net16string()) == b'egg' True """ return parse_map(operator.itemgetter(1), parse_chain(self.parse_net16int, self.parse_fixedbuffer))
>>> next(InBuffer(b"\\0\\x03eggs").parse_net16string()) == b'egg' True
https://github.com/CygnusNetworks/pypureomapi/blob/ff4459678ec023fd56e64ce518a86860efec26bf/pypureomapi.py#L645-L650
CygnusNetworks/pypureomapi
pypureomapi.py
InBuffer.parse_net32string
def parse_net32string(self): """ >>> next(InBuffer(b"\\0\\0\\0\\x03eggs").parse_net32string()) == b'egg' True """ return parse_map(operator.itemgetter(1), parse_chain(self.parse_net32int, self.parse_fixedbuffer))
python
def parse_net32string(self): """ >>> next(InBuffer(b"\\0\\0\\0\\x03eggs").parse_net32string()) == b'egg' True """ return parse_map(operator.itemgetter(1), parse_chain(self.parse_net32int, self.parse_fixedbuffer))
>>> next(InBuffer(b"\\0\\0\\0\\x03eggs").parse_net32string()) == b'egg' True
https://github.com/CygnusNetworks/pypureomapi/blob/ff4459678ec023fd56e64ce518a86860efec26bf/pypureomapi.py#L652-L657
CygnusNetworks/pypureomapi
pypureomapi.py
InBuffer.parse_bindict
def parse_bindict(self): """ >>> d = b"\\0\\x01a\\0\\0\\0\\x01b\\0\\0spam" >>> next(InBuffer(d).parse_bindict()) == [(b'a', b'b')] True """ entries = [] try: while True: for key in self.parse_net16string(): if key is None: yield None elif not key: raise StopIteration() el...
python
def parse_bindict(self): """ >>> d = b"\\0\\x01a\\0\\0\\0\\x01b\\0\\0spam" >>> next(InBuffer(d).parse_bindict()) == [(b'a', b'b')] True """ entries = [] try: while True: for key in self.parse_net16string(): if key is None: yield None elif not key: raise StopIteration() el...
>>> d = b"\\0\\x01a\\0\\0\\0\\x01b\\0\\0spam" >>> next(InBuffer(d).parse_bindict()) == [(b'a', b'b')] True
https://github.com/CygnusNetworks/pypureomapi/blob/ff4459678ec023fd56e64ce518a86860efec26bf/pypureomapi.py#L659-L684
CygnusNetworks/pypureomapi
pypureomapi.py
InBuffer.parse_startup_message
def parse_startup_message(self): """results in an OmapiStartupMessage >>> d = b"\\0\\0\\0\\x64\\0\\0\\0\\x18" >>> next(InBuffer(d).parse_startup_message()).validate() """ return parse_map(lambda args: OmapiStartupMessage(*args), parse_chain(self.parse_net32int, lambda _: self.parse_net32int()))
python
def parse_startup_message(self): """results in an OmapiStartupMessage >>> d = b"\\0\\0\\0\\x64\\0\\0\\0\\x18" >>> next(InBuffer(d).parse_startup_message()).validate() """ return parse_map(lambda args: OmapiStartupMessage(*args), parse_chain(self.parse_net32int, lambda _: self.parse_net32int()))
results in an OmapiStartupMessage >>> d = b"\\0\\0\\0\\x64\\0\\0\\0\\x18" >>> next(InBuffer(d).parse_startup_message()).validate()
https://github.com/CygnusNetworks/pypureomapi/blob/ff4459678ec023fd56e64ce518a86860efec26bf/pypureomapi.py#L686-L692
CygnusNetworks/pypureomapi
pypureomapi.py
InBuffer.parse_message
def parse_message(self): """results in an OmapiMessage""" parser = parse_chain(self.parse_net32int, # authid lambda *_: self.parse_net32int(), # authlen lambda *_: self.parse_net32int(), # opcode lambda *_: self.parse_net32int(), # handle lambda *_: self.parse_net32int(), # tid ...
python
def parse_message(self): """results in an OmapiMessage""" parser = parse_chain(self.parse_net32int, # authid lambda *_: self.parse_net32int(), # authlen lambda *_: self.parse_net32int(), # opcode lambda *_: self.parse_net32int(), # handle lambda *_: self.parse_net32int(), # tid ...
results in an OmapiMessage
https://github.com/CygnusNetworks/pypureomapi/blob/ff4459678ec023fd56e64ce518a86860efec26bf/pypureomapi.py#L694-L706
CygnusNetworks/pypureomapi
pypureomapi.py
TCPClientTransport.fill_inbuffer
def fill_inbuffer(self): """Read bytes from the connection and hand them to the protocol. @raises OmapiError: @raises socket.error: """ if not self.connection: raise OmapiError("not connected") try: data = self.connection.recv(2048) except socket.error: self.close() raise if not data: sel...
python
def fill_inbuffer(self): """Read bytes from the connection and hand them to the protocol. @raises OmapiError: @raises socket.error: """ if not self.connection: raise OmapiError("not connected") try: data = self.connection.recv(2048) except socket.error: self.close() raise if not data: sel...
Read bytes from the connection and hand them to the protocol. @raises OmapiError: @raises socket.error:
https://github.com/CygnusNetworks/pypureomapi/blob/ff4459678ec023fd56e64ce518a86860efec26bf/pypureomapi.py#L849-L868
CygnusNetworks/pypureomapi
pypureomapi.py
TCPClientTransport.write
def write(self, data): """Send all of data to the connection. @type data: bytes @raises socket.error: """ try: self.connection.sendall(data) except socket.error: self.close() raise
python
def write(self, data): """Send all of data to the connection. @type data: bytes @raises socket.error: """ try: self.connection.sendall(data) except socket.error: self.close() raise
Send all of data to the connection. @type data: bytes @raises socket.error:
https://github.com/CygnusNetworks/pypureomapi/blob/ff4459678ec023fd56e64ce518a86860efec26bf/pypureomapi.py#L870-L880
CygnusNetworks/pypureomapi
pypureomapi.py
OmapiProtocol.send_message
def send_message(self, message, sign=True): """Send the given message to the connection. @type message: OmapiMessage @param sign: whether the message needs to be signed @raises OmapiError: @raises socket.error: """ if sign: message.sign(self.authenticators[self.defauth]) logger.debug("sending %s", L...
python
def send_message(self, message, sign=True): """Send the given message to the connection. @type message: OmapiMessage @param sign: whether the message needs to be signed @raises OmapiError: @raises socket.error: """ if sign: message.sign(self.authenticators[self.defauth]) logger.debug("sending %s", L...
Send the given message to the connection. @type message: OmapiMessage @param sign: whether the message needs to be signed @raises OmapiError: @raises socket.error:
https://github.com/CygnusNetworks/pypureomapi/blob/ff4459678ec023fd56e64ce518a86860efec26bf/pypureomapi.py#L937-L948
CygnusNetworks/pypureomapi
pypureomapi.py
Omapi.receive_message
def receive_message(self): """Read the next message from the connection. @rtype: OmapiMessage @raises OmapiError: @raises socket.error: """ while not self.recv_message_queue: self.transport.fill_inbuffer() message = self.recv_message_queue.pop(0) assert message is not None if not message.verify(sel...
python
def receive_message(self): """Read the next message from the connection. @rtype: OmapiMessage @raises OmapiError: @raises socket.error: """ while not self.recv_message_queue: self.transport.fill_inbuffer() message = self.recv_message_queue.pop(0) assert message is not None if not message.verify(sel...
Read the next message from the connection. @rtype: OmapiMessage @raises OmapiError: @raises socket.error:
https://github.com/CygnusNetworks/pypureomapi/blob/ff4459678ec023fd56e64ce518a86860efec26bf/pypureomapi.py#L1005-L1018
CygnusNetworks/pypureomapi
pypureomapi.py
Omapi.receive_response
def receive_response(self, message, insecure=False): """Read the response for the given message. @type message: OmapiMessage @type insecure: bool @param insecure: avoid an OmapiError about a wrong authenticator @rtype: OmapiMessage @raises OmapiError: @raises socket.error: """ response = self.receive_...
python
def receive_response(self, message, insecure=False): """Read the response for the given message. @type message: OmapiMessage @type insecure: bool @param insecure: avoid an OmapiError about a wrong authenticator @rtype: OmapiMessage @raises OmapiError: @raises socket.error: """ response = self.receive_...
Read the response for the given message. @type message: OmapiMessage @type insecure: bool @param insecure: avoid an OmapiError about a wrong authenticator @rtype: OmapiMessage @raises OmapiError: @raises socket.error:
https://github.com/CygnusNetworks/pypureomapi/blob/ff4459678ec023fd56e64ce518a86860efec26bf/pypureomapi.py#L1020-L1035
CygnusNetworks/pypureomapi
pypureomapi.py
Omapi.send_message
def send_message(self, message, sign=True): """Sends the given message to the connection. @type message: OmapiMessage @type sign: bool @param sign: whether the message needs to be signed @raises OmapiError: @raises socket.error: """ self.check_connected() self.protocol.send_message(message, sign)
python
def send_message(self, message, sign=True): """Sends the given message to the connection. @type message: OmapiMessage @type sign: bool @param sign: whether the message needs to be signed @raises OmapiError: @raises socket.error: """ self.check_connected() self.protocol.send_message(message, sign)
Sends the given message to the connection. @type message: OmapiMessage @type sign: bool @param sign: whether the message needs to be signed @raises OmapiError: @raises socket.error:
https://github.com/CygnusNetworks/pypureomapi/blob/ff4459678ec023fd56e64ce518a86860efec26bf/pypureomapi.py#L1037-L1046
CygnusNetworks/pypureomapi
pypureomapi.py
Omapi.lookup_ip_host
def lookup_ip_host(self, mac): """Lookup a host object with with given mac address. @type mac: str @raises ValueError: @raises OmapiError: @raises OmapiErrorNotFound: if no lease object with the given mac could be found @raises OmapiErrorAttributeNotFound: if lease could be found, but objects lacks a ip ...
python
def lookup_ip_host(self, mac): """Lookup a host object with with given mac address. @type mac: str @raises ValueError: @raises OmapiError: @raises OmapiErrorNotFound: if no lease object with the given mac could be found @raises OmapiErrorAttributeNotFound: if lease could be found, but objects lacks a ip ...
Lookup a host object with with given mac address. @type mac: str @raises ValueError: @raises OmapiError: @raises OmapiErrorNotFound: if no lease object with the given mac could be found @raises OmapiErrorAttributeNotFound: if lease could be found, but objects lacks a ip @raises socket.error:
https://github.com/CygnusNetworks/pypureomapi/blob/ff4459678ec023fd56e64ce518a86860efec26bf/pypureomapi.py#L1077-L1091
CygnusNetworks/pypureomapi
pypureomapi.py
Omapi.lookup_ip
def lookup_ip(self, mac): """Look for a lease object with given mac address and return the assigned ip address. @type mac: str @rtype: str or None @raises ValueError: @raises OmapiError: @raises OmapiErrorNotFound: if no lease object with the given mac could be found @raises OmapiErrorAttributeNotFound...
python
def lookup_ip(self, mac): """Look for a lease object with given mac address and return the assigned ip address. @type mac: str @rtype: str or None @raises ValueError: @raises OmapiError: @raises OmapiErrorNotFound: if no lease object with the given mac could be found @raises OmapiErrorAttributeNotFound...
Look for a lease object with given mac address and return the assigned ip address. @type mac: str @rtype: str or None @raises ValueError: @raises OmapiError: @raises OmapiErrorNotFound: if no lease object with the given mac could be found @raises OmapiErrorAttributeNotFound: if lease could be found, but ...
https://github.com/CygnusNetworks/pypureomapi/blob/ff4459678ec023fd56e64ce518a86860efec26bf/pypureomapi.py#L1093-L1109
CygnusNetworks/pypureomapi
pypureomapi.py
Omapi.lookup_mac
def lookup_mac(self, ip): """Look up a lease object with given ip address and return the associated mac address. @type ip: str @rtype: str or None @raises ValueError: @raises OmapiError: @raises OmapiErrorNotFound: if no lease object with the given ip could be found @raises OmapiErrorAttributeNotFound:...
python
def lookup_mac(self, ip): """Look up a lease object with given ip address and return the associated mac address. @type ip: str @rtype: str or None @raises ValueError: @raises OmapiError: @raises OmapiErrorNotFound: if no lease object with the given ip could be found @raises OmapiErrorAttributeNotFound:...
Look up a lease object with given ip address and return the associated mac address. @type ip: str @rtype: str or None @raises ValueError: @raises OmapiError: @raises OmapiErrorNotFound: if no lease object with the given ip could be found @raises OmapiErrorAttributeNotFound: if lease could be found, but o...
https://github.com/CygnusNetworks/pypureomapi/blob/ff4459678ec023fd56e64ce518a86860efec26bf/pypureomapi.py#L1111-L1127
CygnusNetworks/pypureomapi
pypureomapi.py
Omapi.lookup_host
def lookup_host(self, name): """Look for a host object with given name and return the name, mac, and ip address @type name: str @rtype: dict or None @raises ValueError: @raises OmapiError: @raises OmapiErrorNotFound: if no host object with the given name could be found @raises OmapiErrorAttributeNotFou...
python
def lookup_host(self, name): """Look for a host object with given name and return the name, mac, and ip address @type name: str @rtype: dict or None @raises ValueError: @raises OmapiError: @raises OmapiErrorNotFound: if no host object with the given name could be found @raises OmapiErrorAttributeNotFou...
Look for a host object with given name and return the name, mac, and ip address @type name: str @rtype: dict or None @raises ValueError: @raises OmapiError: @raises OmapiErrorNotFound: if no host object with the given name could be found @raises OmapiErrorAttributeNotFound: if lease could be found, but o...
https://github.com/CygnusNetworks/pypureomapi/blob/ff4459678ec023fd56e64ce518a86860efec26bf/pypureomapi.py#L1129-L1145
CygnusNetworks/pypureomapi
pypureomapi.py
Omapi.lookup_host_host
def lookup_host_host(self, mac): """Look for a host object with given mac address and return the name, mac, and ip address @type mac: str @rtype: dict or None @raises ValueError: @raises OmapiError: @raises OmapiErrorNotFound: if no host object with the given mac address could be found @raises OmapiErr...
python
def lookup_host_host(self, mac): """Look for a host object with given mac address and return the name, mac, and ip address @type mac: str @rtype: dict or None @raises ValueError: @raises OmapiError: @raises OmapiErrorNotFound: if no host object with the given mac address could be found @raises OmapiErr...
Look for a host object with given mac address and return the name, mac, and ip address @type mac: str @rtype: dict or None @raises ValueError: @raises OmapiError: @raises OmapiErrorNotFound: if no host object with the given mac address could be found @raises OmapiErrorAttributeNotFound: if lease could be...
https://github.com/CygnusNetworks/pypureomapi/blob/ff4459678ec023fd56e64ce518a86860efec26bf/pypureomapi.py#L1147-L1163
CygnusNetworks/pypureomapi
pypureomapi.py
Omapi.lookup_hostname
def lookup_hostname(self, ip): """Look up a lease object with given ip address and return the associated client hostname. @type ip: str @rtype: str or None @raises ValueError: @raises OmapiError: @raises OmapiErrorNotFound: if no lease object with the given ip address could be found @raises OmapiErrorAtt...
python
def lookup_hostname(self, ip): """Look up a lease object with given ip address and return the associated client hostname. @type ip: str @rtype: str or None @raises ValueError: @raises OmapiError: @raises OmapiErrorNotFound: if no lease object with the given ip address could be found @raises OmapiErrorAtt...
Look up a lease object with given ip address and return the associated client hostname. @type ip: str @rtype: str or None @raises ValueError: @raises OmapiError: @raises OmapiErrorNotFound: if no lease object with the given ip address could be found @raises OmapiErrorAttributeNotFound: if lease could be fo...
https://github.com/CygnusNetworks/pypureomapi/blob/ff4459678ec023fd56e64ce518a86860efec26bf/pypureomapi.py#L1165-L1179
CygnusNetworks/pypureomapi
pypureomapi.py
Omapi.__lookup
def __lookup(self, ltype, **kwargs): """Generic Lookup function @type ltype: str @type rvalues: list @type ip: str @type mac: str @type name: str @rtype: dict or str (if len(rvalues) == 1) or None @raises ValueError: @raises OmapiError: @raises OmapiErrorNotFound: if no host object with the given n...
python
def __lookup(self, ltype, **kwargs): """Generic Lookup function @type ltype: str @type rvalues: list @type ip: str @type mac: str @type name: str @rtype: dict or str (if len(rvalues) == 1) or None @raises ValueError: @raises OmapiError: @raises OmapiErrorNotFound: if no host object with the given n...
Generic Lookup function @type ltype: str @type rvalues: list @type ip: str @type mac: str @type name: str @rtype: dict or str (if len(rvalues) == 1) or None @raises ValueError: @raises OmapiError: @raises OmapiErrorNotFound: if no host object with the given name could be found or the object lacks...
https://github.com/CygnusNetworks/pypureomapi/blob/ff4459678ec023fd56e64ce518a86860efec26bf/pypureomapi.py#L1187-L1238