sentence1
stringlengths
52
3.87M
sentence2
stringlengths
1
47.2k
label
stringclasses
1 value
def __handle_low_seq_resend(self, msg, req): """special error case - low sequence number (update sequence number & resend if applicable). Returns True if a resend was scheduled, False otherwise. MUST be called within self.__requests lock.""" if msg[M_TYPE] == E_FAILED and msg[M_PAYLOAD][P_COD...
special error case - low sequence number (update sequence number & resend if applicable). Returns True if a resend was scheduled, False otherwise. MUST be called within self.__requests lock.
entailment
def __decode_data_time(self, payload): """Extract time and decode payload (based on mime type) from payload. Applies to E_FEEDDATA and E_RECENTDATA. Returns tuple of data, mime, time.""" data, mime = self.__bytes_to_share_data(payload) try: time = datetime.strptime(payload.ge...
Extract time and decode payload (based on mime type) from payload. Applies to E_FEEDDATA and E_RECENTDATA. Returns tuple of data, mime, time.
entailment
def __perform_unsolicited_callbacks(self, msg): """Callbacks for which a client reference is either optional or does not apply at all""" type_ = msg[M_TYPE] payload = msg[M_PAYLOAD] # callbacks for responses which might be unsolicited (e.g. created or deleted) if type_ in _RSP_P...
Callbacks for which a client reference is either optional or does not apply at all
entailment
def roles(self, roles_list): ''' Set the roles for the current launch. Full list of roles can be found here: http://www.imsglobal.org/LTI/v1p1/ltiIMGv1p1.html#_Toc319560479 LIS roles include: * Student * Faculty * Member * Learner * Instr...
Set the roles for the current launch. Full list of roles can be found here: http://www.imsglobal.org/LTI/v1p1/ltiIMGv1p1.html#_Toc319560479 LIS roles include: * Student * Faculty * Member * Learner * Instructor * Mentor * Staff * ...
entailment
def process_params(self, params): ''' Populates the launch data from a dictionary. Only cares about keys in the LAUNCH_DATA_PARAMETERS list, or that start with 'custom_' or 'ext_'. ''' for key, val in params.items(): if key in LAUNCH_DATA_PARAMETERS and val !=...
Populates the launch data from a dictionary. Only cares about keys in the LAUNCH_DATA_PARAMETERS list, or that start with 'custom_' or 'ext_'.
entailment
def to_params(self): ''' Createa a new dictionary with all launch data. Custom / Extension keys will be included. Roles are set as a ',' separated string. ''' params = {} custom_params = {} for key in self.custom_params: custom_params[key] = self.custo...
Createa a new dictionary with all launch data. Custom / Extension keys will be included. Roles are set as a ',' separated string.
entailment
def write_longstr(self, s): """Write a string up to 2**32 bytes long after encoding. If passed a unicode string, encode as UTF-8. """ self._flushbits() if isinstance(s, text_t): s = s.encode('utf-8') self.write_long(len(s)) self.out.write(s)
Write a string up to 2**32 bytes long after encoding. If passed a unicode string, encode as UTF-8.
entailment
def run(self, background=False): """Runs `on_startup`, `main` and `on_shutdown`, blocking until finished, unless background is set.""" if self.__bgthread: raise Exception('run has already been called (since last stop)') self.__shutdown.clear() if background: self....
Runs `on_startup`, `main` and `on_shutdown`, blocking until finished, unless background is set.
entailment
def stop(self, timeout=None): """Requests device to stop running, waiting at most the given timout in seconds (fractional). Has no effect if `run()` was not called with background=True set. Returns True if successfully stopped (or already not running). """ stopped = True self.__s...
Requests device to stop running, waiting at most the given timout in seconds (fractional). Has no effect if `run()` was not called with background=True set. Returns True if successfully stopped (or already not running).
entailment
def add_message_to_queue(self, payload, **attributes): """ Given a payload (a dict) and any optional message attributes (also a dict), add it to the queue. """ return self.queue.send_message(MessageBody=json.dumps(payload), MessageAttributes={k: {"StringValue": v}...
Given a payload (a dict) and any optional message attributes (also a dict), add it to the queue.
entailment
def receive_messages_from_queue(self, wait_time=15, num_messages=1): """ Returns the first (according to FIFO) element in the queue; if none, then returns None.""" return self.queue.receive_messages(MaxNumberOfMessages=num_messages, WaitTimeSeconds=wait_time)
Returns the first (according to FIFO) element in the queue; if none, then returns None.
entailment
def save_json(self, jsonfn=None, pretty=True): """Write a .json file with the units tree jsonfn='path/file.name' default os.getcwd() + 'units.json' pretty=True use JSON dumps pretty print for human readability """ if jsonfn is None: jsonfn = os.path.join(os.getcwd(), ...
Write a .json file with the units tree jsonfn='path/file.name' default os.getcwd() + 'units.json' pretty=True use JSON dumps pretty print for human readability
entailment
def accumulate_metric(cls, name, value): """ Accumulate a custom metric (name and value) in the metrics cache. """ metrics_cache = cls._get_metrics_cache() metrics_cache.setdefault(name, 0) metrics_cache.set(name, value)
Accumulate a custom metric (name and value) in the metrics cache.
entailment
def _batch_report(cls, request): """ Report the collected custom metrics to New Relic. """ if not newrelic: return metrics_cache = cls._get_metrics_cache() try: newrelic.agent.add_custom_parameter('user_id', request.user.id) except Attribut...
Report the collected custom metrics to New Relic.
entailment
def process_request(self, request): """ Store memory data to log later. """ if self._is_enabled(): self._cache.set(self.guid_key, six.text_type(uuid4())) log_prefix = self._log_prefix(u"Before", request) self._cache.set(self.memory_data_key, self._memo...
Store memory data to log later.
entailment
def process_response(self, request, response): """ Logs memory data after processing response. """ if self._is_enabled(): log_prefix = self._log_prefix(u"After", request) new_memory_data = self._memory_data(log_prefix) log_prefix = self._log_prefix(u"...
Logs memory data after processing response.
entailment
def _log_prefix(self, prefix, request): """ Returns a formatted prefix for logging for the given request. """ # After a celery task runs, the request cache is cleared. So if celery # tasks are running synchronously (CELERY_ALWAYS _EAGER), "guid_key" # will no longer be in...
Returns a formatted prefix for logging for the given request.
entailment
def _memory_data(self, log_prefix): """ Returns a dict with information for current memory utilization. Uses log_prefix in log statements. """ machine_data = psutil.virtual_memory() process = psutil.Process() process_data = { 'memory_info': process.ge...
Returns a dict with information for current memory utilization. Uses log_prefix in log statements.
entailment
def _log_diff_memory_data(self, prefix, new_memory_data, old_memory_data): """ Computes and logs the difference in memory utilization between the given old and new memory data. """ def _vmem_used(memory_data): return memory_data['machine_data'].used def _proc...
Computes and logs the difference in memory utilization between the given old and new memory data.
entailment
def data(self, namespace): """ Gets the thread.local data (dict) for a given namespace. Args: namespace (string): The namespace, or key, of the data dict. Returns: (dict) """ assert namespace if namespace in self._data: retu...
Gets the thread.local data (dict) for a given namespace. Args: namespace (string): The namespace, or key, of the data dict. Returns: (dict)
entailment
def get_cached_response(self, key): """ Retrieves a CachedResponse for the provided key. Args: key (string) Returns: A CachedResponse with is_found status and value. """ cached_value = self.data.get(key, _CACHE_MISS) is_found = cached_va...
Retrieves a CachedResponse for the provided key. Args: key (string) Returns: A CachedResponse with is_found status and value.
entailment
def get_cached_response(cls, key): """ Retrieves a CachedResponse for the provided key. Args: key (string) Returns: A CachedResponse with is_found status and value. """ request_cached_response = DEFAULT_REQUEST_CACHE.get_cached_response(key) ...
Retrieves a CachedResponse for the provided key. Args: key (string) Returns: A CachedResponse with is_found status and value.
entailment
def set_all_tiers(key, value, django_cache_timeout=DEFAULT_TIMEOUT): """ Caches the value for the provided key in both the request cache and the django cache. Args: key (string) value (object) django_cache_timeout (int): (Optional) Timeout used to det...
Caches the value for the provided key in both the request cache and the django cache. Args: key (string) value (object) django_cache_timeout (int): (Optional) Timeout used to determine if and for how long to cache in the django cache. A timeout of ...
entailment
def _get_cached_response_from_django_cache(key): """ Retrieves a CachedResponse for the given key from the django cache. If the request was set to force cache misses, then this will always return a cache miss response. Args: key (string) Returns: ...
Retrieves a CachedResponse for the given key from the django cache. If the request was set to force cache misses, then this will always return a cache miss response. Args: key (string) Returns: A CachedResponse with is_found status and value.
entailment
def _set_request_cache_if_django_cache_hit(key, django_cached_response): """ Sets the value in the request cache if the django cached response was a hit. Args: key (string) django_cached_response (CachedResponse) """ if django_cached_response.is_found: ...
Sets the value in the request cache if the django cached response was a hit. Args: key (string) django_cached_response (CachedResponse)
entailment
def _get_and_set_force_cache_miss(request): """ Gets value for request query parameter FORCE_CACHE_MISS and sets it in the default request cache. This functionality is only available for staff. Example: http://clobert.com/api/v1/resource?force_cache_miss=true ...
Gets value for request query parameter FORCE_CACHE_MISS and sets it in the default request cache. This functionality is only available for staff. Example: http://clobert.com/api/v1/resource?force_cache_miss=true
entailment
def _should_force_django_cache_miss(cls): """ Returns True if the tiered cache should force a cache miss for the django cache, and False otherwise. """ cached_response = DEFAULT_REQUEST_CACHE.get_cached_response(SHOULD_FORCE_CACHE_MISS_KEY) return False if not cached_res...
Returns True if the tiered cache should force a cache miss for the django cache, and False otherwise.
entailment
def check_convert_string(obj, name=None, no_leading_trailing_whitespace=True, no_whitespace=False, no_newline=True, whole_word=False, min_len=1, m...
Ensures the provided object can be interpreted as a unicode string, optionally with additional restrictions imposed. By default this means a non-zero length string which does not begin or end in whitespace.
entailment
def guid_check_convert(guid, allow_none=False): """Take a GUID in the form of hex string "32" or "8-4-4-4-12". Returns hex string "32" or raises ValueError: badly formed hexadecimal UUID string """ if isinstance(guid, string_types): return ensure_unicode(UUID(guid).hex) ...
Take a GUID in the form of hex string "32" or "8-4-4-4-12". Returns hex string "32" or raises ValueError: badly formed hexadecimal UUID string
entailment
def tags_check_convert(cls, tags): """Accept one tag as string or multiple tags in list of strings. Returns list (with tags in unicode form) or raises ValueError """ # single string check comes first since string is also a Sequence if isinstance(tags, string_types): r...
Accept one tag as string or multiple tags in list of strings. Returns list (with tags in unicode form) or raises ValueError
entailment
def __valid_url(cls, url): """Expects input to already be a valid string""" bits = urlparse(url) return ((bits.scheme == "http" or bits.scheme == "https") and _PATTERN_URL_PART.match(bits.netloc) and _PATTERN_URL_PART.match(bits.path))
Expects input to already be a valid string
entailment
def location_check(lat, lon): """For use by Core client wrappers""" if not (isinstance(lat, number_types) and -90 <= lat <= 90): raise ValueError("Latitude: '{latitude}' invalid".format(latitude=lat)) if not (isinstance(lon, number_types) and -180 <= lon <= 180): raise V...
For use by Core client wrappers
entailment
def search_location_check(cls, location): """Core.Client.request_search location parameter should be a dictionary that contains lat, lon and radius floats """ if not (isinstance(location, Mapping) and set(location.keys()) == _LOCATION_SEARCH_ARGS): raise ValueError('Search location s...
Core.Client.request_search location parameter should be a dictionary that contains lat, lon and radius floats
entailment
def __search_text_check_convert(cls, text): """Converts and keeps only words in text deemed to be valid""" text = cls.check_convert_string(text, name='text', no_leading_trailing_whitespace=False) if len(text) > VALIDATION_META_SEARCH_TEXT: raise ValueError("Search text can contain at...
Converts and keeps only words in text deemed to be valid
entailment
def callable_check(func, arg_count=1, arg_value=None, allow_none=False): """Check whether func is callable, with the given number of positional arguments. Returns True if check succeeded, False otherwise.""" if func is None: if not allow_none: raise ValueError('cal...
Check whether func is callable, with the given number of positional arguments. Returns True if check succeeded, False otherwise.
entailment
def list_feeds(self, limit=500, offset=0): """List `all` the feeds on this Thing. Returns QAPI list function payload Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkExcep...
List `all` the feeds on this Thing. Returns QAPI list function payload Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLink...
entailment
def list_controls(self, limit=500, offset=0): """List `all` the controls on this Thing. Returns QAPI list function payload Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [Lin...
List `all` the controls on this Thing. Returns QAPI list function payload Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpL...
entailment
def set_public(self, public=True): """Sets your Thing to be public to all. If `public=True`. This means the tags, label and description of your Thing are now searchable by anybody, along with its location and the units of any values on any Points. If `public=False` the metadata of your ...
Sets your Thing to be public to all. If `public=True`. This means the tags, label and description of your Thing are now searchable by anybody, along with its location and the units of any values on any Points. If `public=False` the metadata of your Thing is no longer searchable. Raises...
entailment
def rename(self, new_lid): """Rename the Thing. `ADVANCED USERS ONLY` This can be confusing. You are changing the local id of a Thing to `new_lid`. If you create another Thing using the "old_lid", the system will oblige, but it will be a completely _new_ Thing. Raises [IOTException]...
Rename the Thing. `ADVANCED USERS ONLY` This can be confusing. You are changing the local id of a Thing to `new_lid`. If you create another Thing using the "old_lid", the system will oblige, but it will be a completely _new_ Thing. Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Ex...
entailment
def reassign(self, new_epid): """Reassign the Thing from one agent to another. `ADVANCED USERS ONLY` This will lead to any local instances of a Thing being rendered useless. They won't be able to receive control requests, feed data or to share any feeds as they won't be in this agent. ...
Reassign the Thing from one agent to another. `ADVANCED USERS ONLY` This will lead to any local instances of a Thing being rendered useless. They won't be able to receive control requests, feed data or to share any feeds as they won't be in this agent. Raises [IOTException](./Exceptions.m.htm...
entailment
def create_tag(self, tags): """Create tags for a Thing in the language you specify. Tags can only contain alphanumeric (unicode) characters and the underscore. Tags will be stored lower-cased. Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing t...
Create tags for a Thing in the language you specify. Tags can only contain alphanumeric (unicode) characters and the underscore. Tags will be stored lower-cased. Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects ...
entailment
def delete_tag(self, tags): """Delete tags for a Thing in the language you specify. Case will be ignored and any tags matching lower-cased will be deleted. Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detect...
Delete tags for a Thing in the language you specify. Case will be ignored and any tags matching lower-cased will be deleted. Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkExcept...
entailment
def list_tag(self, limit=500, offset=0): """List `all` the tags for this Thing Returns lists of tags, as below #!python [ "mytag1", "mytag2" "ein_name", "nochein_name" ] - OR... Raises...
List `all` the tags for this Thing Returns lists of tags, as below #!python [ "mytag1", "mytag2" "ein_name", "nochein_name" ] - OR... Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.E...
entailment
def get_meta(self): """Get the metadata object for this Thing Returns a [ThingMeta](ThingMeta.m.html#IoticAgent.IOT.ThingMeta.ThingMeta) object """ rdf = self.get_meta_rdf(fmt='n3') return ThingMeta(self, rdf, self._client.default_lang, fmt='n3')
Get the metadata object for this Thing Returns a [ThingMeta](ThingMeta.m.html#IoticAgent.IOT.ThingMeta.ThingMeta) object
entailment
def get_meta_rdf(self, fmt='n3'): """Get the metadata for this Thing in rdf fmt Advanced users who want to manipulate the RDF for this Thing directly without the [ThingMeta](ThingMeta.m.html#IoticAgent.IOT.ThingMeta.ThingMeta) helper object Returns the RDF in the format you specify. - ...
Get the metadata for this Thing in rdf fmt Advanced users who want to manipulate the RDF for this Thing directly without the [ThingMeta](ThingMeta.m.html#IoticAgent.IOT.ThingMeta.ThingMeta) helper object Returns the RDF in the format you specify. - OR - Raises [IOTException](./Excepti...
entailment
def set_meta_rdf(self, rdf, fmt='n3'): """Set the metadata for this Thing in RDF fmt Advanced users who want to manipulate the RDF for this Thing directly without the [ThingMeta](ThingMeta.m.html#IoticAgent.IOT.ThingMeta.ThingMeta) helper object Raises [IOTException](./Exceptions.m.htm...
Set the metadata for this Thing in RDF fmt Advanced users who want to manipulate the RDF for this Thing directly without the [ThingMeta](ThingMeta.m.html#IoticAgent.IOT.ThingMeta.ThingMeta) helper object Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) ...
entailment
def get_feed(self, pid): """Get the details of a newly created feed. This only applies to asynchronous creation of feeds and the new feed instance can only be retrieved once. `NOTE` - Destructive Read. Once you've called get_feed once, any further calls will raise a `KeyError` Returns ...
Get the details of a newly created feed. This only applies to asynchronous creation of feeds and the new feed instance can only be retrieved once. `NOTE` - Destructive Read. Once you've called get_feed once, any further calls will raise a `KeyError` Returns a [Feed](Point.m.html#IoticAgent.IOT...
entailment
def get_control(self, pid): """Get the details of a newly created control. This only applies to asynchronous creation of feeds and the new control instance can only be retrieved once. `NOTE` - Destructive Read. Once you've called get_control once, any further calls will raise a `KeyError` ...
Get the details of a newly created control. This only applies to asynchronous creation of feeds and the new control instance can only be retrieved once. `NOTE` - Destructive Read. Once you've called get_control once, any further calls will raise a `KeyError` Returns a [Control](Point.m.html#Io...
entailment
def create_feed(self, pid, save_recent=0): """Create a new Feed for this Thing with a local point id (pid). Returns a new [Feed](Point.m.html#IoticAgent.IOT.Point.Feed) object, or the existing one, if the Feed already exists Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exce...
Create a new Feed for this Thing with a local point id (pid). Returns a new [Feed](Point.m.html#IoticAgent.IOT.Point.Feed) object, or the existing one, if the Feed already exists Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if t...
entailment
def create_control(self, pid, callback, callback_parsed=None): """Create a control for this Thing with a local point id (pid) and a control request feedback Returns a new [Control](Point.m.html#IoticAgent.IOT.Point.Control) object or the existing one if the Control already exists Raise...
Create a control for this Thing with a local point id (pid) and a control request feedback Returns a new [Control](Point.m.html#IoticAgent.IOT.Point.Control) object or the existing one if the Control already exists Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTExceptio...
entailment
def delete_feed(self, pid): """Delete a feed, identified by its local id. Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLi...
Delete a feed, identified by its local id. Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) if there is a...
entailment
def delete_control(self, pid): """Delete a control, identified by its local id. Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core....
Delete a control, identified by its local id. Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) if there i...
entailment
def __sub_add_reference(self, key): """Used by __sub_make_request to save reference for pending sub request""" new_subs = self.__new_subs with new_subs: # don't allow multiple subscription requests to overwrite internal reference if key in new_subs: raise ...
Used by __sub_make_request to save reference for pending sub request
entailment
def __sub_del_reference(self, req, key): """Blindly clear reference to pending subscription on failure.""" if not req.success: try: self.__new_subs.pop(key) except KeyError: logger.warning('No sub ref %s', key)
Blindly clear reference to pending subscription on failure.
entailment
def __sub_make_request(self, foc, gpid, callback): """Make right subscription request depending on whether local or global - used by __sub*""" # global if isinstance(gpid, string_types): gpid = uuid_to_hex(gpid) ref = (foc, gpid) with self.__sub_add_reference(...
Make right subscription request depending on whether local or global - used by __sub*
entailment
def follow(self, gpid, callback=None, callback_parsed=None): """Create a subscription (i.e. follow) a Feed/Point with a global point id (gpid) and a feed data callback Returns a new [RemoteFeed](RemotePoint.m.html#IoticAgent.IOT.RemotePoint.RemoteFeed) object or the existing one if the subscrip...
Create a subscription (i.e. follow) a Feed/Point with a global point id (gpid) and a feed data callback Returns a new [RemoteFeed](RemotePoint.m.html#IoticAgent.IOT.RemotePoint.RemoteFeed) object or the existing one if the subscription already exists - OR - Raises [IOTException](./Exceptions.m...
entailment
def list_connections(self, limit=500, offset=0): """List Points to which this Things is subscribed. I.e. list all the Points this Thing is following and controls it's attached to Returns subscription list e.g. #!python { "<Subscription GUID 1>": { ...
List Points to which this Things is subscribed. I.e. list all the Points this Thing is following and controls it's attached to Returns subscription list e.g. #!python { "<Subscription GUID 1>": { "id": "<Control GUID>", "e...
entailment
def _cb_created(self, payload, duplicated): """Indirect callback (via Client) for point & subscription creation responses""" if payload[P_RESOURCE] in _POINT_TYPE_TO_CLASS: store = self.__new_feeds if payload[P_RESOURCE] == R_FEED else self.__new_controls cls = _POINT_TYPE_TO_CLA...
Indirect callback (via Client) for point & subscription creation responses
entailment
def wait(self, allowed_methods=None): """Wait for a method that matches our allowed_methods parameter (the default value of None means match any method), and dispatch to it.""" method_sig, args, content = self.connection._wait_method( self.channel_id, allowed_methods) return...
Wait for a method that matches our allowed_methods parameter (the default value of None means match any method), and dispatch to it.
entailment
def get_recent(self, count): """Get the last instance(s) of feeddata from the feed. Useful if the remote Thing doesn't publish very often. Returns an iterable of dicts (in chronologically ascending order) containing: #!python 'data' # (decoded or raw bytes) 'mime' # ...
Get the last instance(s) of feeddata from the feed. Useful if the remote Thing doesn't publish very often. Returns an iterable of dicts (in chronologically ascending order) containing: #!python 'data' # (decoded or raw bytes) 'mime' # (None, unless payload was not decoded an...
entailment
def get_recent_async(self, count, callback): """Similar to `get_recent` except instead of returning an iterable, passes each dict to the given function which must accept a single argument. Returns the request. `callback` (mandatory) (function) instead of returning an iterable, pass each dict (a...
Similar to `get_recent` except instead of returning an iterable, passes each dict to the given function which must accept a single argument. Returns the request. `callback` (mandatory) (function) instead of returning an iterable, pass each dict (as described above) to the given function which m...
entailment
def simulate(self, data, mime=None): """Simulate the arrival of feeddata into the feed. Useful if the remote Thing doesn't publish very often. `data` (mandatory) (as applicable) The data you want to use to simulate the arrival of remote feed data `mime` (optional) (string) The mime ty...
Simulate the arrival of feeddata into the feed. Useful if the remote Thing doesn't publish very often. `data` (mandatory) (as applicable) The data you want to use to simulate the arrival of remote feed data `mime` (optional) (string) The mime type of your data. See: [share()](./Point...
entailment
def ask(self, data, mime=None): """Request a remote control to do something. Ask is "fire-and-forget" in that you won't receive any notification of the success or otherwise of the action at the far end. Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) c...
Request a remote control to do something. Ask is "fire-and-forget" in that you won't receive any notification of the success or otherwise of the action at the far end. Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure d...
entailment
def tell(self, data, timeout=10, mime=None): """Order a remote control to do something. Tell is confirmed in that you will receive a notification of the success or otherwise of the action at the far end via a callback `Example` #!python data = {"thermostat":18.0} ...
Order a remote control to do something. Tell is confirmed in that you will receive a notification of the success or otherwise of the action at the far end via a callback `Example` #!python data = {"thermostat":18.0} retval = r_thermostat.tell(data, timeout=10, mime...
entailment
def tell_async(self, data, timeout=10, mime=None): """Asyncronous version of [tell()](./RemotePoint.m.html#IoticAgent.IOT.RemotePoint.RemoteControl.tell) `Note` payload contains the success and reason keys they are not separated out as in the synchronous version """ logger.info("tell(ti...
Asyncronous version of [tell()](./RemotePoint.m.html#IoticAgent.IOT.RemotePoint.RemoteControl.tell) `Note` payload contains the success and reason keys they are not separated out as in the synchronous version
entailment
def rename(self, new_pid): """Rename the Point. Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) ...
Rename the Point. Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) if there is a communications problem b...
entailment
def list(self, limit=50, offset=0): """List `all` the values on this Point. Returns QAPI list function payload Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkException](...
List `all` the values on this Point. Returns QAPI list function payload Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLin...
entailment
def list_followers(self): """list followers for this point, i.e. remote follows for feeds and remote attaches for controls. Returns QAPI subscription list function payload #!python { "<Subscription GUID 1>": "<GUID of follower1>", "<Subscription ...
list followers for this point, i.e. remote follows for feeds and remote attaches for controls. Returns QAPI subscription list function payload #!python { "<Subscription GUID 1>": "<GUID of follower1>", "<Subscription GUID 2>": "<GUID of follower2>" ...
entailment
def get_meta(self): """Get the metadata object for this Point Returns a [PointMeta](PointMeta.m.html#IoticAgent.IOT.PointMeta.PointMeta) object - OR - Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a ...
Get the metadata object for this Point Returns a [PointMeta](PointMeta.m.html#IoticAgent.IOT.PointMeta.PointMeta) object - OR - Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkEx...
entailment
def get_meta_rdf(self, fmt='n3'): """Get the metadata for this Point in rdf fmt Advanced users who want to manipulate the RDF for this Point directly without the [PointMeta](PointMeta.m.html#IoticAgent.IOT.PointMeta.PointMeta) helper object Returns the RDF in the format you specify. - ...
Get the metadata for this Point in rdf fmt Advanced users who want to manipulate the RDF for this Point directly without the [PointMeta](PointMeta.m.html#IoticAgent.IOT.PointMeta.PointMeta) helper object Returns the RDF in the format you specify. - OR - Raises [IOTException](./Excepti...
entailment
def set_meta_rdf(self, rdf, fmt='n3'): """Set the metadata for this Point in rdf fmt """ evt = self._client._request_point_meta_set(self._type, self.__lid, self.__pid, rdf, fmt=fmt) self._client._wait_and_except_if_failed(evt)
Set the metadata for this Point in rdf fmt
entailment
def create_tag(self, tags): """Create tags for a Point in the language you specify. Tags can only contain alphanumeric (unicode) characters and the underscore. Tags will be stored lower-cased. Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing t...
Create tags for a Point in the language you specify. Tags can only contain alphanumeric (unicode) characters and the underscore. Tags will be stored lower-cased. Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects ...
entailment
def delete_tag(self, tags): """Delete tags for a Point in the language you specify. Case will be ignored and any tags matching lower-cased will be deleted. Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detect...
Delete tags for a Point in the language you specify. Case will be ignored and any tags matching lower-cased will be deleted. Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkExcept...
entailment
def list_tag(self, limit=50, offset=0): """List `all` the tags for this Point Returns list of tags, as below #!python [ "mytag1", "mytag2" "ein_name", "nochein_name" ] - OR... Raises [...
List `all` the tags for this Point Returns list of tags, as below #!python [ "mytag1", "mytag2" "ein_name", "nochein_name" ] - OR... Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Ex...
entailment
def create_value(self, label, vtype, lang=None, description=None, unit=None): """Create a value on this Point. Values are descriptions in semantic metadata of the individual data items you are sharing (or expecting to receive, if this Point is a control). This will help others to search for yo...
Create a value on this Point. Values are descriptions in semantic metadata of the individual data items you are sharing (or expecting to receive, if this Point is a control). This will help others to search for your feed or control. If a value with the given label (and language) already exists, its fi...
entailment
def delete_value(self, label=None): """Delete the labelled value (or all values) on this Point Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkException](../Core/AmqpLink.m.html#I...
Delete the labelled value (or all values) on this Point Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) ...
entailment
def share(self, data, mime=None, time=None): """Share some data from this Feed Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.A...
Share some data from this Feed Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) if there is a communicati...
entailment
def get_recent_info(self): """Retrieves statistics and configuration about recent storage for this Feed. Returns QAPI recent info function payload #!python { "maxSamples": 0, "count": 0 } Raises [IOTException](./Exceptions.m....
Retrieves statistics and configuration about recent storage for this Feed. Returns QAPI recent info function payload #!python { "maxSamples": 0, "count": 0 } Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTExce...
entailment
def set_recent_config(self, max_samples=0): """Update/configure recent data settings for this Feed. If the container does not support recent storage or it is not enabled for this owner, this function will have no effect. `max_samples` (optional) (int) how many shares to store for later retrieva...
Update/configure recent data settings for this Feed. If the container does not support recent storage or it is not enabled for this owner, this function will have no effect. `max_samples` (optional) (int) how many shares to store for later retrieval. If not supported by container, this argument...
entailment
def filter_by(self, text=(), types=(), units=(), include_unset=False): """Return subset of values which match the given text, types and/or units. For a value to be matched, at least one item from each specified filter category has to apply to a value. Each of the categories must be specified as ...
Return subset of values which match the given text, types and/or units. For a value to be matched, at least one item from each specified filter category has to apply to a value. Each of the categories must be specified as a sequence of strings. If `include_unset` is set, unset values will also be consid...
entailment
def to_dict(self): """Converts the set of values into a dictionary. Unset values are excluded.""" return {value.label: value.value for value in self.__values if not value.unset}
Converts the set of values into a dictionary. Unset values are excluded.
entailment
def _from_dict(cls, values, value_filter, dictionary, allow_unset=True): """Instantiates new PointDataObject, populated from the given dictionary. With allow_unset=False, a ValueError will be raised if any value has not been set. Used by PointDataObjectHandler""" if not isinstance(dictionary, Ma...
Instantiates new PointDataObject, populated from the given dictionary. With allow_unset=False, a ValueError will be raised if any value has not been set. Used by PointDataObjectHandler
entailment
def set(self): """Pushes the RDF metadata description back to the infrastructure. This will be searchable if you have called [set_public()](./Thing.m.html#IoticAgent.IOT.Thing.Thing.set_public) at any time `Example 1` Use of python `with` syntax and XXXXmeta class. `Recommended` ...
Pushes the RDF metadata description back to the infrastructure. This will be searchable if you have called [set_public()](./Thing.m.html#IoticAgent.IOT.Thing.Thing.set_public) at any time `Example 1` Use of python `with` syntax and XXXXmeta class. `Recommended` #!python ...
entailment
def update(self): """Gets the latest version of your metadata from the infrastructure and updates your local copy Returns `True` if successful, `False` otherwise - OR - Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrast...
Gets the latest version of your metadata from the infrastructure and updates your local copy Returns `True` if successful, `False` otherwise - OR - Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem ...
entailment
def set_label(self, label, lang=None): """Sets the `label` metadata property on your Thing/Point. Only one label is allowed per language, so any other labels in this language are removed before adding this one Raises `ValueError` containing an error message if the parameters fail validation ...
Sets the `label` metadata property on your Thing/Point. Only one label is allowed per language, so any other labels in this language are removed before adding this one Raises `ValueError` containing an error message if the parameters fail validation `label` (mandatory) (string) the new text o...
entailment
def delete_label(self, lang=None): """Deletes all the `label` metadata properties on your Thing/Point for this language Raises `ValueError` containing an error message if the parameters fail validation `lang` (optional) (string) The two-character ISO 639-1 language code to identify your label....
Deletes all the `label` metadata properties on your Thing/Point for this language Raises `ValueError` containing an error message if the parameters fail validation `lang` (optional) (string) The two-character ISO 639-1 language code to identify your label. None means use the default language f...
entailment
def set_description(self, description, lang=None): """Sets the `description` metadata property on your Thing/Point. Only one description is allowed per language, so any other descriptions in this language are removed before adding this one Raises `ValueError` containing an error message if the...
Sets the `description` metadata property on your Thing/Point. Only one description is allowed per language, so any other descriptions in this language are removed before adding this one Raises `ValueError` containing an error message if the parameters fail validation `description` (mandatory)...
entailment
def delete_description(self, lang=None): """Deletes all the `label` metadata properties on your Thing/Point for this language Raises `ValueError` containing an error message if the parameters fail validation `lang` (optional) (string) The two-character ISO 639-1 language code to use for your l...
Deletes all the `label` metadata properties on your Thing/Point for this language Raises `ValueError` containing an error message if the parameters fail validation `lang` (optional) (string) The two-character ISO 639-1 language code to use for your label. None means use the default language fo...
entailment
def bool_from(obj, default=False): """Returns True if obj is not None and its string representation is not 0 or False (case-insensitive). If obj is None, 'default' is used. """ return str(obj).lower() not in ('0', 'false') if obj is not None else bool(default)
Returns True if obj is not None and its string representation is not 0 or False (case-insensitive). If obj is None, 'default' is used.
entailment
def private_name_for(var_name, cls): """Returns mangled variable name (if applicable) for the given variable and class instance. See https://docs.python.org/3/tutorial/classes.html#private-variables""" if not (isinstance(var_name, string_types) and var_name): raise TypeError('var_name must be non...
Returns mangled variable name (if applicable) for the given variable and class instance. See https://docs.python.org/3/tutorial/classes.html#private-variables
entailment
def private_names_for(cls, names): """Returns iterable of private names using privateNameFor()""" if not isinstance(names, Iterable): raise TypeError('names must be an interable') return (private_name_for(item, cls) for item in names)
Returns iterable of private names using privateNameFor()
entailment
def acquire(self, blocking=True, timeout=-1): """Acquire a lock, blocking or non-blocking. Blocks until timeout, if timeout a positive float and blocking=True. A timeout value of -1 blocks indefinitely, unless blocking=False.""" if not isinstance(timeout, (int, float)): raise...
Acquire a lock, blocking or non-blocking. Blocks until timeout, if timeout a positive float and blocking=True. A timeout value of -1 blocks indefinitely, unless blocking=False.
entailment
def release(self): """Release a lock.""" self.__lock.release() with self.__condition: self.__condition.notify()
Release a lock.
entailment
def set_config(self, config): ''' Set launch data from a ToolConfig. ''' if self.launch_url == None: self.launch_url = config.launch_url self.custom_params.update(config.custom_params)
Set launch data from a ToolConfig.
entailment
def has_required_params(self): ''' Check if required parameters for a tool launch are set. ''' return self.consumer_key and\ self.consumer_secret and\ self.resource_link_id and\ self.launch_url
Check if required parameters for a tool launch are set.
entailment
def _sent_without_response(self, send_time_before): """Used internally to determine whether the request has not received any response from the container and was send before the given time. Unsent requests are not considered.""" return not self._messages and self._send_time and self._send_time...
Used internally to determine whether the request has not received any response from the container and was send before the given time. Unsent requests are not considered.
entailment
def is_set(self): """Returns True if the request has finished or False if it is still pending. Raises [LinkException](AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) if the request failed due to a network related problem. """ if self.__event.is_set(): if self...
Returns True if the request has finished or False if it is still pending. Raises [LinkException](AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) if the request failed due to a network related problem.
entailment
def _set(self): """Called internally by Client to indicate this request has finished""" self.__event.set() if self._complete_func: self.__run_completion_func(self._complete_func, self.id_)
Called internally by Client to indicate this request has finished
entailment
def _run_on_completion(self, func, *args, **kwargs): """Function to call when request has finished, after having been _set(). The first argument passed to func will be the request itself. Additional parameters are NOT validated. If the request is already finished, the given function will be run ...
Function to call when request has finished, after having been _set(). The first argument passed to func will be the request itself. Additional parameters are NOT validated. If the request is already finished, the given function will be run immediately (in same thread).
entailment
def wait(self, timeout=None): """Wait for the request to finish, optionally timing out. Returns True if the request has finished or False if it is still pending. Raises [LinkException](AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) if the request failed due to a network related...
Wait for the request to finish, optionally timing out. Returns True if the request has finished or False if it is still pending. Raises [LinkException](AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) if the request failed due to a network related problem.
entailment