repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
Iotic-Labs/py-IoticAgent | src/IoticAgent/IOT/Client.py | Client.confirm_tell | def confirm_tell(self, data, success):
"""Confirm that you've done as you were told. Call this from your control callback to confirm action.
Used when you are advertising a control and you want to tell the remote requestor that you have
done what they asked you to.
`Example:` this is a... | python | def confirm_tell(self, data, success):
"""Confirm that you've done as you were told. Call this from your control callback to confirm action.
Used when you are advertising a control and you want to tell the remote requestor that you have
done what they asked you to.
`Example:` this is a... | [
"def",
"confirm_tell",
"(",
"self",
",",
"data",
",",
"success",
")",
":",
"logger",
".",
"info",
"(",
"\"confirm_tell(success=%s) [lid=\\\"%s\\\",pid=\\\"%s\\\"]\"",
",",
"success",
",",
"data",
"[",
"P_ENTITY_LID",
"]",
",",
"data",
"[",
"P_LID",
"]",
")",
"... | Confirm that you've done as you were told. Call this from your control callback to confirm action.
Used when you are advertising a control and you want to tell the remote requestor that you have
done what they asked you to.
`Example:` this is a minimal example to show the idea. Note - no Exce... | [
"Confirm",
"that",
"you",
"ve",
"done",
"as",
"you",
"were",
"told",
".",
"Call",
"this",
"from",
"your",
"control",
"callback",
"to",
"confirm",
"action",
".",
"Used",
"when",
"you",
"are",
"advertising",
"a",
"control",
"and",
"you",
"want",
"to",
"tel... | train | https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/IOT/Client.py#L564-L604 |
Iotic-Labs/py-IoticAgent | src/IoticAgent/IOT/Client.py | Client.save_config | def save_config(self):
"""Save the config, update the seqnum & default language
"""
self.__config.set('agent', 'seqnum', self.__client.get_seqnum())
self.__config.set('agent', 'lang', self.__client.default_lang)
self.__config.save() | python | def save_config(self):
"""Save the config, update the seqnum & default language
"""
self.__config.set('agent', 'seqnum', self.__client.get_seqnum())
self.__config.set('agent', 'lang', self.__client.default_lang)
self.__config.save() | [
"def",
"save_config",
"(",
"self",
")",
":",
"self",
".",
"__config",
".",
"set",
"(",
"'agent'",
",",
"'seqnum'",
",",
"self",
".",
"__client",
".",
"get_seqnum",
"(",
")",
")",
"self",
".",
"__config",
".",
"set",
"(",
"'agent'",
",",
"'lang'",
","... | Save the config, update the seqnum & default language | [
"Save",
"the",
"config",
"update",
"the",
"seqnum",
"&",
"default",
"language"
] | train | https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/IOT/Client.py#L606-L611 |
Iotic-Labs/py-IoticAgent | src/IoticAgent/IOT/Client.py | Client._get_point_data_handler_for | def _get_point_data_handler_for(self, point):
"""Used by point instances and data callbacks"""
with self.__point_data_handlers:
try:
return self.__point_data_handlers[point]
except KeyError:
return self.__point_data_handlers.setdefault(point, Point... | python | def _get_point_data_handler_for(self, point):
"""Used by point instances and data callbacks"""
with self.__point_data_handlers:
try:
return self.__point_data_handlers[point]
except KeyError:
return self.__point_data_handlers.setdefault(point, Point... | [
"def",
"_get_point_data_handler_for",
"(",
"self",
",",
"point",
")",
":",
"with",
"self",
".",
"__point_data_handlers",
":",
"try",
":",
"return",
"self",
".",
"__point_data_handlers",
"[",
"point",
"]",
"except",
"KeyError",
":",
"return",
"self",
".",
"__po... | Used by point instances and data callbacks | [
"Used",
"by",
"point",
"instances",
"and",
"data",
"callbacks"
] | train | https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/IOT/Client.py#L621-L627 |
Iotic-Labs/py-IoticAgent | src/IoticAgent/IOT/Client.py | Client._parsed_callback_wrapper | def _parsed_callback_wrapper(self, callback_parsed, callback_plain, foc, data):
"""Used to by register_catchall_*data() and Thing class (follow, create_point) to present point data as an
object."""
# used by PointDataObjectHandler as reference
if foc == R_FEED:
point_ref = da... | python | def _parsed_callback_wrapper(self, callback_parsed, callback_plain, foc, data):
"""Used to by register_catchall_*data() and Thing class (follow, create_point) to present point data as an
object."""
# used by PointDataObjectHandler as reference
if foc == R_FEED:
point_ref = da... | [
"def",
"_parsed_callback_wrapper",
"(",
"self",
",",
"callback_parsed",
",",
"callback_plain",
",",
"foc",
",",
"data",
")",
":",
"# used by PointDataObjectHandler as reference",
"if",
"foc",
"==",
"R_FEED",
":",
"point_ref",
"=",
"data",
"[",
"'pid'",
"]",
"else"... | Used to by register_catchall_*data() and Thing class (follow, create_point) to present point data as an
object. | [
"Used",
"to",
"by",
"register_catchall_",
"*",
"data",
"()",
"and",
"Thing",
"class",
"(",
"follow",
"create_point",
")",
"to",
"present",
"point",
"data",
"as",
"an",
"object",
"."
] | train | https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/IOT/Client.py#L629-L651 |
Iotic-Labs/py-IoticAgent | src/IoticAgent/IOT/Client.py | Client._wait_and_except_if_failed | def _wait_and_except_if_failed(self, event, timeout=None):
"""Combines waiting for event and call to `_except_if_failed`. If timeout is not specified the configured
sync_timeout is used.
"""
event.wait(timeout or self.__sync_timeout)
self._except_if_failed(event) | python | def _wait_and_except_if_failed(self, event, timeout=None):
"""Combines waiting for event and call to `_except_if_failed`. If timeout is not specified the configured
sync_timeout is used.
"""
event.wait(timeout or self.__sync_timeout)
self._except_if_failed(event) | [
"def",
"_wait_and_except_if_failed",
"(",
"self",
",",
"event",
",",
"timeout",
"=",
"None",
")",
":",
"event",
".",
"wait",
"(",
"timeout",
"or",
"self",
".",
"__sync_timeout",
")",
"self",
".",
"_except_if_failed",
"(",
"event",
")"
] | Combines waiting for event and call to `_except_if_failed`. If timeout is not specified the configured
sync_timeout is used. | [
"Combines",
"waiting",
"for",
"event",
"and",
"call",
"to",
"_except_if_failed",
".",
"If",
"timeout",
"is",
"not",
"specified",
"the",
"configured",
"sync_timeout",
"is",
"used",
"."
] | train | https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/IOT/Client.py#L661-L666 |
Iotic-Labs/py-IoticAgent | src/IoticAgent/IOT/Client.py | Client._except_if_failed | def _except_if_failed(cls, event):
"""Raises an IOTException from the given event if it was not successful. Assumes timeout success flag on event
has not been set yet."""
if event.success is None:
raise IOTSyncTimeout('Requested timed out', event)
if not event.success:
... | python | def _except_if_failed(cls, event):
"""Raises an IOTException from the given event if it was not successful. Assumes timeout success flag on event
has not been set yet."""
if event.success is None:
raise IOTSyncTimeout('Requested timed out', event)
if not event.success:
... | [
"def",
"_except_if_failed",
"(",
"cls",
",",
"event",
")",
":",
"if",
"event",
".",
"success",
"is",
"None",
":",
"raise",
"IOTSyncTimeout",
"(",
"'Requested timed out'",
",",
"event",
")",
"if",
"not",
"event",
".",
"success",
":",
"msg",
"=",
"\"Request ... | Raises an IOTException from the given event if it was not successful. Assumes timeout success flag on event
has not been set yet. | [
"Raises",
"an",
"IOTException",
"from",
"the",
"given",
"event",
"if",
"it",
"was",
"not",
"successful",
".",
"Assumes",
"timeout",
"success",
"flag",
"on",
"event",
"has",
"not",
"been",
"set",
"yet",
"."
] | train | https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/IOT/Client.py#L669-L686 |
Iotic-Labs/py-IoticAgent | src/IoticAgent/IOT/Client.py | Client.list | def list(self, all_my_agents=False, limit=500, offset=0):
"""List `all` the things created by this client on this or all your agents
Returns QAPI list function payload
Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException)
if there is a communications pr... | python | def list(self, all_my_agents=False, limit=500, offset=0):
"""List `all` the things created by this client on this or all your agents
Returns QAPI list function payload
Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException)
if there is a communications pr... | [
"def",
"list",
"(",
"self",
",",
"all_my_agents",
"=",
"False",
",",
"limit",
"=",
"500",
",",
"offset",
"=",
"0",
")",
":",
"logger",
".",
"info",
"(",
"\"list(all_my_agents=%s, limit=%s, offset=%s)\"",
",",
"all_my_agents",
",",
"limit",
",",
"offset",
")"... | List `all` the things created by this client on this or all your agents
Returns QAPI list function payload
Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException)
if there is a communications problem between you and the infrastructure
`all_my_agents` (op... | [
"List",
"all",
"the",
"things",
"created",
"by",
"this",
"client",
"on",
"this",
"or",
"all",
"your",
"agents"
] | train | https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/IOT/Client.py#L688-L710 |
Iotic-Labs/py-IoticAgent | src/IoticAgent/IOT/Client.py | Client.get_thing | def get_thing(self, lid):
"""Get the details of a newly created Thing. This only applies to asynchronous creation of Things and the
new Thing instance can only be retrieved once.
Returns a [Thing](Thing.m.html#IoticAgent.IOT.Thing.Thing) object,
which corresponds to the Thing with the g... | python | def get_thing(self, lid):
"""Get the details of a newly created Thing. This only applies to asynchronous creation of Things and the
new Thing instance can only be retrieved once.
Returns a [Thing](Thing.m.html#IoticAgent.IOT.Thing.Thing) object,
which corresponds to the Thing with the g... | [
"def",
"get_thing",
"(",
"self",
",",
"lid",
")",
":",
"with",
"self",
".",
"__new_things",
":",
"try",
":",
"return",
"self",
".",
"__new_things",
".",
"pop",
"(",
"lid",
")",
"except",
"KeyError",
"as",
"ex",
":",
"raise_from",
"(",
"KeyError",
"(",
... | Get the details of a newly created Thing. This only applies to asynchronous creation of Things and the
new Thing instance can only be retrieved once.
Returns a [Thing](Thing.m.html#IoticAgent.IOT.Thing.Thing) object,
which corresponds to the Thing with the given local id (nickname)
Rai... | [
"Get",
"the",
"details",
"of",
"a",
"newly",
"created",
"Thing",
".",
"This",
"only",
"applies",
"to",
"asynchronous",
"creation",
"of",
"Things",
"and",
"the",
"new",
"Thing",
"instance",
"can",
"only",
"be",
"retrieved",
"once",
"."
] | train | https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/IOT/Client.py#L712-L727 |
Iotic-Labs/py-IoticAgent | src/IoticAgent/IOT/Client.py | Client.create_thing | def create_thing(self, lid):
"""Create a new Thing with a local id (lid).
Returns a [Thing](Thing.m.html#IoticAgent.IOT.Thing.Thing) object if successful
or if the Thing already exists
Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException)
containing... | python | def create_thing(self, lid):
"""Create a new Thing with a local id (lid).
Returns a [Thing](Thing.m.html#IoticAgent.IOT.Thing.Thing) object if successful
or if the Thing already exists
Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException)
containing... | [
"def",
"create_thing",
"(",
"self",
",",
"lid",
")",
":",
"evt",
"=",
"self",
".",
"create_thing_async",
"(",
"lid",
")",
"self",
".",
"_wait_and_except_if_failed",
"(",
"evt",
")",
"try",
":",
"with",
"self",
".",
"__new_things",
":",
"return",
"self",
... | Create a new Thing with a local id (lid).
Returns a [Thing](Thing.m.html#IoticAgent.IOT.Thing.Thing) object if successful
or if the Thing already exists
Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException)
containing the error if the infrastructure detects... | [
"Create",
"a",
"new",
"Thing",
"with",
"a",
"local",
"id",
"(",
"lid",
")",
"."
] | train | https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/IOT/Client.py#L729-L750 |
Iotic-Labs/py-IoticAgent | src/IoticAgent/IOT/Client.py | Client.delete_thing | def delete_thing(self, lid):
"""Delete a Thing
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)
i... | python | def delete_thing(self, lid):
"""Delete a Thing
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)
i... | [
"def",
"delete_thing",
"(",
"self",
",",
"lid",
")",
":",
"logger",
".",
"info",
"(",
"\"delete_thing(lid=\\\"%s\\\")\"",
",",
"lid",
")",
"evt",
"=",
"self",
".",
"delete_thing_async",
"(",
"lid",
")",
"self",
".",
"_wait_and_except_if_failed",
"(",
"evt",
... | Delete a Thing
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 betw... | [
"Delete",
"a",
"Thing"
] | train | https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/IOT/Client.py#L756-L769 |
Iotic-Labs/py-IoticAgent | src/IoticAgent/IOT/Client.py | Client.search | def search(self, text=None, lang=None, location=None, unit=None, limit=50, offset=0, reduced=False, local=None,
scope=SearchScope.PUBLIC):
"""Search the Iotic Space for public Things with metadata matching the search parameters:
text, lang(uage), location, unit, limit, offset. Note that o... | python | def search(self, text=None, lang=None, location=None, unit=None, limit=50, offset=0, reduced=False, local=None,
scope=SearchScope.PUBLIC):
"""Search the Iotic Space for public Things with metadata matching the search parameters:
text, lang(uage), location, unit, limit, offset. Note that o... | [
"def",
"search",
"(",
"self",
",",
"text",
"=",
"None",
",",
"lang",
"=",
"None",
",",
"location",
"=",
"None",
",",
"unit",
"=",
"None",
",",
"limit",
"=",
"50",
",",
"offset",
"=",
"0",
",",
"reduced",
"=",
"False",
",",
"local",
"=",
"None",
... | Search the Iotic Space for public Things with metadata matching the search parameters:
text, lang(uage), location, unit, limit, offset. Note that only things which have at least one point defined can
be found.
Returns dict of results as below (first with reduced=False, second with reduced=True)... | [
"Search",
"the",
"Iotic",
"Space",
"for",
"public",
"Things",
"with",
"metadata",
"matching",
"the",
"search",
"parameters",
":",
"text",
"lang",
"(",
"uage",
")",
"location",
"unit",
"limit",
"offset",
".",
"Note",
"that",
"only",
"things",
"which",
"have",... | train | https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/IOT/Client.py#L775-L885 |
Iotic-Labs/py-IoticAgent | src/IoticAgent/IOT/Client.py | Client.search_reduced | def search_reduced(self, text=None, lang=None, location=None, unit=None, limit=100, offset=0, local=None,
scope=SearchScope.PUBLIC):
"""Shorthand for [search()](#IoticAgent.IOT.Client.Client.search) with `reduced=True`"""
return self.search(text, lang, location, unit, limit, offse... | python | def search_reduced(self, text=None, lang=None, location=None, unit=None, limit=100, offset=0, local=None,
scope=SearchScope.PUBLIC):
"""Shorthand for [search()](#IoticAgent.IOT.Client.Client.search) with `reduced=True`"""
return self.search(text, lang, location, unit, limit, offse... | [
"def",
"search_reduced",
"(",
"self",
",",
"text",
"=",
"None",
",",
"lang",
"=",
"None",
",",
"location",
"=",
"None",
",",
"unit",
"=",
"None",
",",
"limit",
"=",
"100",
",",
"offset",
"=",
"0",
",",
"local",
"=",
"None",
",",
"scope",
"=",
"Se... | Shorthand for [search()](#IoticAgent.IOT.Client.Client.search) with `reduced=True` | [
"Shorthand",
"for",
"[",
"search",
"()",
"]",
"(",
"#IoticAgent",
".",
"IOT",
".",
"Client",
".",
"Client",
".",
"search",
")",
"with",
"reduced",
"=",
"True"
] | train | https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/IOT/Client.py#L887-L890 |
Iotic-Labs/py-IoticAgent | src/IoticAgent/IOT/Client.py | Client.search_located | def search_located(self, text=None, lang=None, location=None, unit=None, limit=100, offset=0, local=None,
scope=SearchScope.PUBLIC):
"""See [search()](#IoticAgent.IOT.Client.Client.search) for general documentation. Provides a thing-only
result set comprised only of things which h... | python | def search_located(self, text=None, lang=None, location=None, unit=None, limit=100, offset=0, local=None,
scope=SearchScope.PUBLIC):
"""See [search()](#IoticAgent.IOT.Client.Client.search) for general documentation. Provides a thing-only
result set comprised only of things which h... | [
"def",
"search_located",
"(",
"self",
",",
"text",
"=",
"None",
",",
"lang",
"=",
"None",
",",
"location",
"=",
"None",
",",
"unit",
"=",
"None",
",",
"limit",
"=",
"100",
",",
"offset",
"=",
"0",
",",
"local",
"=",
"None",
",",
"scope",
"=",
"Se... | See [search()](#IoticAgent.IOT.Client.Client.search) for general documentation. Provides a thing-only
result set comprised only of things which have a location set, e.g.:
#!python
{
# Keyed by thing id
'2b2d8b068e404861b19f9e060877e002':
... | [
"See",
"[",
"search",
"()",
"]",
"(",
"#IoticAgent",
".",
"IOT",
".",
"Client",
".",
"Client",
".",
"search",
")",
"for",
"general",
"documentation",
".",
"Provides",
"a",
"thing",
"-",
"only",
"result",
"set",
"comprised",
"only",
"of",
"things",
"which... | train | https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/IOT/Client.py#L892-L918 |
Iotic-Labs/py-IoticAgent | src/IoticAgent/IOT/Client.py | Client.describe | def describe(self, guid_or_resource, lang=None, local=None, scope=DescribeScope.AUTO):
"""Describe returns the public (or local) description of a Thing or Point
Returns the description dict (see below for Thing example) if available, otherwise `None`
#!python
{
... | python | def describe(self, guid_or_resource, lang=None, local=None, scope=DescribeScope.AUTO):
"""Describe returns the public (or local) description of a Thing or Point
Returns the description dict (see below for Thing example) if available, otherwise `None`
#!python
{
... | [
"def",
"describe",
"(",
"self",
",",
"guid_or_resource",
",",
"lang",
"=",
"None",
",",
"local",
"=",
"None",
",",
"scope",
"=",
"DescribeScope",
".",
"AUTO",
")",
":",
"if",
"isinstance",
"(",
"guid_or_resource",
",",
"self",
".",
"__guid_resources",
")",... | Describe returns the public (or local) description of a Thing or Point
Returns the description dict (see below for Thing example) if available, otherwise `None`
#!python
{
"type": "Entity",
"meta": {
"long": 0.716356,
... | [
"Describe",
"returns",
"the",
"public",
"(",
"or",
"local",
")",
"description",
"of",
"a",
"Thing",
"or",
"Point"
] | train | https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/IOT/Client.py#L923-L995 |
tophatmonocle/ims_lti_py | ims_lti_py/outcome_request.py | OutcomeRequest.from_post_request | def from_post_request(post_request):
'''
Convenience method for creating a new OutcomeRequest from a request
object.
post_request is assumed to be a Django HttpRequest object
'''
request = OutcomeRequest()
request.post_request = post_request
request.proce... | python | def from_post_request(post_request):
'''
Convenience method for creating a new OutcomeRequest from a request
object.
post_request is assumed to be a Django HttpRequest object
'''
request = OutcomeRequest()
request.post_request = post_request
request.proce... | [
"def",
"from_post_request",
"(",
"post_request",
")",
":",
"request",
"=",
"OutcomeRequest",
"(",
")",
"request",
".",
"post_request",
"=",
"post_request",
"request",
".",
"process_xml",
"(",
"post_request",
".",
"data",
")",
"return",
"request"
] | Convenience method for creating a new OutcomeRequest from a request
object.
post_request is assumed to be a Django HttpRequest object | [
"Convenience",
"method",
"for",
"creating",
"a",
"new",
"OutcomeRequest",
"from",
"a",
"request",
"object",
"."
] | train | https://github.com/tophatmonocle/ims_lti_py/blob/979244d83c2e6420d2c1941f58e52f641c56ad12/ims_lti_py/outcome_request.py#L48-L58 |
tophatmonocle/ims_lti_py | ims_lti_py/outcome_request.py | OutcomeRequest.post_replace_result | def post_replace_result(self, score, result_data=None):
'''
POSTs the given score to the Tool Consumer with a replaceResult.
OPTIONAL:
result_data must be a dictionary
Note: ONLY ONE of these values can be in the dict at a time,
due to the Canvas specificatio... | python | def post_replace_result(self, score, result_data=None):
'''
POSTs the given score to the Tool Consumer with a replaceResult.
OPTIONAL:
result_data must be a dictionary
Note: ONLY ONE of these values can be in the dict at a time,
due to the Canvas specificatio... | [
"def",
"post_replace_result",
"(",
"self",
",",
"score",
",",
"result_data",
"=",
"None",
")",
":",
"self",
".",
"operation",
"=",
"REPLACE_REQUEST",
"self",
".",
"score",
"=",
"score",
"self",
".",
"result_data",
"=",
"result_data",
"if",
"result_data",
"is... | POSTs the given score to the Tool Consumer with a replaceResult.
OPTIONAL:
result_data must be a dictionary
Note: ONLY ONE of these values can be in the dict at a time,
due to the Canvas specification.
'text' : str text
'url' : str url | [
"POSTs",
"the",
"given",
"score",
"to",
"the",
"Tool",
"Consumer",
"with",
"a",
"replaceResult",
"."
] | train | https://github.com/tophatmonocle/ims_lti_py/blob/979244d83c2e6420d2c1941f58e52f641c56ad12/ims_lti_py/outcome_request.py#L60-L87 |
tophatmonocle/ims_lti_py | ims_lti_py/outcome_request.py | OutcomeRequest.post_outcome_request | def post_outcome_request(self):
'''
POST an OAuth signed request to the Tool Consumer.
'''
if not self.has_required_attributes():
raise InvalidLTIConfigError(
'OutcomeRequest does not have all required attributes')
consumer = oauth2.Consumer(key=self.... | python | def post_outcome_request(self):
'''
POST an OAuth signed request to the Tool Consumer.
'''
if not self.has_required_attributes():
raise InvalidLTIConfigError(
'OutcomeRequest does not have all required attributes')
consumer = oauth2.Consumer(key=self.... | [
"def",
"post_outcome_request",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"has_required_attributes",
"(",
")",
":",
"raise",
"InvalidLTIConfigError",
"(",
"'OutcomeRequest does not have all required attributes'",
")",
"consumer",
"=",
"oauth2",
".",
"Consumer",
... | POST an OAuth signed request to the Tool Consumer. | [
"POST",
"an",
"OAuth",
"signed",
"request",
"to",
"the",
"Tool",
"Consumer",
"."
] | train | https://github.com/tophatmonocle/ims_lti_py/blob/979244d83c2e6420d2c1941f58e52f641c56ad12/ims_lti_py/outcome_request.py#L124-L169 |
tophatmonocle/ims_lti_py | ims_lti_py/outcome_request.py | OutcomeRequest.process_xml | def process_xml(self, xml):
'''
Parse Outcome Request data from XML.
'''
root = objectify.fromstring(xml)
self.message_identifier = str(
root.imsx_POXHeader.imsx_POXRequestHeaderInfo.
imsx_messageIdentifier)
try:
result = root.imsx_POXB... | python | def process_xml(self, xml):
'''
Parse Outcome Request data from XML.
'''
root = objectify.fromstring(xml)
self.message_identifier = str(
root.imsx_POXHeader.imsx_POXRequestHeaderInfo.
imsx_messageIdentifier)
try:
result = root.imsx_POXB... | [
"def",
"process_xml",
"(",
"self",
",",
"xml",
")",
":",
"root",
"=",
"objectify",
".",
"fromstring",
"(",
"xml",
")",
"self",
".",
"message_identifier",
"=",
"str",
"(",
"root",
".",
"imsx_POXHeader",
".",
"imsx_POXRequestHeaderInfo",
".",
"imsx_messageIdenti... | Parse Outcome Request data from XML. | [
"Parse",
"Outcome",
"Request",
"data",
"from",
"XML",
"."
] | train | https://github.com/tophatmonocle/ims_lti_py/blob/979244d83c2e6420d2c1941f58e52f641c56ad12/ims_lti_py/outcome_request.py#L171-L206 |
Iotic-Labs/py-IoticAgent | src/IoticAgent/third/amqp/transport.py | SSLTransport._setup_transport | def _setup_transport(self):
"""Wrap the socket in an SSL object."""
if hasattr(self, 'sslopts'):
self.sock = ssl.wrap_socket(self.sock, **self.sslopts)
elif hasattr(self, 'sslctx'):
self.sock = self.sslctx.wrap_socket(self.sock,
... | python | def _setup_transport(self):
"""Wrap the socket in an SSL object."""
if hasattr(self, 'sslopts'):
self.sock = ssl.wrap_socket(self.sock, **self.sslopts)
elif hasattr(self, 'sslctx'):
self.sock = self.sslctx.wrap_socket(self.sock,
... | [
"def",
"_setup_transport",
"(",
"self",
")",
":",
"if",
"hasattr",
"(",
"self",
",",
"'sslopts'",
")",
":",
"self",
".",
"sock",
"=",
"ssl",
".",
"wrap_socket",
"(",
"self",
".",
"sock",
",",
"*",
"*",
"self",
".",
"sslopts",
")",
"elif",
"hasattr",
... | Wrap the socket in an SSL object. | [
"Wrap",
"the",
"socket",
"in",
"an",
"SSL",
"object",
"."
] | train | https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/third/amqp/transport.py#L226-L236 |
Iotic-Labs/py-IoticAgent | src/IoticAgent/third/amqp/transport.py | SSLTransport._shutdown_transport | def _shutdown_transport(self):
"""Unwrap a Python 2.6 SSL socket, so we can call shutdown()"""
if self.sock is not None:
try:
unwrap = self.sock.unwrap
except AttributeError:
return
try:
self.sock = unwrap()
... | python | def _shutdown_transport(self):
"""Unwrap a Python 2.6 SSL socket, so we can call shutdown()"""
if self.sock is not None:
try:
unwrap = self.sock.unwrap
except AttributeError:
return
try:
self.sock = unwrap()
... | [
"def",
"_shutdown_transport",
"(",
"self",
")",
":",
"if",
"self",
".",
"sock",
"is",
"not",
"None",
":",
"try",
":",
"unwrap",
"=",
"self",
".",
"sock",
".",
"unwrap",
"except",
"AttributeError",
":",
"return",
"try",
":",
"self",
".",
"sock",
"=",
... | Unwrap a Python 2.6 SSL socket, so we can call shutdown() | [
"Unwrap",
"a",
"Python",
"2",
".",
"6",
"SSL",
"socket",
"so",
"we",
"can",
"call",
"shutdown",
"()"
] | train | https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/third/amqp/transport.py#L238-L250 |
Iotic-Labs/py-IoticAgent | src/IoticAgent/IOT/Config.py | Config._file_loc | def _file_loc(self):
"""_file_loc helper returns a possible config filename.
EG /tmp/stuff/fish.py -> /tmp/stuff/fish.ini
"""
if self.__fname is None:
f = os.path.splitext(os.path.basename(argv[0]))[0] + '.ini'
cwd = os.getcwd()
# todo: prefer script p... | python | def _file_loc(self):
"""_file_loc helper returns a possible config filename.
EG /tmp/stuff/fish.py -> /tmp/stuff/fish.ini
"""
if self.__fname is None:
f = os.path.splitext(os.path.basename(argv[0]))[0] + '.ini'
cwd = os.getcwd()
# todo: prefer script p... | [
"def",
"_file_loc",
"(",
"self",
")",
":",
"if",
"self",
".",
"__fname",
"is",
"None",
":",
"f",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"os",
".",
"path",
".",
"basename",
"(",
"argv",
"[",
"0",
"]",
")",
")",
"[",
"0",
"]",
"+",
"'.in... | _file_loc helper returns a possible config filename.
EG /tmp/stuff/fish.py -> /tmp/stuff/fish.ini | [
"_file_loc",
"helper",
"returns",
"a",
"possible",
"config",
"filename",
".",
"EG",
"/",
"tmp",
"/",
"stuff",
"/",
"fish",
".",
"py",
"-",
">",
"/",
"tmp",
"/",
"stuff",
"/",
"fish",
".",
"ini"
] | train | https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/IOT/Config.py#L145-L156 |
Iotic-Labs/py-IoticAgent | src/IoticAgent/IOT/Config.py | Config.setup_logging | def setup_logging(self):
"""Setup logging module based on known modules in the config file
"""
logging.getLogger('amqp').setLevel(str_to_logging(self.get('logging', 'amqp')))
logging.getLogger('rdflib').setLevel(str_to_logging(self.get('logging', 'rdflib'))) | python | def setup_logging(self):
"""Setup logging module based on known modules in the config file
"""
logging.getLogger('amqp').setLevel(str_to_logging(self.get('logging', 'amqp')))
logging.getLogger('rdflib').setLevel(str_to_logging(self.get('logging', 'rdflib'))) | [
"def",
"setup_logging",
"(",
"self",
")",
":",
"logging",
".",
"getLogger",
"(",
"'amqp'",
")",
".",
"setLevel",
"(",
"str_to_logging",
"(",
"self",
".",
"get",
"(",
"'logging'",
",",
"'amqp'",
")",
")",
")",
"logging",
".",
"getLogger",
"(",
"'rdflib'",... | Setup logging module based on known modules in the config file | [
"Setup",
"logging",
"module",
"based",
"on",
"known",
"modules",
"in",
"the",
"config",
"file"
] | train | https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/IOT/Config.py#L158-L162 |
Iotic-Labs/py-IoticAgent | src/IoticAgent/IOT/Config.py | Config.save | def save(self, filename=None):
"""Write config to file."""
if self.__fname is None and filename is None:
raise ValueError('Config loaded from string, no filename specified')
conf = self.__config
cpa = dict_to_cp(conf)
with open(self.__fname if filename is None else fi... | python | def save(self, filename=None):
"""Write config to file."""
if self.__fname is None and filename is None:
raise ValueError('Config loaded from string, no filename specified')
conf = self.__config
cpa = dict_to_cp(conf)
with open(self.__fname if filename is None else fi... | [
"def",
"save",
"(",
"self",
",",
"filename",
"=",
"None",
")",
":",
"if",
"self",
".",
"__fname",
"is",
"None",
"and",
"filename",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"'Config loaded from string, no filename specified'",
")",
"conf",
"=",
"self",
... | Write config to file. | [
"Write",
"config",
"to",
"file",
"."
] | train | https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/IOT/Config.py#L164-L171 |
Iotic-Labs/py-IoticAgent | src/IoticAgent/IOT/Config.py | Config.get | def get(self, section, val):
"""Get a setting or the default
`Returns` The current value of the setting `val` or the default, or `None` if not found
`section` (mandatory) (string) the section name in the config E.g. `"agent"`
`val` (mandatory) (string) the section name in the config E... | python | def get(self, section, val):
"""Get a setting or the default
`Returns` The current value of the setting `val` or the default, or `None` if not found
`section` (mandatory) (string) the section name in the config E.g. `"agent"`
`val` (mandatory) (string) the section name in the config E... | [
"def",
"get",
"(",
"self",
",",
"section",
",",
"val",
")",
":",
"val",
"=",
"val",
".",
"lower",
"(",
")",
"if",
"section",
"in",
"self",
".",
"__config",
":",
"if",
"val",
"in",
"self",
".",
"__config",
"[",
"section",
"]",
":",
"# logger.debug('... | Get a setting or the default
`Returns` The current value of the setting `val` or the default, or `None` if not found
`section` (mandatory) (string) the section name in the config E.g. `"agent"`
`val` (mandatory) (string) the section name in the config E.g. `"host"` | [
"Get",
"a",
"setting",
"or",
"the",
"default"
] | train | https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/IOT/Config.py#L173-L191 |
Iotic-Labs/py-IoticAgent | src/IoticAgent/IOT/Config.py | Config.set | def set(self, section, val, data):
"""Add a setting to the config
`section` (mandatory) (string) the section name in the config E.g. `"agent"`
`val` (mandatory) (string) the section name in the config E.g. `"host"`
`data` (mandatory) (as appropriate) the new value for the `val`
... | python | def set(self, section, val, data):
"""Add a setting to the config
`section` (mandatory) (string) the section name in the config E.g. `"agent"`
`val` (mandatory) (string) the section name in the config E.g. `"host"`
`data` (mandatory) (as appropriate) the new value for the `val`
... | [
"def",
"set",
"(",
"self",
",",
"section",
",",
"val",
",",
"data",
")",
":",
"val",
"=",
"val",
".",
"lower",
"(",
")",
"if",
"section",
"in",
"self",
".",
"__config",
":",
"# logger.debug('set %s %s = %s', section, val, data)",
"self",
".",
"__config",
"... | Add a setting to the config
`section` (mandatory) (string) the section name in the config E.g. `"agent"`
`val` (mandatory) (string) the section name in the config E.g. `"host"`
`data` (mandatory) (as appropriate) the new value for the `val` | [
"Add",
"a",
"setting",
"to",
"the",
"config"
] | train | https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/IOT/Config.py#L193-L205 |
Iotic-Labs/py-IoticAgent | src/IoticAgent/IOT/Config.py | Config.update | def update(self, section, val, data):
"""Add a setting to the config, but if same as default or None then no action.
This saves the .save writing the defaults
`section` (mandatory) (string) the section name in the config E.g. `"agent"`
`val` (mandatory) (string) the section name in the... | python | def update(self, section, val, data):
"""Add a setting to the config, but if same as default or None then no action.
This saves the .save writing the defaults
`section` (mandatory) (string) the section name in the config E.g. `"agent"`
`val` (mandatory) (string) the section name in the... | [
"def",
"update",
"(",
"self",
",",
"section",
",",
"val",
",",
"data",
")",
":",
"k",
"=",
"self",
".",
"get",
"(",
"section",
",",
"val",
")",
"# logger.debug('update %s %s from: %s to: %s', section, val, k, data)",
"if",
"data",
"is",
"not",
"None",
"and",
... | Add a setting to the config, but if same as default or None then no action.
This saves the .save writing the defaults
`section` (mandatory) (string) the section name in the config E.g. `"agent"`
`val` (mandatory) (string) the section name in the config E.g. `"host"`
`data` (mandatory)... | [
"Add",
"a",
"setting",
"to",
"the",
"config",
"but",
"if",
"same",
"as",
"default",
"or",
"None",
"then",
"no",
"action",
".",
"This",
"saves",
"the",
".",
"save",
"writing",
"the",
"defaults"
] | train | https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/IOT/Config.py#L207-L220 |
Iotic-Labs/py-IoticAgent | src/IoticAgent/IOT/ThingMeta.py | ThingMeta.get_location | def get_location(self):
"""Gets the current geo location of your Thing
Returns tuple of `(lat, lon)` in `float` or `(None, None)` if location is not set for this Thing
"""
lat = None
lon = None
# note: always picks from first triple
for _, _, o in self._graph.tri... | python | def get_location(self):
"""Gets the current geo location of your Thing
Returns tuple of `(lat, lon)` in `float` or `(None, None)` if location is not set for this Thing
"""
lat = None
lon = None
# note: always picks from first triple
for _, _, o in self._graph.tri... | [
"def",
"get_location",
"(",
"self",
")",
":",
"lat",
"=",
"None",
"lon",
"=",
"None",
"# note: always picks from first triple",
"for",
"_",
",",
"_",
",",
"o",
"in",
"self",
".",
"_graph",
".",
"triples",
"(",
"(",
"None",
",",
"GEO_NS",
".",
"lat",
",... | Gets the current geo location of your Thing
Returns tuple of `(lat, lon)` in `float` or `(None, None)` if location is not set for this Thing | [
"Gets",
"the",
"current",
"geo",
"location",
"of",
"your",
"Thing"
] | train | https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/IOT/ThingMeta.py#L48-L63 |
Iotic-Labs/py-IoticAgent | src/IoticAgent/IOT/ThingMeta.py | ThingMeta.delete_location | def delete_location(self):
"""Deletes all the `geo:lat` and `geo:long` metadata properties on your Thing
"""
# normally this should only remove one triple each
for s, p, o in self._graph.triples((None, GEO_NS.lat, None)):
self._graph.remove((s, p, o))
for s, p, o in s... | python | def delete_location(self):
"""Deletes all the `geo:lat` and `geo:long` metadata properties on your Thing
"""
# normally this should only remove one triple each
for s, p, o in self._graph.triples((None, GEO_NS.lat, None)):
self._graph.remove((s, p, o))
for s, p, o in s... | [
"def",
"delete_location",
"(",
"self",
")",
":",
"# normally this should only remove one triple each",
"for",
"s",
",",
"p",
",",
"o",
"in",
"self",
".",
"_graph",
".",
"triples",
"(",
"(",
"None",
",",
"GEO_NS",
".",
"lat",
",",
"None",
")",
")",
":",
"... | Deletes all the `geo:lat` and `geo:long` metadata properties on your Thing | [
"Deletes",
"all",
"the",
"geo",
":",
"lat",
"and",
"geo",
":",
"long",
"metadata",
"properties",
"on",
"your",
"Thing"
] | train | https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/IOT/ThingMeta.py#L65-L72 |
Iotic-Labs/py-IoticAgent | src/IoticAgent/Core/AmqpLink.py | AmqpLink.start | def start(self):
"""start connection threads, blocks until started
"""
if not (self.__recv_thread or self.__send_thread):
self.__end.clear()
self.__send_ready.clear()
self.__recv_ready.clear()
timeout = self.__socket_timeout + 1
ignore_... | python | def start(self):
"""start connection threads, blocks until started
"""
if not (self.__recv_thread or self.__send_thread):
self.__end.clear()
self.__send_ready.clear()
self.__recv_ready.clear()
timeout = self.__socket_timeout + 1
ignore_... | [
"def",
"start",
"(",
"self",
")",
":",
"if",
"not",
"(",
"self",
".",
"__recv_thread",
"or",
"self",
".",
"__send_thread",
")",
":",
"self",
".",
"__end",
".",
"clear",
"(",
")",
"self",
".",
"__send_ready",
".",
"clear",
"(",
")",
"self",
".",
"__... | start connection threads, blocks until started | [
"start",
"connection",
"threads",
"blocks",
"until",
"started"
] | train | https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/Core/AmqpLink.py#L120-L162 |
Iotic-Labs/py-IoticAgent | src/IoticAgent/Core/AmqpLink.py | AmqpLink.is_alive | def is_alive(self):
"""Helper function to show if send & recv Threads are running
"""
if self.__send_ready.is_set() and self.__recv_ready.is_set():
if self.__send_thread is not None and self.__recv_thread is not None:
return self.__send_thread.is_alive() and self.__re... | python | def is_alive(self):
"""Helper function to show if send & recv Threads are running
"""
if self.__send_ready.is_set() and self.__recv_ready.is_set():
if self.__send_thread is not None and self.__recv_thread is not None:
return self.__send_thread.is_alive() and self.__re... | [
"def",
"is_alive",
"(",
"self",
")",
":",
"if",
"self",
".",
"__send_ready",
".",
"is_set",
"(",
")",
"and",
"self",
".",
"__recv_ready",
".",
"is_set",
"(",
")",
":",
"if",
"self",
".",
"__send_thread",
"is",
"not",
"None",
"and",
"self",
".",
"__re... | Helper function to show if send & recv Threads are running | [
"Helper",
"function",
"to",
"show",
"if",
"send",
"&",
"recv",
"Threads",
"are",
"running"
] | train | https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/Core/AmqpLink.py#L164-L170 |
Iotic-Labs/py-IoticAgent | src/IoticAgent/Core/AmqpLink.py | AmqpLink.stop | def stop(self):
"""disconnect, blocks until stopped
"""
self.__end.set()
if self.__recv_thread:
self.__recv_thread.join()
self.__recv_thread = None
if self.__send_thread:
self.__send_thread.join()
self.__send_thread = None | python | def stop(self):
"""disconnect, blocks until stopped
"""
self.__end.set()
if self.__recv_thread:
self.__recv_thread.join()
self.__recv_thread = None
if self.__send_thread:
self.__send_thread.join()
self.__send_thread = None | [
"def",
"stop",
"(",
"self",
")",
":",
"self",
".",
"__end",
".",
"set",
"(",
")",
"if",
"self",
".",
"__recv_thread",
":",
"self",
".",
"__recv_thread",
".",
"join",
"(",
")",
"self",
".",
"__recv_thread",
"=",
"None",
"if",
"self",
".",
"__send_thre... | disconnect, blocks until stopped | [
"disconnect",
"blocks",
"until",
"stopped"
] | train | https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/Core/AmqpLink.py#L172-L181 |
Iotic-Labs/py-IoticAgent | src/IoticAgent/Core/AmqpLink.py | AmqpLink.send | def send(self, body, content_type='application/ubjson', timeout=5):
"""timeout indicates amount of time to wait for sending thread to be ready. set to larger than zero to wait
(in seconds, fractional) or None to block.
"""
if self.__send_ready.wait(timeout):
try:
... | python | def send(self, body, content_type='application/ubjson', timeout=5):
"""timeout indicates amount of time to wait for sending thread to be ready. set to larger than zero to wait
(in seconds, fractional) or None to block.
"""
if self.__send_ready.wait(timeout):
try:
... | [
"def",
"send",
"(",
"self",
",",
"body",
",",
"content_type",
"=",
"'application/ubjson'",
",",
"timeout",
"=",
"5",
")",
":",
"if",
"self",
".",
"__send_ready",
".",
"wait",
"(",
"timeout",
")",
":",
"try",
":",
"with",
"self",
".",
"__send_lock",
":"... | timeout indicates amount of time to wait for sending thread to be ready. set to larger than zero to wait
(in seconds, fractional) or None to block. | [
"timeout",
"indicates",
"amount",
"of",
"time",
"to",
"wait",
"for",
"sending",
"thread",
"to",
"be",
"ready",
".",
"set",
"to",
"larger",
"than",
"zero",
"to",
"wait",
"(",
"in",
"seconds",
"fractional",
")",
"or",
"None",
"to",
"block",
"."
] | train | https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/Core/AmqpLink.py#L192-L213 |
Iotic-Labs/py-IoticAgent | src/IoticAgent/Core/AmqpLink.py | AmqpLink.__get_ssl_context | def __get_ssl_context(cls, sslca=None):
"""Make an SSLConext for this Python version using public or sslca
"""
if ((version_info[0] == 2 and (version_info[1] >= 7 and version_info[2] >= 5)) or
(version_info[0] == 3 and version_info[1] >= 4)):
logger.debug('SSL method ... | python | def __get_ssl_context(cls, sslca=None):
"""Make an SSLConext for this Python version using public or sslca
"""
if ((version_info[0] == 2 and (version_info[1] >= 7 and version_info[2] >= 5)) or
(version_info[0] == 3 and version_info[1] >= 4)):
logger.debug('SSL method ... | [
"def",
"__get_ssl_context",
"(",
"cls",
",",
"sslca",
"=",
"None",
")",
":",
"if",
"(",
"(",
"version_info",
"[",
"0",
"]",
"==",
"2",
"and",
"(",
"version_info",
"[",
"1",
"]",
">=",
"7",
"and",
"version_info",
"[",
"2",
"]",
">=",
"5",
")",
")"... | Make an SSLConext for this Python version using public or sslca | [
"Make",
"an",
"SSLConext",
"for",
"this",
"Python",
"version",
"using",
"public",
"or",
"sslca"
] | train | https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/Core/AmqpLink.py#L216-L259 |
Iotic-Labs/py-IoticAgent | src/IoticAgent/Core/AmqpLink.py | AmqpLink.__recv_cb | def __recv_cb(self, msg):
"""Calls user-provided callback and marks message for Ack regardless of success
"""
try:
self.__msg_callback(msg)
except:
logger.exception("AmqpLink.__recv_cb exception calling msg_callback")
finally:
# only works if a... | python | def __recv_cb(self, msg):
"""Calls user-provided callback and marks message for Ack regardless of success
"""
try:
self.__msg_callback(msg)
except:
logger.exception("AmqpLink.__recv_cb exception calling msg_callback")
finally:
# only works if a... | [
"def",
"__recv_cb",
"(",
"self",
",",
"msg",
")",
":",
"try",
":",
"self",
".",
"__msg_callback",
"(",
"msg",
")",
"except",
":",
"logger",
".",
"exception",
"(",
"\"AmqpLink.__recv_cb exception calling msg_callback\"",
")",
"finally",
":",
"# only works if all me... | Calls user-provided callback and marks message for Ack regardless of success | [
"Calls",
"user",
"-",
"provided",
"callback",
"and",
"marks",
"message",
"for",
"Ack",
"regardless",
"of",
"success"
] | train | https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/Core/AmqpLink.py#L275-L285 |
Iotic-Labs/py-IoticAgent | src/IoticAgent/Core/AmqpLink.py | AmqpLink.__recv_run | def __recv_run(self): # pylint: disable=too-many-branches,too-many-statements
"""Main receive thread/loop
"""
while not self.__end.is_set():
self.__unacked = 0
self.__last_id = None
try:
self.__recv_ready.clear() # Ensure event is cleared fo... | python | def __recv_run(self): # pylint: disable=too-many-branches,too-many-statements
"""Main receive thread/loop
"""
while not self.__end.is_set():
self.__unacked = 0
self.__last_id = None
try:
self.__recv_ready.clear() # Ensure event is cleared fo... | [
"def",
"__recv_run",
"(",
"self",
")",
":",
"# pylint: disable=too-many-branches,too-many-statements",
"while",
"not",
"self",
".",
"__end",
".",
"is_set",
"(",
")",
":",
"self",
".",
"__unacked",
"=",
"0",
"self",
".",
"__last_id",
"=",
"None",
"try",
":",
... | Main receive thread/loop | [
"Main",
"receive",
"thread",
"/",
"loop"
] | train | https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/Core/AmqpLink.py#L288-L355 |
Iotic-Labs/py-IoticAgent | src/IoticAgent/Core/AmqpLink.py | AmqpLink.__recv_log_set_exc_and_wait | def __recv_log_set_exc_and_wait(self, msg, level=None, wait_seconds=CONN_RETRY_DELAY_SECONDS):
"""Equivalent to __send_log_set_exc_and_wait but for receiver thread"""
logger.log(
((logging.DEBUG if self.__recv_exc else logging.ERROR) if level is None else level),
msg,
... | python | def __recv_log_set_exc_and_wait(self, msg, level=None, wait_seconds=CONN_RETRY_DELAY_SECONDS):
"""Equivalent to __send_log_set_exc_and_wait but for receiver thread"""
logger.log(
((logging.DEBUG if self.__recv_exc else logging.ERROR) if level is None else level),
msg,
... | [
"def",
"__recv_log_set_exc_and_wait",
"(",
"self",
",",
"msg",
",",
"level",
"=",
"None",
",",
"wait_seconds",
"=",
"CONN_RETRY_DELAY_SECONDS",
")",
":",
"logger",
".",
"log",
"(",
"(",
"(",
"logging",
".",
"DEBUG",
"if",
"self",
".",
"__recv_exc",
"else",
... | Equivalent to __send_log_set_exc_and_wait but for receiver thread | [
"Equivalent",
"to",
"__send_log_set_exc_and_wait",
"but",
"for",
"receiver",
"thread"
] | train | https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/Core/AmqpLink.py#L357-L365 |
Iotic-Labs/py-IoticAgent | src/IoticAgent/Core/AmqpLink.py | AmqpLink.__recv_exc_clear | def __recv_exc_clear(self, log_if_exc_set=None):
"""Equivalent to __send_exc_clear"""
if not (log_if_exc_set is None or self.__recv_exc is None):
logger.info(log_if_exc_set)
self.__recv_exc = None | python | def __recv_exc_clear(self, log_if_exc_set=None):
"""Equivalent to __send_exc_clear"""
if not (log_if_exc_set is None or self.__recv_exc is None):
logger.info(log_if_exc_set)
self.__recv_exc = None | [
"def",
"__recv_exc_clear",
"(",
"self",
",",
"log_if_exc_set",
"=",
"None",
")",
":",
"if",
"not",
"(",
"log_if_exc_set",
"is",
"None",
"or",
"self",
".",
"__recv_exc",
"is",
"None",
")",
":",
"logger",
".",
"info",
"(",
"log_if_exc_set",
")",
"self",
".... | Equivalent to __send_exc_clear | [
"Equivalent",
"to",
"__send_exc_clear"
] | train | https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/Core/AmqpLink.py#L367-L371 |
Iotic-Labs/py-IoticAgent | src/IoticAgent/Core/AmqpLink.py | AmqpLink.__send_run | def __send_run(self):
"""Send request thread
"""
while not self.__end.is_set():
try:
with Connection(userid=self.__prefix + self.__epid,
password=self.__passwd,
virtual_host=self.__vhost,
... | python | def __send_run(self):
"""Send request thread
"""
while not self.__end.is_set():
try:
with Connection(userid=self.__prefix + self.__epid,
password=self.__passwd,
virtual_host=self.__vhost,
... | [
"def",
"__send_run",
"(",
"self",
")",
":",
"while",
"not",
"self",
".",
"__end",
".",
"is_set",
"(",
")",
":",
"try",
":",
"with",
"Connection",
"(",
"userid",
"=",
"self",
".",
"__prefix",
"+",
"self",
".",
"__epid",
",",
"password",
"=",
"self",
... | Send request thread | [
"Send",
"request",
"thread"
] | train | https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/Core/AmqpLink.py#L374-L423 |
Iotic-Labs/py-IoticAgent | src/IoticAgent/Core/AmqpLink.py | AmqpLink.__send_log_set_exc_and_wait | def __send_log_set_exc_and_wait(self, msg, level=None, wait_seconds=CONN_RETRY_DELAY_SECONDS):
"""To be called in exception context only.
msg - message to log
level - logging level. If not specified, ERROR unless it is a repeated failure in which case DEBUG. If
specified, the given leve... | python | def __send_log_set_exc_and_wait(self, msg, level=None, wait_seconds=CONN_RETRY_DELAY_SECONDS):
"""To be called in exception context only.
msg - message to log
level - logging level. If not specified, ERROR unless it is a repeated failure in which case DEBUG. If
specified, the given leve... | [
"def",
"__send_log_set_exc_and_wait",
"(",
"self",
",",
"msg",
",",
"level",
"=",
"None",
",",
"wait_seconds",
"=",
"CONN_RETRY_DELAY_SECONDS",
")",
":",
"logger",
".",
"log",
"(",
"(",
"(",
"logging",
".",
"DEBUG",
"if",
"self",
".",
"__send_exc",
"else",
... | To be called in exception context only.
msg - message to log
level - logging level. If not specified, ERROR unless it is a repeated failure in which case DEBUG. If
specified, the given level will always be used.
wait_seconds - how long to pause for (so retry is not triggered immediately... | [
"To",
"be",
"called",
"in",
"exception",
"context",
"only",
"."
] | train | https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/Core/AmqpLink.py#L425-L440 |
Iotic-Labs/py-IoticAgent | src/IoticAgent/Core/AmqpLink.py | AmqpLink.__send_exc_clear | def __send_exc_clear(self, log_if_exc_set=None):
"""Clear send exception and time. If exception was previously was set, optionally log log_if_exc_set at INFO
level.
"""
if not (log_if_exc_set is None or self.__send_exc is None):
logger.info(log_if_exc_set)
self.__send... | python | def __send_exc_clear(self, log_if_exc_set=None):
"""Clear send exception and time. If exception was previously was set, optionally log log_if_exc_set at INFO
level.
"""
if not (log_if_exc_set is None or self.__send_exc is None):
logger.info(log_if_exc_set)
self.__send... | [
"def",
"__send_exc_clear",
"(",
"self",
",",
"log_if_exc_set",
"=",
"None",
")",
":",
"if",
"not",
"(",
"log_if_exc_set",
"is",
"None",
"or",
"self",
".",
"__send_exc",
"is",
"None",
")",
":",
"logger",
".",
"info",
"(",
"log_if_exc_set",
")",
"self",
".... | Clear send exception and time. If exception was previously was set, optionally log log_if_exc_set at INFO
level. | [
"Clear",
"send",
"exception",
"and",
"time",
".",
"If",
"exception",
"was",
"previously",
"was",
"set",
"optionally",
"log",
"log_if_exc_set",
"at",
"INFO",
"level",
"."
] | train | https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/Core/AmqpLink.py#L442-L449 |
Iotic-Labs/py-IoticAgent | src/IoticAgent/Core/Mime.py | valid_mimetype | def valid_mimetype(type_, allow_none=True):
"""Checks for validity of given type, optionally allowing for a None value. Note: Unknown idx/NUMBER notation, where
NUMBER is not a known shorthand mapping, will be rejected, i.e. type_ is valid if it
1) is an ASCII-only string between 1 & 64 characters lo... | python | def valid_mimetype(type_, allow_none=True):
"""Checks for validity of given type, optionally allowing for a None value. Note: Unknown idx/NUMBER notation, where
NUMBER is not a known shorthand mapping, will be rejected, i.e. type_ is valid if it
1) is an ASCII-only string between 1 & 64 characters lo... | [
"def",
"valid_mimetype",
"(",
"type_",
",",
"allow_none",
"=",
"True",
")",
":",
"if",
"isinstance",
"(",
"type_",
",",
"unicode_type",
")",
":",
"match",
"=",
"__IDX_PATTERN",
".",
"match",
"(",
"type_",
")",
"if",
"match",
":",
"return",
"match",
".",
... | Checks for validity of given type, optionally allowing for a None value. Note: Unknown idx/NUMBER notation, where
NUMBER is not a known shorthand mapping, will be rejected, i.e. type_ is valid if it
1) is an ASCII-only string between 1 & 64 characters long
2a) does not begin with "idx/" OR
... | [
"Checks",
"for",
"validity",
"of",
"given",
"type",
"optionally",
"allowing",
"for",
"a",
"None",
"value",
".",
"Note",
":",
"Unknown",
"idx",
"/",
"NUMBER",
"notation",
"where",
"NUMBER",
"is",
"not",
"a",
"known",
"shorthand",
"mapping",
"will",
"be",
"r... | train | https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/Core/Mime.py#L46-L60 |
Iotic-Labs/py-IoticAgent | src/IoticAgent/Core/Mime.py | expand_idx_mimetype | def expand_idx_mimetype(type_):
"""Returns long equivalent of type_, if available, otherwise type_ itself. Does not raise exceptions"""
if isinstance(type_, unicode_type):
match = __IDX_PATTERN.match(type_)
return __IDX_MAPPING.get(match.group(1), type_) if match else type_
else:
ret... | python | def expand_idx_mimetype(type_):
"""Returns long equivalent of type_, if available, otherwise type_ itself. Does not raise exceptions"""
if isinstance(type_, unicode_type):
match = __IDX_PATTERN.match(type_)
return __IDX_MAPPING.get(match.group(1), type_) if match else type_
else:
ret... | [
"def",
"expand_idx_mimetype",
"(",
"type_",
")",
":",
"if",
"isinstance",
"(",
"type_",
",",
"unicode_type",
")",
":",
"match",
"=",
"__IDX_PATTERN",
".",
"match",
"(",
"type_",
")",
"return",
"__IDX_MAPPING",
".",
"get",
"(",
"match",
".",
"group",
"(",
... | Returns long equivalent of type_, if available, otherwise type_ itself. Does not raise exceptions | [
"Returns",
"long",
"equivalent",
"of",
"type_",
"if",
"available",
"otherwise",
"type_",
"itself",
".",
"Does",
"not",
"raise",
"exceptions"
] | train | https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/Core/Mime.py#L73-L79 |
Iotic-Labs/py-IoticAgent | src/IoticAgent/Core/RateLimiter.py | RateLimiter.throttle | def throttle(self):
"""Uses time.monotonic() (or time.sleep() if not available) to limit to the desired rate. Should be called once
per iteration of action which is to be throttled. Returns None unless a custom wait_cmd was specified in the
constructor in which case its return value is used if a... | python | def throttle(self):
"""Uses time.monotonic() (or time.sleep() if not available) to limit to the desired rate. Should be called once
per iteration of action which is to be throttled. Returns None unless a custom wait_cmd was specified in the
constructor in which case its return value is used if a... | [
"def",
"throttle",
"(",
"self",
")",
":",
"iterations",
"=",
"self",
".",
"__iterations",
"timestamp",
"=",
"monotonic",
"(",
")",
"outdated_threshold",
"=",
"timestamp",
"-",
"self",
".",
"__interval",
"with",
"self",
".",
"__lock",
":",
"# remove any iterati... | Uses time.monotonic() (or time.sleep() if not available) to limit to the desired rate. Should be called once
per iteration of action which is to be throttled. Returns None unless a custom wait_cmd was specified in the
constructor in which case its return value is used if a wait was required. | [
"Uses",
"time",
".",
"monotonic",
"()",
"(",
"or",
"time",
".",
"sleep",
"()",
"if",
"not",
"available",
")",
"to",
"limit",
"to",
"the",
"desired",
"rate",
".",
"Should",
"be",
"called",
"once",
"per",
"iteration",
"of",
"action",
"which",
"is",
"to",... | train | https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/Core/RateLimiter.py#L54-L85 |
Iotic-Labs/py-IoticAgent | src/IoticAgent/Core/MessageDecoder.py | decode_sent_msg | def decode_sent_msg(pref, message, pretty=False):
"""decode_sent_msg: Return a string of the decoded message
"""
newline = "\n" if pretty else " "
indent = " " if pretty else ""
start = newline + indent
out = []
out.append("%s%s{%sSEQNUM: %d," % (pref, newline, start, message[Const.W_SEQ... | python | def decode_sent_msg(pref, message, pretty=False):
"""decode_sent_msg: Return a string of the decoded message
"""
newline = "\n" if pretty else " "
indent = " " if pretty else ""
start = newline + indent
out = []
out.append("%s%s{%sSEQNUM: %d," % (pref, newline, start, message[Const.W_SEQ... | [
"def",
"decode_sent_msg",
"(",
"pref",
",",
"message",
",",
"pretty",
"=",
"False",
")",
":",
"newline",
"=",
"\"\\n\"",
"if",
"pretty",
"else",
"\" \"",
"indent",
"=",
"\" \"",
"if",
"pretty",
"else",
"\"\"",
"start",
"=",
"newline",
"+",
"indent",
"... | decode_sent_msg: Return a string of the decoded message | [
"decode_sent_msg",
":",
"Return",
"a",
"string",
"of",
"the",
"decoded",
"message"
] | train | https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/Core/MessageDecoder.py#L84-L104 |
Iotic-Labs/py-IoticAgent | src/IoticAgent/Core/MessageDecoder.py | decode_rcvd_msg | def decode_rcvd_msg(pref, message, seqnum, pretty=False):
"""decode_rcvd_msg: Return string of received message expanding short codes, optionally with newlines and indent
"""
newline = "\n" if pretty else " "
indent = " " if pretty else ""
start = newline + indent
out = []
out.append("%s... | python | def decode_rcvd_msg(pref, message, seqnum, pretty=False):
"""decode_rcvd_msg: Return string of received message expanding short codes, optionally with newlines and indent
"""
newline = "\n" if pretty else " "
indent = " " if pretty else ""
start = newline + indent
out = []
out.append("%s... | [
"def",
"decode_rcvd_msg",
"(",
"pref",
",",
"message",
",",
"seqnum",
",",
"pretty",
"=",
"False",
")",
":",
"newline",
"=",
"\"\\n\"",
"if",
"pretty",
"else",
"\" \"",
"indent",
"=",
"\" \"",
"if",
"pretty",
"else",
"\"\"",
"start",
"=",
"newline",
"... | decode_rcvd_msg: Return string of received message expanding short codes, optionally with newlines and indent | [
"decode_rcvd_msg",
":",
"Return",
"string",
"of",
"received",
"message",
"expanding",
"short",
"codes",
"optionally",
"with",
"newlines",
"and",
"indent"
] | train | https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/Core/MessageDecoder.py#L107-L134 |
HumanCellAtlas/dcplib | dcplib/checksumming_io/_crc32c.py | CRC32C._long_to_bytes | def _long_to_bytes(self, long_value):
"""
Turns a long value into its byte string equivalent.
:param long_value: the long value to be returned as a byte string
:return: a byte string equivalent of a long value
"""
_byte_string = b''
pack = struct.pack
whil... | python | def _long_to_bytes(self, long_value):
"""
Turns a long value into its byte string equivalent.
:param long_value: the long value to be returned as a byte string
:return: a byte string equivalent of a long value
"""
_byte_string = b''
pack = struct.pack
whil... | [
"def",
"_long_to_bytes",
"(",
"self",
",",
"long_value",
")",
":",
"_byte_string",
"=",
"b''",
"pack",
"=",
"struct",
".",
"pack",
"while",
"long_value",
">",
"0",
":",
"_byte_string",
"=",
"pack",
"(",
"b'>I'",
",",
"long_value",
"&",
"0xffffffff",
")",
... | Turns a long value into its byte string equivalent.
:param long_value: the long value to be returned as a byte string
:return: a byte string equivalent of a long value | [
"Turns",
"a",
"long",
"value",
"into",
"its",
"byte",
"string",
"equivalent",
".",
":",
"param",
"long_value",
":",
"the",
"long",
"value",
"to",
"be",
"returned",
"as",
"a",
"byte",
"string",
":",
"return",
":",
"a",
"byte",
"string",
"equivalent",
"of"... | train | https://github.com/HumanCellAtlas/dcplib/blob/23614d39914a6b5fc278e732030674a2956a0767/dcplib/checksumming_io/_crc32c.py#L32-L51 |
Iotic-Labs/py-IoticAgent | src/IoticAgent/Core/Client.py | Client.restore_event | def restore_event(self, requestId):
"""restore an event based on the requestId.
For example if the user app had to shutdown with pending requests.
The user can rebuild the Events they were waiting for based on the requestId(s).
"""
with self.__requests:
if requestId ... | python | def restore_event(self, requestId):
"""restore an event based on the requestId.
For example if the user app had to shutdown with pending requests.
The user can rebuild the Events they were waiting for based on the requestId(s).
"""
with self.__requests:
if requestId ... | [
"def",
"restore_event",
"(",
"self",
",",
"requestId",
")",
":",
"with",
"self",
".",
"__requests",
":",
"if",
"requestId",
"not",
"in",
"self",
".",
"__requests",
":",
"self",
".",
"__requests",
"[",
"requestId",
"]",
"=",
"RequestEvent",
"(",
"requestId"... | restore an event based on the requestId.
For example if the user app had to shutdown with pending requests.
The user can rebuild the Events they were waiting for based on the requestId(s). | [
"restore",
"an",
"event",
"based",
"on",
"the",
"requestId",
"."
] | train | https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/Core/Client.py#L286-L296 |
Iotic-Labs/py-IoticAgent | src/IoticAgent/Core/Client.py | Client.__add_callback | def __add_callback(self, type_, func, serialised_if_crud=True):
"""sync_if_crud indicates whether to serialise this callback (applies only to CRUD)"""
Validation.callable_check(func)
with self.__callbacks:
self.__callbacks[type_].append((func, serialised_if_crud)) | python | def __add_callback(self, type_, func, serialised_if_crud=True):
"""sync_if_crud indicates whether to serialise this callback (applies only to CRUD)"""
Validation.callable_check(func)
with self.__callbacks:
self.__callbacks[type_].append((func, serialised_if_crud)) | [
"def",
"__add_callback",
"(",
"self",
",",
"type_",
",",
"func",
",",
"serialised_if_crud",
"=",
"True",
")",
":",
"Validation",
".",
"callable_check",
"(",
"func",
")",
"with",
"self",
".",
"__callbacks",
":",
"self",
".",
"__callbacks",
"[",
"type_",
"]"... | sync_if_crud indicates whether to serialise this callback (applies only to CRUD) | [
"sync_if_crud",
"indicates",
"whether",
"to",
"serialise",
"this",
"callback",
"(",
"applies",
"only",
"to",
"CRUD",
")"
] | train | https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/Core/Client.py#L298-L302 |
Iotic-Labs/py-IoticAgent | src/IoticAgent/Core/Client.py | Client.register_callback_created | def register_callback_created(self, func, serialised=True):
"""Register a callback function to receive QAPI Unsolicited (resource) CREATED. The
callback receives a single argument - the inner message. If `serialised` is not set,
the callbacks might arrive out-of-order (e.g. created point before ... | python | def register_callback_created(self, func, serialised=True):
"""Register a callback function to receive QAPI Unsolicited (resource) CREATED. The
callback receives a single argument - the inner message. If `serialised` is not set,
the callbacks might arrive out-of-order (e.g. created point before ... | [
"def",
"register_callback_created",
"(",
"self",
",",
"func",
",",
"serialised",
"=",
"True",
")",
":",
"self",
".",
"__add_callback",
"(",
"_CB_CREATED",
",",
"func",
",",
"serialised_if_crud",
"=",
"serialised",
")"
] | Register a callback function to receive QAPI Unsolicited (resource) CREATED. The
callback receives a single argument - the inner message. If `serialised` is not set,
the callbacks might arrive out-of-order (e.g. created point before created thing). | [
"Register",
"a",
"callback",
"function",
"to",
"receive",
"QAPI",
"Unsolicited",
"(",
"resource",
")",
"CREATED",
".",
"The",
"callback",
"receives",
"a",
"single",
"argument",
"-",
"the",
"inner",
"message",
".",
"If",
"serialised",
"is",
"not",
"set",
"the... | train | https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/Core/Client.py#L304-L309 |
Iotic-Labs/py-IoticAgent | src/IoticAgent/Core/Client.py | Client.register_callback_duplicate | def register_callback_duplicate(self, func, serialised=True):
"""Register a callback function to receive QAPI Unsolicited (resource) DUPLICATE. The
callback receives a single argument - the inner message. If `serialised` is not set,
the callbacks might arrive out-of-order.
"""
se... | python | def register_callback_duplicate(self, func, serialised=True):
"""Register a callback function to receive QAPI Unsolicited (resource) DUPLICATE. The
callback receives a single argument - the inner message. If `serialised` is not set,
the callbacks might arrive out-of-order.
"""
se... | [
"def",
"register_callback_duplicate",
"(",
"self",
",",
"func",
",",
"serialised",
"=",
"True",
")",
":",
"self",
".",
"__add_callback",
"(",
"_CB_DUPLICATE",
",",
"func",
",",
"serialised_if_crud",
"=",
"serialised",
")"
] | Register a callback function to receive QAPI Unsolicited (resource) DUPLICATE. The
callback receives a single argument - the inner message. If `serialised` is not set,
the callbacks might arrive out-of-order. | [
"Register",
"a",
"callback",
"function",
"to",
"receive",
"QAPI",
"Unsolicited",
"(",
"resource",
")",
"DUPLICATE",
".",
"The",
"callback",
"receives",
"a",
"single",
"argument",
"-",
"the",
"inner",
"message",
".",
"If",
"serialised",
"is",
"not",
"set",
"t... | train | https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/Core/Client.py#L311-L316 |
Iotic-Labs/py-IoticAgent | src/IoticAgent/Core/Client.py | Client.register_callback_renamed | def register_callback_renamed(self, func, serialised=True):
"""Register a callback function to receive QAPI Unsolicited (resource) RENAMED. The
callback receives a single argument - the inner message. If `serialised` is not set,
the callbacks might arrive out-of-order.
"""
self._... | python | def register_callback_renamed(self, func, serialised=True):
"""Register a callback function to receive QAPI Unsolicited (resource) RENAMED. The
callback receives a single argument - the inner message. If `serialised` is not set,
the callbacks might arrive out-of-order.
"""
self._... | [
"def",
"register_callback_renamed",
"(",
"self",
",",
"func",
",",
"serialised",
"=",
"True",
")",
":",
"self",
".",
"__add_callback",
"(",
"_CB_RENAMED",
",",
"func",
",",
"serialised_if_crud",
"=",
"serialised",
")"
] | Register a callback function to receive QAPI Unsolicited (resource) RENAMED. The
callback receives a single argument - the inner message. If `serialised` is not set,
the callbacks might arrive out-of-order. | [
"Register",
"a",
"callback",
"function",
"to",
"receive",
"QAPI",
"Unsolicited",
"(",
"resource",
")",
"RENAMED",
".",
"The",
"callback",
"receives",
"a",
"single",
"argument",
"-",
"the",
"inner",
"message",
".",
"If",
"serialised",
"is",
"not",
"set",
"the... | train | https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/Core/Client.py#L318-L323 |
Iotic-Labs/py-IoticAgent | src/IoticAgent/Core/Client.py | Client.register_callback_deleted | def register_callback_deleted(self, func, serialised=True):
"""Register a callback function to receive QAPI Unsolicited (resource) DELETED. The
callback receives a single argument - the inner message. If `serialised` is not set,
the callbacks might arrive out-of-order.
"""
self._... | python | def register_callback_deleted(self, func, serialised=True):
"""Register a callback function to receive QAPI Unsolicited (resource) DELETED. The
callback receives a single argument - the inner message. If `serialised` is not set,
the callbacks might arrive out-of-order.
"""
self._... | [
"def",
"register_callback_deleted",
"(",
"self",
",",
"func",
",",
"serialised",
"=",
"True",
")",
":",
"self",
".",
"__add_callback",
"(",
"_CB_DELETED",
",",
"func",
",",
"serialised_if_crud",
"=",
"serialised",
")"
] | Register a callback function to receive QAPI Unsolicited (resource) DELETED. The
callback receives a single argument - the inner message. If `serialised` is not set,
the callbacks might arrive out-of-order. | [
"Register",
"a",
"callback",
"function",
"to",
"receive",
"QAPI",
"Unsolicited",
"(",
"resource",
")",
"DELETED",
".",
"The",
"callback",
"receives",
"a",
"single",
"argument",
"-",
"the",
"inner",
"message",
".",
"If",
"serialised",
"is",
"not",
"set",
"the... | train | https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/Core/Client.py#L325-L330 |
Iotic-Labs/py-IoticAgent | src/IoticAgent/Core/Client.py | Client.register_callback_reassigned | def register_callback_reassigned(self, func, serialised=True):
"""Register a callback function to receive QAPI Unsolicited (entity) REASSIGNED. The
callback receives a single argument - the inner message. If `serialised` is not set,
the callbacks might arrive out-of-order.
"""
se... | python | def register_callback_reassigned(self, func, serialised=True):
"""Register a callback function to receive QAPI Unsolicited (entity) REASSIGNED. The
callback receives a single argument - the inner message. If `serialised` is not set,
the callbacks might arrive out-of-order.
"""
se... | [
"def",
"register_callback_reassigned",
"(",
"self",
",",
"func",
",",
"serialised",
"=",
"True",
")",
":",
"self",
".",
"__add_callback",
"(",
"_CB_REASSIGNED",
",",
"func",
",",
"serialised_if_crud",
"=",
"serialised",
")"
] | Register a callback function to receive QAPI Unsolicited (entity) REASSIGNED. The
callback receives a single argument - the inner message. If `serialised` is not set,
the callbacks might arrive out-of-order. | [
"Register",
"a",
"callback",
"function",
"to",
"receive",
"QAPI",
"Unsolicited",
"(",
"entity",
")",
"REASSIGNED",
".",
"The",
"callback",
"receives",
"a",
"single",
"argument",
"-",
"the",
"inner",
"message",
".",
"If",
"serialised",
"is",
"not",
"set",
"th... | train | https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/Core/Client.py#L332-L337 |
Iotic-Labs/py-IoticAgent | src/IoticAgent/Core/Client.py | Client.simulate_feeddata | def simulate_feeddata(self, feedid, data, mime=None, time=None):
"""Send feed data"""
# Separate public method since internal one does not require parameter checks
feedid = Validation.guid_check_convert(feedid)
mime = Validation.mime_check_convert(mime, allow_none=True)
Validatio... | python | def simulate_feeddata(self, feedid, data, mime=None, time=None):
"""Send feed data"""
# Separate public method since internal one does not require parameter checks
feedid = Validation.guid_check_convert(feedid)
mime = Validation.mime_check_convert(mime, allow_none=True)
Validatio... | [
"def",
"simulate_feeddata",
"(",
"self",
",",
"feedid",
",",
"data",
",",
"mime",
"=",
"None",
",",
"time",
"=",
"None",
")",
":",
"# Separate public method since internal one does not require parameter checks",
"feedid",
"=",
"Validation",
".",
"guid_check_convert",
... | Send feed data | [
"Send",
"feed",
"data"
] | train | https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/Core/Client.py#L393-L399 |
Iotic-Labs/py-IoticAgent | src/IoticAgent/Core/Client.py | Client.start | def start(self): # noqa (complexity)
"""Start the send & recv Threads.
Start can be delayed to EG restore requestIds before attaching to the QAPI
Note: This function waits for/blocks until amqplink connect(s) and the current
sequence number has been obtained from the container (wi... | python | def start(self): # noqa (complexity)
"""Start the send & recv Threads.
Start can be delayed to EG restore requestIds before attaching to the QAPI
Note: This function waits for/blocks until amqplink connect(s) and the current
sequence number has been obtained from the container (wi... | [
"def",
"start",
"(",
"self",
")",
":",
"# noqa (complexity)",
"if",
"not",
"self",
".",
"__end",
".",
"is_set",
"(",
")",
":",
"return",
"self",
".",
"__end",
".",
"clear",
"(",
")",
"try",
":",
"self",
".",
"__network_retry_queue",
"=",
"Queue",
"(",
... | Start the send & recv Threads.
Start can be delayed to EG restore requestIds before attaching to the QAPI
Note: This function waits for/blocks until amqplink connect(s) and the current
sequence number has been obtained from the container (within 5 seconds) | [
"Start",
"the",
"send",
"&",
"recv",
"Threads",
".",
"Start",
"can",
"be",
"delayed",
"to",
"EG",
"restore",
"requestIds",
"before",
"attaching",
"to",
"the",
"QAPI",
"Note",
":",
"This",
"function",
"waits",
"for",
"/",
"blocks",
"until",
"amqplink",
"con... | train | https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/Core/Client.py#L444-L492 |
Iotic-Labs/py-IoticAgent | src/IoticAgent/Core/Client.py | Client.stop | def stop(self):
"""Stop the Client, disconnect from queue
"""
if self.__end.is_set():
return
self.__end.set()
self.__send_retry_requests_timer.cancel()
self.__threadpool.stop()
self.__crud_threadpool.stop()
self.__amqplink.stop()
self._... | python | def stop(self):
"""Stop the Client, disconnect from queue
"""
if self.__end.is_set():
return
self.__end.set()
self.__send_retry_requests_timer.cancel()
self.__threadpool.stop()
self.__crud_threadpool.stop()
self.__amqplink.stop()
self._... | [
"def",
"stop",
"(",
"self",
")",
":",
"if",
"self",
".",
"__end",
".",
"is_set",
"(",
")",
":",
"return",
"self",
".",
"__end",
".",
"set",
"(",
")",
"self",
".",
"__send_retry_requests_timer",
".",
"cancel",
"(",
")",
"self",
".",
"__threadpool",
".... | Stop the Client, disconnect from queue | [
"Stop",
"the",
"Client",
"disconnect",
"from",
"queue"
] | train | https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/Core/Client.py#L516-L540 |
Iotic-Labs/py-IoticAgent | src/IoticAgent/Core/Client.py | Client.set_compression | def set_compression(self, comp=COMP_DEFAULT, size=COMP_SIZE):
"""Override compression method (defined by container) and threshold"""
if comp not in COMPRESSORS:
if comp == COMP_LZ4F:
raise ValueError('lz4f compression not available, required lz4framed')
else:
... | python | def set_compression(self, comp=COMP_DEFAULT, size=COMP_SIZE):
"""Override compression method (defined by container) and threshold"""
if comp not in COMPRESSORS:
if comp == COMP_LZ4F:
raise ValueError('lz4f compression not available, required lz4framed')
else:
... | [
"def",
"set_compression",
"(",
"self",
",",
"comp",
"=",
"COMP_DEFAULT",
",",
"size",
"=",
"COMP_SIZE",
")",
":",
"if",
"comp",
"not",
"in",
"COMPRESSORS",
":",
"if",
"comp",
"==",
"COMP_LZ4F",
":",
"raise",
"ValueError",
"(",
"'lz4f compression not available,... | Override compression method (defined by container) and threshold | [
"Override",
"compression",
"method",
"(",
"defined",
"by",
"container",
")",
"and",
"threshold"
] | train | https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/Core/Client.py#L542-L553 |
Iotic-Labs/py-IoticAgent | src/IoticAgent/Core/Client.py | Client._request | def _request(self, resource, rtype, action=None, payload=None, offset=None, limit=None, requestId=None,
is_crud=False):
"""_request amqp queue publish helper
return: RequestEvent object or None for failed to publish
"""
end = self.__end
if end.is_set():
... | python | def _request(self, resource, rtype, action=None, payload=None, offset=None, limit=None, requestId=None,
is_crud=False):
"""_request amqp queue publish helper
return: RequestEvent object or None for failed to publish
"""
end = self.__end
if end.is_set():
... | [
"def",
"_request",
"(",
"self",
",",
"resource",
",",
"rtype",
",",
"action",
"=",
"None",
",",
"payload",
"=",
"None",
",",
"offset",
"=",
"None",
",",
"limit",
"=",
"None",
",",
"requestId",
"=",
"None",
",",
"is_crud",
"=",
"False",
")",
":",
"e... | _request amqp queue publish helper
return: RequestEvent object or None for failed to publish | [
"_request",
"amqp",
"queue",
"publish",
"helper"
] | train | https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/Core/Client.py#L577-L601 |
Iotic-Labs/py-IoticAgent | src/IoticAgent/Core/Client.py | Client.__send_ready_cb | def __send_ready_cb(self, last_send_failure_time):
"""Callback from AmqpLink on send transport readiness. (Only ever comes from a single thread.)"""
logger.debug('Readiness notification (last failed=%s)', last_send_failure_time)
# It is possible for multiple timers to be scheduled (if multiple t... | python | def __send_ready_cb(self, last_send_failure_time):
"""Callback from AmqpLink on send transport readiness. (Only ever comes from a single thread.)"""
logger.debug('Readiness notification (last failed=%s)', last_send_failure_time)
# It is possible for multiple timers to be scheduled (if multiple t... | [
"def",
"__send_ready_cb",
"(",
"self",
",",
"last_send_failure_time",
")",
":",
"logger",
".",
"debug",
"(",
"'Readiness notification (last failed=%s)'",
",",
"last_send_failure_time",
")",
"# It is possible for multiple timers to be scheduled (if multiple transport failures happen i... | Callback from AmqpLink on send transport readiness. (Only ever comes from a single thread.) | [
"Callback",
"from",
"AmqpLink",
"on",
"send",
"transport",
"readiness",
".",
"(",
"Only",
"ever",
"comes",
"from",
"a",
"single",
"thread",
".",
")"
] | train | https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/Core/Client.py#L617-L626 |
Iotic-Labs/py-IoticAgent | src/IoticAgent/Core/Client.py | Client.__send_retry_requests | def __send_retry_requests(self, last_send_failure_time):
"""Called via Timer from __send_ready to resend requests which might not have been sent due to transport
failure. This can happen since the current transport implementation does not received acknowledgements
for sent messages."""
... | python | def __send_retry_requests(self, last_send_failure_time):
"""Called via Timer from __send_ready to resend requests which might not have been sent due to transport
failure. This can happen since the current transport implementation does not received acknowledgements
for sent messages."""
... | [
"def",
"__send_retry_requests",
"(",
"self",
",",
"last_send_failure_time",
")",
":",
"# make sure multiple failures having set multiple times do not run concurrently",
"with",
"self",
".",
"__send_retry_requests_lock",
":",
"with",
"self",
".",
"__requests",
":",
"# produce li... | Called via Timer from __send_ready to resend requests which might not have been sent due to transport
failure. This can happen since the current transport implementation does not received acknowledgements
for sent messages. | [
"Called",
"via",
"Timer",
"from",
"__send_ready",
"to",
"resend",
"requests",
"which",
"might",
"not",
"have",
"been",
"sent",
"due",
"to",
"transport",
"failure",
".",
"This",
"can",
"happen",
"since",
"the",
"current",
"transport",
"implementation",
"does",
... | train | https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/Core/Client.py#L628-L656 |
Iotic-Labs/py-IoticAgent | src/IoticAgent/Core/Client.py | Client.request_entity_create | def request_entity_create(self, lid, epId=None):
"""request entity create: lid = local name to user
If epId=None (default), the current agent/EP is chosen
If epId=False, no agent is assigned
If epId=guid, said agent is chosen
"""
lid = Validation.lid_check_convert(lid)
... | python | def request_entity_create(self, lid, epId=None):
"""request entity create: lid = local name to user
If epId=None (default), the current agent/EP is chosen
If epId=False, no agent is assigned
If epId=guid, said agent is chosen
"""
lid = Validation.lid_check_convert(lid)
... | [
"def",
"request_entity_create",
"(",
"self",
",",
"lid",
",",
"epId",
"=",
"None",
")",
":",
"lid",
"=",
"Validation",
".",
"lid_check_convert",
"(",
"lid",
")",
"if",
"epId",
"is",
"None",
":",
"epId",
"=",
"self",
".",
"__epId",
"elif",
"epId",
"is",... | request entity create: lid = local name to user
If epId=None (default), the current agent/EP is chosen
If epId=False, no agent is assigned
If epId=guid, said agent is chosen | [
"request",
"entity",
"create",
":",
"lid",
"=",
"local",
"name",
"to",
"user",
"If",
"epId",
"=",
"None",
"(",
"default",
")",
"the",
"current",
"agent",
"/",
"EP",
"is",
"chosen",
"If",
"epId",
"=",
"False",
"no",
"agent",
"is",
"assigned",
"If",
"e... | train | https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/Core/Client.py#L662-L676 |
Iotic-Labs/py-IoticAgent | src/IoticAgent/Core/Client.py | Client.request_entity_reassign | def request_entity_reassign(self, lid, nepId=None):
"""request entity to be reassigned to given ep/agent
If nepId=None (default), the current agent/EP is chosen
If nepId=False, no agent is assigned
If nepId=guid, said agent is chosen
"""
lid = Validation.lid_check_convert... | python | def request_entity_reassign(self, lid, nepId=None):
"""request entity to be reassigned to given ep/agent
If nepId=None (default), the current agent/EP is chosen
If nepId=False, no agent is assigned
If nepId=guid, said agent is chosen
"""
lid = Validation.lid_check_convert... | [
"def",
"request_entity_reassign",
"(",
"self",
",",
"lid",
",",
"nepId",
"=",
"None",
")",
":",
"lid",
"=",
"Validation",
".",
"lid_check_convert",
"(",
"lid",
")",
"if",
"nepId",
"is",
"None",
":",
"nepId",
"=",
"self",
".",
"__epId",
"elif",
"nepId",
... | request entity to be reassigned to given ep/agent
If nepId=None (default), the current agent/EP is chosen
If nepId=False, no agent is assigned
If nepId=guid, said agent is chosen | [
"request",
"entity",
"to",
"be",
"reassigned",
"to",
"given",
"ep",
"/",
"agent",
"If",
"nepId",
"=",
"None",
"(",
"default",
")",
"the",
"current",
"agent",
"/",
"EP",
"is",
"chosen",
"If",
"nepId",
"=",
"False",
"no",
"agent",
"is",
"assigned",
"If",... | train | https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/Core/Client.py#L684-L698 |
Iotic-Labs/py-IoticAgent | src/IoticAgent/Core/Client.py | Client.request_point_create | def request_point_create(self, foc, lid, pid, control_cb=None, save_recent=0):
"""request point create: feed or control, lid and pid point lid
"""
Validation.foc_check(foc)
lid = Validation.lid_check_convert(lid)
pid = Validation.pid_check_convert(pid)
save_recent = valid... | python | def request_point_create(self, foc, lid, pid, control_cb=None, save_recent=0):
"""request point create: feed or control, lid and pid point lid
"""
Validation.foc_check(foc)
lid = Validation.lid_check_convert(lid)
pid = Validation.pid_check_convert(pid)
save_recent = valid... | [
"def",
"request_point_create",
"(",
"self",
",",
"foc",
",",
"lid",
",",
"pid",
",",
"control_cb",
"=",
"None",
",",
"save_recent",
"=",
"0",
")",
":",
"Validation",
".",
"foc_check",
"(",
"foc",
")",
"lid",
"=",
"Validation",
".",
"lid_check_convert",
"... | request point create: feed or control, lid and pid point lid | [
"request",
"point",
"create",
":",
"feed",
"or",
"control",
"lid",
"and",
"pid",
"point",
"lid"
] | train | https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/Core/Client.py#L742-L762 |
Iotic-Labs/py-IoticAgent | src/IoticAgent/Core/Client.py | Client.__point_data_to_bytes | def __point_data_to_bytes(self, data, mime=None): # pylint: disable=too-many-branches
"""Returns tuple of mime type & data. Auto encodes unicode strings (to utf8) and
dictionaries (to ubjson) depending on client setting."""
if mime is None:
if self.__auto_encode_decode:
... | python | def __point_data_to_bytes(self, data, mime=None): # pylint: disable=too-many-branches
"""Returns tuple of mime type & data. Auto encodes unicode strings (to utf8) and
dictionaries (to ubjson) depending on client setting."""
if mime is None:
if self.__auto_encode_decode:
... | [
"def",
"__point_data_to_bytes",
"(",
"self",
",",
"data",
",",
"mime",
"=",
"None",
")",
":",
"# pylint: disable=too-many-branches",
"if",
"mime",
"is",
"None",
":",
"if",
"self",
".",
"__auto_encode_decode",
":",
"if",
"isinstance",
"(",
"data",
",",
"bytes",... | Returns tuple of mime type & data. Auto encodes unicode strings (to utf8) and
dictionaries (to ubjson) depending on client setting. | [
"Returns",
"tuple",
"of",
"mime",
"type",
"&",
"data",
".",
"Auto",
"encodes",
"unicode",
"strings",
"(",
"to",
"utf8",
")",
"and",
"dictionaries",
"(",
"to",
"ubjson",
")",
"depending",
"on",
"client",
"setting",
"."
] | train | https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/Core/Client.py#L931-L958 |
Iotic-Labs/py-IoticAgent | src/IoticAgent/Core/Client.py | Client.__bytes_to_share_data | def __bytes_to_share_data(self, payload):
"""Attempt to auto-decode data"""
rbytes = payload[P_DATA]
mime = payload[P_MIME]
if mime is None or not self.__auto_encode_decode:
return rbytes, mime
mime = expand_idx_mimetype(mime).lower()
try:
if mime... | python | def __bytes_to_share_data(self, payload):
"""Attempt to auto-decode data"""
rbytes = payload[P_DATA]
mime = payload[P_MIME]
if mime is None or not self.__auto_encode_decode:
return rbytes, mime
mime = expand_idx_mimetype(mime).lower()
try:
if mime... | [
"def",
"__bytes_to_share_data",
"(",
"self",
",",
"payload",
")",
":",
"rbytes",
"=",
"payload",
"[",
"P_DATA",
"]",
"mime",
"=",
"payload",
"[",
"P_MIME",
"]",
"if",
"mime",
"is",
"None",
"or",
"not",
"self",
".",
"__auto_encode_decode",
":",
"return",
... | Attempt to auto-decode data | [
"Attempt",
"to",
"auto",
"-",
"decode",
"data"
] | train | https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/Core/Client.py#L960-L977 |
Iotic-Labs/py-IoticAgent | src/IoticAgent/Core/Client.py | Client.__new_request_id | def __new_request_id(self):
"""requestId follows form "pre num" where pre is some random ascii prefix EG 6 chars long
and num is an ever increasing number (self.__reqnum). MUST be called within self.__requests lock
"""
while True:
# Since seqnum wraps on 2^64 at most, this sh... | python | def __new_request_id(self):
"""requestId follows form "pre num" where pre is some random ascii prefix EG 6 chars long
and num is an ever increasing number (self.__reqnum). MUST be called within self.__requests lock
"""
while True:
# Since seqnum wraps on 2^64 at most, this sh... | [
"def",
"__new_request_id",
"(",
"self",
")",
":",
"while",
"True",
":",
"# Since seqnum wraps on 2^64 at most, this should always fit into 32 chars (QAPI request id limit)",
"with",
"self",
".",
"__seqnum_lock",
":",
"requestId",
"=",
"\"%s%d\"",
"%",
"(",
"self",
".",
"_... | requestId follows form "pre num" where pre is some random ascii prefix EG 6 chars long
and num is an ever increasing number (self.__reqnum). MUST be called within self.__requests lock | [
"requestId",
"follows",
"form",
"pre",
"num",
"where",
"pre",
"is",
"some",
"random",
"ascii",
"prefix",
"EG",
"6",
"chars",
"long",
"and",
"num",
"is",
"an",
"ever",
"increasing",
"number",
"(",
"self",
".",
"__reqnum",
")",
".",
"MUST",
"be",
"called",... | train | https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/Core/Client.py#L1050-L1063 |
Iotic-Labs/py-IoticAgent | src/IoticAgent/Core/Client.py | Client.__make_hash | def __make_hash(cls, innermsg, token, seqnum):
"""return the hash for this innermsg, token, seqnum
return digest bytes
"""
hobj = hmacNew(token, digestmod=hashfunc)
hobj.update(innermsg)
hobj.update(cls.__byte_packer(seqnum))
return hobj.digest() | python | def __make_hash(cls, innermsg, token, seqnum):
"""return the hash for this innermsg, token, seqnum
return digest bytes
"""
hobj = hmacNew(token, digestmod=hashfunc)
hobj.update(innermsg)
hobj.update(cls.__byte_packer(seqnum))
return hobj.digest() | [
"def",
"__make_hash",
"(",
"cls",
",",
"innermsg",
",",
"token",
",",
"seqnum",
")",
":",
"hobj",
"=",
"hmacNew",
"(",
"token",
",",
"digestmod",
"=",
"hashfunc",
")",
"hobj",
".",
"update",
"(",
"innermsg",
")",
"hobj",
".",
"update",
"(",
"cls",
".... | return the hash for this innermsg, token, seqnum
return digest bytes | [
"return",
"the",
"hash",
"for",
"this",
"innermsg",
"token",
"seqnum",
"return",
"digest",
"bytes"
] | train | https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/Core/Client.py#L1069-L1076 |
Iotic-Labs/py-IoticAgent | src/IoticAgent/Core/Client.py | Client.__check_hash | def __check_hash(self, message):
"""return true/false if hash is good
message = dict
"""
return message[W_HASH] == self.__make_hash(message[W_MESSAGE], self.__token, message[W_SEQ]) | python | def __check_hash(self, message):
"""return true/false if hash is good
message = dict
"""
return message[W_HASH] == self.__make_hash(message[W_MESSAGE], self.__token, message[W_SEQ]) | [
"def",
"__check_hash",
"(",
"self",
",",
"message",
")",
":",
"return",
"message",
"[",
"W_HASH",
"]",
"==",
"self",
".",
"__make_hash",
"(",
"message",
"[",
"W_MESSAGE",
"]",
",",
"self",
".",
"__token",
",",
"message",
"[",
"W_SEQ",
"]",
")"
] | return true/false if hash is good
message = dict | [
"return",
"true",
"/",
"false",
"if",
"hash",
"is",
"good",
"message",
"=",
"dict"
] | train | https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/Core/Client.py#L1078-L1082 |
Iotic-Labs/py-IoticAgent | src/IoticAgent/Core/Client.py | Client.__make_innermsg | def __make_innermsg(resource, rtype, ref, action=None, payload=None, limit=None):
"""return innermsg chunk (dict)
"""
if action is not None and not isinstance(action, (tuple, list)):
raise TypeError('action must be None/tuple/list')
p = {M_RESOURCE: resource,
M_T... | python | def __make_innermsg(resource, rtype, ref, action=None, payload=None, limit=None):
"""return innermsg chunk (dict)
"""
if action is not None and not isinstance(action, (tuple, list)):
raise TypeError('action must be None/tuple/list')
p = {M_RESOURCE: resource,
M_T... | [
"def",
"__make_innermsg",
"(",
"resource",
",",
"rtype",
",",
"ref",
",",
"action",
"=",
"None",
",",
"payload",
"=",
"None",
",",
"limit",
"=",
"None",
")",
":",
"if",
"action",
"is",
"not",
"None",
"and",
"not",
"isinstance",
"(",
"action",
",",
"(... | return innermsg chunk (dict) | [
"return",
"innermsg",
"chunk",
"(",
"dict",
")"
] | train | https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/Core/Client.py#L1085-L1098 |
Iotic-Labs/py-IoticAgent | src/IoticAgent/Core/Client.py | Client.__request_except | def __request_except(self, requestId, exc, set_and_forget=True):
"""Set exception (if not None) for the given request and (optionally) remove from internal cache & setting its
event"""
try:
with self.__requests:
if set_and_forget:
req = self.__r... | python | def __request_except(self, requestId, exc, set_and_forget=True):
"""Set exception (if not None) for the given request and (optionally) remove from internal cache & setting its
event"""
try:
with self.__requests:
if set_and_forget:
req = self.__r... | [
"def",
"__request_except",
"(",
"self",
",",
"requestId",
",",
"exc",
",",
"set_and_forget",
"=",
"True",
")",
":",
"try",
":",
"with",
"self",
".",
"__requests",
":",
"if",
"set_and_forget",
":",
"req",
"=",
"self",
".",
"__requests",
".",
"pop",
"(",
... | Set exception (if not None) for the given request and (optionally) remove from internal cache & setting its
event | [
"Set",
"exception",
"(",
"if",
"not",
"None",
")",
"for",
"the",
"given",
"request",
"and",
"(",
"optionally",
")",
"remove",
"from",
"internal",
"cache",
"&",
"setting",
"its",
"event"
] | train | https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/Core/Client.py#L1100-L1115 |
Iotic-Labs/py-IoticAgent | src/IoticAgent/Core/Client.py | Client.__request_mark_sent | def __request_mark_sent(self, requestId):
"""Set send time & clear exception from request if set, ignoring non-existent requests"""
with self.__requests:
try:
req = self.__requests[requestId]
except KeyError:
# request might have had a response alr... | python | def __request_mark_sent(self, requestId):
"""Set send time & clear exception from request if set, ignoring non-existent requests"""
with self.__requests:
try:
req = self.__requests[requestId]
except KeyError:
# request might have had a response alr... | [
"def",
"__request_mark_sent",
"(",
"self",
",",
"requestId",
")",
":",
"with",
"self",
".",
"__requests",
":",
"try",
":",
"req",
"=",
"self",
".",
"__requests",
"[",
"requestId",
"]",
"except",
"KeyError",
":",
"# request might have had a response already have be... | Set send time & clear exception from request if set, ignoring non-existent requests | [
"Set",
"send",
"time",
"&",
"clear",
"exception",
"from",
"request",
"if",
"set",
"ignoring",
"non",
"-",
"existent",
"requests"
] | train | https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/Core/Client.py#L1117-L1127 |
Iotic-Labs/py-IoticAgent | src/IoticAgent/Core/Client.py | Client.__publish | def __publish(self, qmsg):
"""Returns True unless sending failed (at which point an exception will have been set in the request)"""
with self.__seqnum_lock:
seqnum = self.__seqnum
self.__seqnum = (self.__seqnum + 1) % _SEQ_WRAP_SIZE
#
innermsg = ubjdumpb(qmsg.inne... | python | def __publish(self, qmsg):
"""Returns True unless sending failed (at which point an exception will have been set in the request)"""
with self.__seqnum_lock:
seqnum = self.__seqnum
self.__seqnum = (self.__seqnum + 1) % _SEQ_WRAP_SIZE
#
innermsg = ubjdumpb(qmsg.inne... | [
"def",
"__publish",
"(",
"self",
",",
"qmsg",
")",
":",
"with",
"self",
".",
"__seqnum_lock",
":",
"seqnum",
"=",
"self",
".",
"__seqnum",
"self",
".",
"__seqnum",
"=",
"(",
"self",
".",
"__seqnum",
"+",
"1",
")",
"%",
"_SEQ_WRAP_SIZE",
"#",
"innermsg"... | Returns True unless sending failed (at which point an exception will have been set in the request) | [
"Returns",
"True",
"unless",
"sending",
"failed",
"(",
"at",
"which",
"point",
"an",
"exception",
"will",
"have",
"been",
"set",
"in",
"the",
"request",
")"
] | train | https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/Core/Client.py#L1129-L1165 |
Iotic-Labs/py-IoticAgent | src/IoticAgent/Core/Client.py | Client.__fire_callback | def __fire_callback(self, type_, *args, **kwargs):
"""Returns True if at least one callback was called"""
called = False
plain_submit = self.__threadpool.submit
with self.__callbacks:
submit = self.__crud_threadpool.submit if type_ in _CB_CRUD_TYPES else plain_submit
... | python | def __fire_callback(self, type_, *args, **kwargs):
"""Returns True if at least one callback was called"""
called = False
plain_submit = self.__threadpool.submit
with self.__callbacks:
submit = self.__crud_threadpool.submit if type_ in _CB_CRUD_TYPES else plain_submit
... | [
"def",
"__fire_callback",
"(",
"self",
",",
"type_",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"called",
"=",
"False",
"plain_submit",
"=",
"self",
".",
"__threadpool",
".",
"submit",
"with",
"self",
".",
"__callbacks",
":",
"submit",
"=",
"... | Returns True if at least one callback was called | [
"Returns",
"True",
"if",
"at",
"least",
"one",
"callback",
"was",
"called"
] | train | https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/Core/Client.py#L1225-L1235 |
Iotic-Labs/py-IoticAgent | src/IoticAgent/Core/Client.py | Client.__validate_decode_msg | def __validate_decode_msg(self, message): # noqa (complexity) pylint: disable=too-many-return-statements,too-many-branches
"""Decodes wrapper, check hash & seq, decodes body. Returns body or None, if validation / unpack failed"""
try:
if not _CONTENT_TYPE_PATTERN.match(message.content_type)... | python | def __validate_decode_msg(self, message): # noqa (complexity) pylint: disable=too-many-return-statements,too-many-branches
"""Decodes wrapper, check hash & seq, decodes body. Returns body or None, if validation / unpack failed"""
try:
if not _CONTENT_TYPE_PATTERN.match(message.content_type)... | [
"def",
"__validate_decode_msg",
"(",
"self",
",",
"message",
")",
":",
"# noqa (complexity) pylint: disable=too-many-return-statements,too-many-branches",
"try",
":",
"if",
"not",
"_CONTENT_TYPE_PATTERN",
".",
"match",
"(",
"message",
".",
"content_type",
")",
":",
"logge... | Decodes wrapper, check hash & seq, decodes body. Returns body or None, if validation / unpack failed | [
"Decodes",
"wrapper",
"check",
"hash",
"&",
"seq",
"decodes",
"body",
".",
"Returns",
"body",
"or",
"None",
"if",
"validation",
"/",
"unpack",
"failed"
] | train | https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/Core/Client.py#L1267-L1322 |
Iotic-Labs/py-IoticAgent | src/IoticAgent/Core/Client.py | Client.__dispatch_msg | def __dispatch_msg(self, message):
"""Verify the signature and update RequestEvents / perform callbacks
Note messages with an invalid wrapper, invalid hash, invalid sequence number or unexpected clientRef
will be sent to debug_bad callback.
"""
msg = self.__validate_decode_msg(m... | python | def __dispatch_msg(self, message):
"""Verify the signature and update RequestEvents / perform callbacks
Note messages with an invalid wrapper, invalid hash, invalid sequence number or unexpected clientRef
will be sent to debug_bad callback.
"""
msg = self.__validate_decode_msg(m... | [
"def",
"__dispatch_msg",
"(",
"self",
",",
"message",
")",
":",
"msg",
"=",
"self",
".",
"__validate_decode_msg",
"(",
"message",
")",
"if",
"msg",
":",
"msg",
",",
"seqnum",
"=",
"msg",
"else",
":",
"self",
".",
"__fire_callback",
"(",
"_CB_DEBUG_BAD",
... | Verify the signature and update RequestEvents / perform callbacks
Note messages with an invalid wrapper, invalid hash, invalid sequence number or unexpected clientRef
will be sent to debug_bad callback. | [
"Verify",
"the",
"signature",
"and",
"update",
"RequestEvents",
"/",
"perform",
"callbacks"
] | train | https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/Core/Client.py#L1324-L1356 |
Iotic-Labs/py-IoticAgent | src/IoticAgent/Core/Client.py | Client.__handle_known_solicited | def __handle_known_solicited(self, msg):
"""returns True if message has been handled as a solicited response"""
with self.__requests:
try:
req = self.__requests[msg[M_CLIENTREF]]
except KeyError:
return False
if self.__handle_low_seq_r... | python | def __handle_known_solicited(self, msg):
"""returns True if message has been handled as a solicited response"""
with self.__requests:
try:
req = self.__requests[msg[M_CLIENTREF]]
except KeyError:
return False
if self.__handle_low_seq_r... | [
"def",
"__handle_known_solicited",
"(",
"self",
",",
"msg",
")",
":",
"with",
"self",
".",
"__requests",
":",
"try",
":",
"req",
"=",
"self",
".",
"__requests",
"[",
"msg",
"[",
"M_CLIENTREF",
"]",
"]",
"except",
"KeyError",
":",
"return",
"False",
"if",... | returns True if message has been handled as a solicited response | [
"returns",
"True",
"if",
"message",
"has",
"been",
"handled",
"as",
"a",
"solicited",
"response"
] | train | https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/Core/Client.py#L1358-L1398 |
Iotic-Labs/py-IoticAgent | src/IoticAgent/Core/Client.py | Client.__clear_references | def __clear_references(self, request, remove_request=True):
"""Remove any internal references to the given request"""
# remove request itself
if remove_request:
with self.__requests:
self.__requests.pop(request.id_)
# remove request type specific references
... | python | def __clear_references(self, request, remove_request=True):
"""Remove any internal references to the given request"""
# remove request itself
if remove_request:
with self.__requests:
self.__requests.pop(request.id_)
# remove request type specific references
... | [
"def",
"__clear_references",
"(",
"self",
",",
"request",
",",
"remove_request",
"=",
"True",
")",
":",
"# remove request itself",
"if",
"remove_request",
":",
"with",
"self",
".",
"__requests",
":",
"self",
".",
"__requests",
".",
"pop",
"(",
"request",
".",
... | Remove any internal references to the given request | [
"Remove",
"any",
"internal",
"references",
"to",
"the",
"given",
"request"
] | train | https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/Core/Client.py#L1400-L1411 |
Iotic-Labs/py-IoticAgent | src/IoticAgent/Core/Client.py | Client.__update_existing | def __update_existing(self, msg, req):
"""Propagate changes based on type of message. MUST be called within self.__requests lock. Performs additional
actions when solicited messages arrive."""
req._messages.append(msg)
payload = msg[M_PAYLOAD]
if msg[M_TYPE] in _RSP_TYPE_CREA... | python | def __update_existing(self, msg, req):
"""Propagate changes based on type of message. MUST be called within self.__requests lock. Performs additional
actions when solicited messages arrive."""
req._messages.append(msg)
payload = msg[M_PAYLOAD]
if msg[M_TYPE] in _RSP_TYPE_CREA... | [
"def",
"__update_existing",
"(",
"self",
",",
"msg",
",",
"req",
")",
":",
"req",
".",
"_messages",
".",
"append",
"(",
"msg",
")",
"payload",
"=",
"msg",
"[",
"M_PAYLOAD",
"]",
"if",
"msg",
"[",
"M_TYPE",
"]",
"in",
"_RSP_TYPE_CREATION",
":",
"if",
... | Propagate changes based on type of message. MUST be called within self.__requests lock. Performs additional
actions when solicited messages arrive. | [
"Propagate",
"changes",
"based",
"on",
"type",
"of",
"message",
".",
"MUST",
"be",
"called",
"within",
"self",
".",
"__requests",
"lock",
".",
"Performs",
"additional",
"actions",
"when",
"solicited",
"messages",
"arrive",
"."
] | train | https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/Core/Client.py#L1413-L1444 |
Iotic-Labs/py-IoticAgent | src/IoticAgent/Core/Client.py | Client.__handle_low_seq_resend | 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... | python | 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... | [
"def",
"__handle_low_seq_resend",
"(",
"self",
",",
"msg",
",",
"req",
")",
":",
"if",
"msg",
"[",
"M_TYPE",
"]",
"==",
"E_FAILED",
"and",
"msg",
"[",
"M_PAYLOAD",
"]",
"[",
"P_CODE",
"]",
"==",
"E_FAILED_CODE_LOWSEQNUM",
":",
"with",
"self",
".",
"__seq... | 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. | [
"special",
"error",
"case",
"-",
"low",
"sequence",
"number",
"(",
"update",
"sequence",
"number",
"&",
"resend",
"if",
"applicable",
")",
".",
"Returns",
"True",
"if",
"a",
"resend",
"was",
"scheduled",
"False",
"otherwise",
".",
"MUST",
"be",
"called",
"... | train | https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/Core/Client.py#L1446-L1455 |
Iotic-Labs/py-IoticAgent | src/IoticAgent/Core/Client.py | Client.__decode_data_time | 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... | python | 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... | [
"def",
"__decode_data_time",
"(",
"self",
",",
"payload",
")",
":",
"data",
",",
"mime",
"=",
"self",
".",
"__bytes_to_share_data",
"(",
"payload",
")",
"try",
":",
"time",
"=",
"datetime",
".",
"strptime",
"(",
"payload",
".",
"get",
"(",
"P_TIME",
")",... | Extract time and decode payload (based on mime type) from payload. Applies to E_FEEDDATA and E_RECENTDATA.
Returns tuple of data, mime, time. | [
"Extract",
"time",
"and",
"decode",
"payload",
"(",
"based",
"on",
"mime",
"type",
")",
"from",
"payload",
".",
"Applies",
"to",
"E_FEEDDATA",
"and",
"E_RECENTDATA",
".",
"Returns",
"tuple",
"of",
"data",
"mime",
"time",
"."
] | train | https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/Core/Client.py#L1459-L1469 |
Iotic-Labs/py-IoticAgent | src/IoticAgent/Core/Client.py | Client.__perform_unsolicited_callbacks | 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... | python | 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... | [
"def",
"__perform_unsolicited_callbacks",
"(",
"self",
",",
"msg",
")",
":",
"type_",
"=",
"msg",
"[",
"M_TYPE",
"]",
"payload",
"=",
"msg",
"[",
"M_PAYLOAD",
"]",
"# callbacks for responses which might be unsolicited (e.g. created or deleted)",
"if",
"type_",
"in",
"... | Callbacks for which a client reference is either optional or does not apply at all | [
"Callbacks",
"for",
"which",
"a",
"client",
"reference",
"is",
"either",
"optional",
"or",
"does",
"not",
"apply",
"at",
"all"
] | train | https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/Core/Client.py#L1471-L1489 |
tophatmonocle/ims_lti_py | ims_lti_py/launch_params.py | LaunchParamsMixin.roles | 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... | python | 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... | [
"def",
"roles",
"(",
"self",
",",
"roles_list",
")",
":",
"if",
"roles_list",
"and",
"isinstance",
"(",
"roles_list",
",",
"list",
")",
":",
"self",
".",
"roles",
"=",
"[",
"]",
".",
"extend",
"(",
"roles_list",
")",
"elif",
"roles_list",
"and",
"isins... | 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
* ... | [
"Set",
"the",
"roles",
"for",
"the",
"current",
"launch",
"."
] | train | https://github.com/tophatmonocle/ims_lti_py/blob/979244d83c2e6420d2c1941f58e52f641c56ad12/ims_lti_py/launch_params.py#L71-L97 |
tophatmonocle/ims_lti_py | ims_lti_py/launch_params.py | LaunchParamsMixin.process_params | 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 !=... | python | 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 !=... | [
"def",
"process_params",
"(",
"self",
",",
"params",
")",
":",
"for",
"key",
",",
"val",
"in",
"params",
".",
"items",
"(",
")",
":",
"if",
"key",
"in",
"LAUNCH_DATA_PARAMETERS",
"and",
"val",
"!=",
"'None'",
":",
"if",
"key",
"==",
"'roles'",
":",
"... | Populates the launch data from a dictionary. Only cares about keys in
the LAUNCH_DATA_PARAMETERS list, or that start with 'custom_' or
'ext_'. | [
"Populates",
"the",
"launch",
"data",
"from",
"a",
"dictionary",
".",
"Only",
"cares",
"about",
"keys",
"in",
"the",
"LAUNCH_DATA_PARAMETERS",
"list",
"or",
"that",
"start",
"with",
"custom_",
"or",
"ext_",
"."
] | train | https://github.com/tophatmonocle/ims_lti_py/blob/979244d83c2e6420d2c1941f58e52f641c56ad12/ims_lti_py/launch_params.py#L99-L119 |
tophatmonocle/ims_lti_py | ims_lti_py/launch_params.py | LaunchParamsMixin.to_params | 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... | python | 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... | [
"def",
"to_params",
"(",
"self",
")",
":",
"params",
"=",
"{",
"}",
"custom_params",
"=",
"{",
"}",
"for",
"key",
"in",
"self",
".",
"custom_params",
":",
"custom_params",
"[",
"key",
"]",
"=",
"self",
".",
"custom_params",
"[",
"key",
"]",
"ext_params... | Createa a new dictionary with all launch data. Custom / Extension keys
will be included. Roles are set as a ',' separated string. | [
"Createa",
"a",
"new",
"dictionary",
"with",
"all",
"launch",
"data",
".",
"Custom",
"/",
"Extension",
"keys",
"will",
"be",
"included",
".",
"Roles",
"are",
"set",
"as",
"a",
"separated",
"string",
"."
] | train | https://github.com/tophatmonocle/ims_lti_py/blob/979244d83c2e6420d2c1941f58e52f641c56ad12/ims_lti_py/launch_params.py#L139-L156 |
Iotic-Labs/py-IoticAgent | src/IoticAgent/third/amqp/serialization.py | AMQPWriter.write_longstr | 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) | python | 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) | [
"def",
"write_longstr",
"(",
"self",
",",
"s",
")",
":",
"self",
".",
"_flushbits",
"(",
")",
"if",
"isinstance",
"(",
"s",
",",
"text_t",
")",
":",
"s",
"=",
"s",
".",
"encode",
"(",
"'utf-8'",
")",
"self",
".",
"write_long",
"(",
"len",
"(",
"s... | Write a string up to 2**32 bytes long after encoding.
If passed a unicode string, encode as UTF-8. | [
"Write",
"a",
"string",
"up",
"to",
"2",
"**",
"32",
"bytes",
"long",
"after",
"encoding",
"."
] | train | https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/third/amqp/serialization.py#L330-L340 |
Iotic-Labs/py-IoticAgent | src/IoticAgent/ThingRunner.py | ThingRunner.run | 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.... | python | 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.... | [
"def",
"run",
"(",
"self",
",",
"background",
"=",
"False",
")",
":",
"if",
"self",
".",
"__bgthread",
":",
"raise",
"Exception",
"(",
"'run has already been called (since last stop)'",
")",
"self",
".",
"__shutdown",
".",
"clear",
"(",
")",
"if",
"background"... | Runs `on_startup`, `main` and `on_shutdown`, blocking until finished, unless background is set. | [
"Runs",
"on_startup",
"main",
"and",
"on_shutdown",
"blocking",
"until",
"finished",
"unless",
"background",
"is",
"set",
"."
] | train | https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/ThingRunner.py#L73-L83 |
Iotic-Labs/py-IoticAgent | src/IoticAgent/ThingRunner.py | ThingRunner.stop | 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... | python | 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... | [
"def",
"stop",
"(",
"self",
",",
"timeout",
"=",
"None",
")",
":",
"stopped",
"=",
"True",
"self",
".",
"__shutdown",
".",
"set",
"(",
")",
"if",
"self",
".",
"__bgthread",
":",
"logger",
".",
"debug",
"(",
"'Stopping bgthread'",
")",
"self",
".",
"_... | 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). | [
"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",
".... | train | https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/ThingRunner.py#L151-L164 |
HumanCellAtlas/dcplib | dcplib/aws/sqs_handler.py | SQSHandler.add_message_to_queue | 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}... | python | 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}... | [
"def",
"add_message_to_queue",
"(",
"self",
",",
"payload",
",",
"*",
"*",
"attributes",
")",
":",
"return",
"self",
".",
"queue",
".",
"send_message",
"(",
"MessageBody",
"=",
"json",
".",
"dumps",
"(",
"payload",
")",
",",
"MessageAttributes",
"=",
"{",
... | Given a payload (a dict) and any optional message attributes (also a dict), add it to the queue. | [
"Given",
"a",
"payload",
"(",
"a",
"dict",
")",
"and",
"any",
"optional",
"message",
"attributes",
"(",
"also",
"a",
"dict",
")",
"add",
"it",
"to",
"the",
"queue",
"."
] | train | https://github.com/HumanCellAtlas/dcplib/blob/23614d39914a6b5fc278e732030674a2956a0767/dcplib/aws/sqs_handler.py#L20-L24 |
HumanCellAtlas/dcplib | dcplib/aws/sqs_handler.py | SQSHandler.receive_messages_from_queue | 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) | python | 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) | [
"def",
"receive_messages_from_queue",
"(",
"self",
",",
"wait_time",
"=",
"15",
",",
"num_messages",
"=",
"1",
")",
":",
"return",
"self",
".",
"queue",
".",
"receive_messages",
"(",
"MaxNumberOfMessages",
"=",
"num_messages",
",",
"WaitTimeSeconds",
"=",
"wait_... | Returns the first (according to FIFO) element in the queue; if none, then returns None. | [
"Returns",
"the",
"first",
"(",
"according",
"to",
"FIFO",
")",
"element",
"in",
"the",
"queue",
";",
"if",
"none",
"then",
"returns",
"None",
"."
] | train | https://github.com/HumanCellAtlas/dcplib/blob/23614d39914a6b5fc278e732030674a2956a0767/dcplib/aws/sqs_handler.py#L26-L30 |
Iotic-Labs/py-IoticAgent | src/IoticAgent/Units.py | Units.save_json | 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(), ... | python | 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(), ... | [
"def",
"save_json",
"(",
"self",
",",
"jsonfn",
"=",
"None",
",",
"pretty",
"=",
"True",
")",
":",
"if",
"jsonfn",
"is",
"None",
":",
"jsonfn",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"getcwd",
"(",
")",
",",
"'units.json'",
")",
"#"... | 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 | [
"Write",
"a",
".",
"json",
"file",
"with",
"the",
"units",
"tree",
"jsonfn",
"=",
"path",
"/",
"file",
".",
"name",
"default",
"os",
".",
"getcwd",
"()",
"+",
"units",
".",
"json",
"pretty",
"=",
"True",
"use",
"JSON",
"dumps",
"pretty",
"print",
"fo... | train | https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/Units.py#L210-L229 |
edx/edx-django-utils | edx_django_utils/monitoring/middleware.py | MonitoringCustomMetricsMiddleware.accumulate_metric | 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) | python | 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) | [
"def",
"accumulate_metric",
"(",
"cls",
",",
"name",
",",
"value",
")",
":",
"metrics_cache",
"=",
"cls",
".",
"_get_metrics_cache",
"(",
")",
"metrics_cache",
".",
"setdefault",
"(",
"name",
",",
"0",
")",
"metrics_cache",
".",
"set",
"(",
"name",
",",
... | Accumulate a custom metric (name and value) in the metrics cache. | [
"Accumulate",
"a",
"custom",
"metric",
"(",
"name",
"and",
"value",
")",
"in",
"the",
"metrics",
"cache",
"."
] | train | https://github.com/edx/edx-django-utils/blob/16cb4ac617e53c572bf68ccd19d24afeff1ca769/edx_django_utils/monitoring/middleware.py#L57-L63 |
edx/edx-django-utils | edx_django_utils/monitoring/middleware.py | MonitoringCustomMetricsMiddleware._batch_report | 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... | python | 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... | [
"def",
"_batch_report",
"(",
"cls",
",",
"request",
")",
":",
"if",
"not",
"newrelic",
":",
"return",
"metrics_cache",
"=",
"cls",
".",
"_get_metrics_cache",
"(",
")",
"try",
":",
"newrelic",
".",
"agent",
".",
"add_custom_parameter",
"(",
"'user_id'",
",",
... | Report the collected custom metrics to New Relic. | [
"Report",
"the",
"collected",
"custom",
"metrics",
"to",
"New",
"Relic",
"."
] | train | https://github.com/edx/edx-django-utils/blob/16cb4ac617e53c572bf68ccd19d24afeff1ca769/edx_django_utils/monitoring/middleware.py#L66-L78 |
edx/edx-django-utils | edx_django_utils/monitoring/middleware.py | MonitoringMemoryMiddleware.process_request | 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... | python | 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... | [
"def",
"process_request",
"(",
"self",
",",
"request",
")",
":",
"if",
"self",
".",
"_is_enabled",
"(",
")",
":",
"self",
".",
"_cache",
".",
"set",
"(",
"self",
".",
"guid_key",
",",
"six",
".",
"text_type",
"(",
"uuid4",
"(",
")",
")",
")",
"log_... | Store memory data to log later. | [
"Store",
"memory",
"data",
"to",
"log",
"later",
"."
] | train | https://github.com/edx/edx-django-utils/blob/16cb4ac617e53c572bf68ccd19d24afeff1ca769/edx_django_utils/monitoring/middleware.py#L115-L122 |
edx/edx-django-utils | edx_django_utils/monitoring/middleware.py | MonitoringMemoryMiddleware.process_response | 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"... | python | 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"... | [
"def",
"process_response",
"(",
"self",
",",
"request",
",",
"response",
")",
":",
"if",
"self",
".",
"_is_enabled",
"(",
")",
":",
"log_prefix",
"=",
"self",
".",
"_log_prefix",
"(",
"u\"After\"",
",",
"request",
")",
"new_memory_data",
"=",
"self",
".",
... | Logs memory data after processing response. | [
"Logs",
"memory",
"data",
"after",
"processing",
"response",
"."
] | train | https://github.com/edx/edx-django-utils/blob/16cb4ac617e53c572bf68ccd19d24afeff1ca769/edx_django_utils/monitoring/middleware.py#L124-L136 |
edx/edx-django-utils | edx_django_utils/monitoring/middleware.py | MonitoringMemoryMiddleware._log_prefix | 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... | python | 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... | [
"def",
"_log_prefix",
"(",
"self",
",",
"prefix",
",",
"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 the request cache when process_response exec... | Returns a formatted prefix for logging for the given request. | [
"Returns",
"a",
"formatted",
"prefix",
"for",
"logging",
"for",
"the",
"given",
"request",
"."
] | train | https://github.com/edx/edx-django-utils/blob/16cb4ac617e53c572bf68ccd19d24afeff1ca769/edx_django_utils/monitoring/middleware.py#L145-L154 |
edx/edx-django-utils | edx_django_utils/monitoring/middleware.py | MonitoringMemoryMiddleware._memory_data | 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... | python | 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... | [
"def",
"_memory_data",
"(",
"self",
",",
"log_prefix",
")",
":",
"machine_data",
"=",
"psutil",
".",
"virtual_memory",
"(",
")",
"process",
"=",
"psutil",
".",
"Process",
"(",
")",
"process_data",
"=",
"{",
"'memory_info'",
":",
"process",
".",
"get_memory_i... | Returns a dict with information for current memory utilization.
Uses log_prefix in log statements. | [
"Returns",
"a",
"dict",
"with",
"information",
"for",
"current",
"memory",
"utilization",
".",
"Uses",
"log_prefix",
"in",
"log",
"statements",
"."
] | train | https://github.com/edx/edx-django-utils/blob/16cb4ac617e53c572bf68ccd19d24afeff1ca769/edx_django_utils/monitoring/middleware.py#L156-L175 |
edx/edx-django-utils | edx_django_utils/monitoring/middleware.py | MonitoringMemoryMiddleware._log_diff_memory_data | 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... | python | 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... | [
"def",
"_log_diff_memory_data",
"(",
"self",
",",
"prefix",
",",
"new_memory_data",
",",
"old_memory_data",
")",
":",
"def",
"_vmem_used",
"(",
"memory_data",
")",
":",
"return",
"memory_data",
"[",
"'machine_data'",
"]",
".",
"used",
"def",
"_process_mem_percent"... | Computes and logs the difference in memory utilization
between the given old and new memory data. | [
"Computes",
"and",
"logs",
"the",
"difference",
"in",
"memory",
"utilization",
"between",
"the",
"given",
"old",
"and",
"new",
"memory",
"data",
"."
] | train | https://github.com/edx/edx-django-utils/blob/16cb4ac617e53c572bf68ccd19d24afeff1ca769/edx_django_utils/monitoring/middleware.py#L177-L202 |
edx/edx-django-utils | edx_django_utils/cache/utils.py | _RequestCache.data | 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... | python | 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... | [
"def",
"data",
"(",
"self",
",",
"namespace",
")",
":",
"assert",
"namespace",
"if",
"namespace",
"in",
"self",
".",
"_data",
":",
"return",
"self",
".",
"_data",
"[",
"namespace",
"]",
"new_data",
"=",
"{",
"}",
"self",
".",
"_data",
"[",
"namespace",... | Gets the thread.local data (dict) for a given namespace.
Args:
namespace (string): The namespace, or key, of the data dict.
Returns:
(dict) | [
"Gets",
"the",
"thread",
".",
"local",
"data",
"(",
"dict",
")",
"for",
"a",
"given",
"namespace",
"."
] | train | https://github.com/edx/edx-django-utils/blob/16cb4ac617e53c572bf68ccd19d24afeff1ca769/edx_django_utils/cache/utils.py#L33-L51 |
edx/edx-django-utils | edx_django_utils/cache/utils.py | RequestCache.get_cached_response | 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... | python | 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... | [
"def",
"get_cached_response",
"(",
"self",
",",
"key",
")",
":",
"cached_value",
"=",
"self",
".",
"data",
".",
"get",
"(",
"key",
",",
"_CACHE_MISS",
")",
"is_found",
"=",
"cached_value",
"is",
"not",
"_CACHE_MISS",
"return",
"CachedResponse",
"(",
"is_foun... | Retrieves a CachedResponse for the provided key.
Args:
key (string)
Returns:
A CachedResponse with is_found status and value. | [
"Retrieves",
"a",
"CachedResponse",
"for",
"the",
"provided",
"key",
"."
] | train | https://github.com/edx/edx-django-utils/blob/16cb4ac617e53c572bf68ccd19d24afeff1ca769/edx_django_utils/cache/utils.py#L94-L107 |
edx/edx-django-utils | edx_django_utils/cache/utils.py | TieredCache.get_cached_response | 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)
... | python | 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)
... | [
"def",
"get_cached_response",
"(",
"cls",
",",
"key",
")",
":",
"request_cached_response",
"=",
"DEFAULT_REQUEST_CACHE",
".",
"get_cached_response",
"(",
"key",
")",
"if",
"not",
"request_cached_response",
".",
"is_found",
":",
"django_cached_response",
"=",
"cls",
... | Retrieves a CachedResponse for the provided key.
Args:
key (string)
Returns:
A CachedResponse with is_found status and value. | [
"Retrieves",
"a",
"CachedResponse",
"for",
"the",
"provided",
"key",
"."
] | train | https://github.com/edx/edx-django-utils/blob/16cb4ac617e53c572bf68ccd19d24afeff1ca769/edx_django_utils/cache/utils.py#L152-L169 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.