repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
iotile/coretools | iotilegateway/iotilegateway/supervisor/client.py | AsyncSupervisorClient.post_info | def post_info(self, name, message):
"""Asynchronously post a user facing info message about a service.
Args:
name (string): The name of the service
message (string): The user facing info message that will be stored
for the service and can be queried later.
... | python | def post_info(self, name, message):
"""Asynchronously post a user facing info message about a service.
Args:
name (string): The name of the service
message (string): The user facing info message that will be stored
for the service and can be queried later.
... | [
"def",
"post_info",
"(",
"self",
",",
"name",
",",
"message",
")",
":",
"self",
".",
"post_command",
"(",
"OPERATIONS",
".",
"CMD_POST_MESSAGE",
",",
"_create_message",
"(",
"name",
",",
"states",
".",
"INFO_LEVEL",
",",
"message",
")",
")"
] | Asynchronously post a user facing info message about a service.
Args:
name (string): The name of the service
message (string): The user facing info message that will be stored
for the service and can be queried later. | [
"Asynchronously",
"post",
"a",
"user",
"facing",
"info",
"message",
"about",
"a",
"service",
"."
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilegateway/iotilegateway/supervisor/client.py#L326-L335 | train |
iotile/coretools | iotilegateway/iotilegateway/supervisor/client.py | AsyncSupervisorClient._on_status_change | async def _on_status_change(self, update):
"""Update a service that has its status updated."""
info = update['payload']
new_number = info['new_status']
name = update['service']
if name not in self.services:
return
with self._state_lock:
is_chang... | python | async def _on_status_change(self, update):
"""Update a service that has its status updated."""
info = update['payload']
new_number = info['new_status']
name = update['service']
if name not in self.services:
return
with self._state_lock:
is_chang... | [
"async",
"def",
"_on_status_change",
"(",
"self",
",",
"update",
")",
":",
"info",
"=",
"update",
"[",
"'payload'",
"]",
"new_number",
"=",
"info",
"[",
"'new_status'",
"]",
"name",
"=",
"update",
"[",
"'service'",
"]",
"if",
"name",
"not",
"in",
"self",... | Update a service that has its status updated. | [
"Update",
"a",
"service",
"that",
"has",
"its",
"status",
"updated",
"."
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilegateway/iotilegateway/supervisor/client.py#L408-L424 | train |
iotile/coretools | iotilegateway/iotilegateway/supervisor/client.py | AsyncSupervisorClient._on_heartbeat | async def _on_heartbeat(self, update):
"""Receive a new heartbeat for a service."""
name = update['service']
if name not in self.services:
return
with self._state_lock:
self.services[name].heartbeat() | python | async def _on_heartbeat(self, update):
"""Receive a new heartbeat for a service."""
name = update['service']
if name not in self.services:
return
with self._state_lock:
self.services[name].heartbeat() | [
"async",
"def",
"_on_heartbeat",
"(",
"self",
",",
"update",
")",
":",
"name",
"=",
"update",
"[",
"'service'",
"]",
"if",
"name",
"not",
"in",
"self",
".",
"services",
":",
"return",
"with",
"self",
".",
"_state_lock",
":",
"self",
".",
"services",
"[... | Receive a new heartbeat for a service. | [
"Receive",
"a",
"new",
"heartbeat",
"for",
"a",
"service",
"."
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilegateway/iotilegateway/supervisor/client.py#L446-L455 | train |
iotile/coretools | iotilegateway/iotilegateway/supervisor/client.py | AsyncSupervisorClient._on_message | async def _on_message(self, update):
"""Receive a message from a service."""
name = update['service']
message_obj = update['payload']
if name not in self.services:
return
with self._state_lock:
self.services[name].post_message(message_obj['level'], mess... | python | async def _on_message(self, update):
"""Receive a message from a service."""
name = update['service']
message_obj = update['payload']
if name not in self.services:
return
with self._state_lock:
self.services[name].post_message(message_obj['level'], mess... | [
"async",
"def",
"_on_message",
"(",
"self",
",",
"update",
")",
":",
"name",
"=",
"update",
"[",
"'service'",
"]",
"message_obj",
"=",
"update",
"[",
"'payload'",
"]",
"if",
"name",
"not",
"in",
"self",
".",
"services",
":",
"return",
"with",
"self",
"... | Receive a message from a service. | [
"Receive",
"a",
"message",
"from",
"a",
"service",
"."
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilegateway/iotilegateway/supervisor/client.py#L457-L467 | train |
iotile/coretools | iotilegateway/iotilegateway/supervisor/client.py | AsyncSupervisorClient._on_headline | async def _on_headline(self, update):
"""Receive a headline from a service."""
name = update['service']
message_obj = update['payload']
new_headline = False
if name not in self.services:
return
with self._state_lock:
self.services[name].set_head... | python | async def _on_headline(self, update):
"""Receive a headline from a service."""
name = update['service']
message_obj = update['payload']
new_headline = False
if name not in self.services:
return
with self._state_lock:
self.services[name].set_head... | [
"async",
"def",
"_on_headline",
"(",
"self",
",",
"update",
")",
":",
"name",
"=",
"update",
"[",
"'service'",
"]",
"message_obj",
"=",
"update",
"[",
"'payload'",
"]",
"new_headline",
"=",
"False",
"if",
"name",
"not",
"in",
"self",
".",
"services",
":"... | Receive a headline from a service. | [
"Receive",
"a",
"headline",
"from",
"a",
"service",
"."
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilegateway/iotilegateway/supervisor/client.py#L469-L488 | train |
iotile/coretools | iotilegateway/iotilegateway/supervisor/client.py | AsyncSupervisorClient._on_rpc_command | async def _on_rpc_command(self, event):
"""Received an RPC command that we should execute."""
payload = event['payload']
rpc_id = payload['rpc_id']
tag = payload['response_uuid']
args = payload['payload']
result = 'success'
response = b''
if self._rpc_d... | python | async def _on_rpc_command(self, event):
"""Received an RPC command that we should execute."""
payload = event['payload']
rpc_id = payload['rpc_id']
tag = payload['response_uuid']
args = payload['payload']
result = 'success'
response = b''
if self._rpc_d... | [
"async",
"def",
"_on_rpc_command",
"(",
"self",
",",
"event",
")",
":",
"payload",
"=",
"event",
"[",
"'payload'",
"]",
"rpc_id",
"=",
"payload",
"[",
"'rpc_id'",
"]",
"tag",
"=",
"payload",
"[",
"'response_uuid'",
"]",
"args",
"=",
"payload",
"[",
"'pay... | Received an RPC command that we should execute. | [
"Received",
"an",
"RPC",
"command",
"that",
"we",
"should",
"execute",
"."
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilegateway/iotilegateway/supervisor/client.py#L490-L522 | train |
iotile/coretools | transport_plugins/websocket/iotile_transport_websocket/generic/packing.py | _decode_datetime | def _decode_datetime(obj):
"""Decode a msgpack'ed datetime."""
if '__datetime__' in obj:
obj = datetime.datetime.strptime(obj['as_str'].decode(), "%Y%m%dT%H:%M:%S.%f")
return obj | python | def _decode_datetime(obj):
"""Decode a msgpack'ed datetime."""
if '__datetime__' in obj:
obj = datetime.datetime.strptime(obj['as_str'].decode(), "%Y%m%dT%H:%M:%S.%f")
return obj | [
"def",
"_decode_datetime",
"(",
"obj",
")",
":",
"if",
"'__datetime__'",
"in",
"obj",
":",
"obj",
"=",
"datetime",
".",
"datetime",
".",
"strptime",
"(",
"obj",
"[",
"'as_str'",
"]",
".",
"decode",
"(",
")",
",",
"\"%Y%m%dT%H:%M:%S.%f\"",
")",
"return",
... | Decode a msgpack'ed datetime. | [
"Decode",
"a",
"msgpack",
"ed",
"datetime",
"."
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/transport_plugins/websocket/iotile_transport_websocket/generic/packing.py#L19-L24 | train |
iotile/coretools | transport_plugins/websocket/iotile_transport_websocket/generic/packing.py | _encode_datetime | def _encode_datetime(obj):
"""Encode a msgpck'ed datetime."""
if isinstance(obj, datetime.datetime):
obj = {'__datetime__': True, 'as_str': obj.strftime("%Y%m%dT%H:%M:%S.%f").encode()}
return obj | python | def _encode_datetime(obj):
"""Encode a msgpck'ed datetime."""
if isinstance(obj, datetime.datetime):
obj = {'__datetime__': True, 'as_str': obj.strftime("%Y%m%dT%H:%M:%S.%f").encode()}
return obj | [
"def",
"_encode_datetime",
"(",
"obj",
")",
":",
"if",
"isinstance",
"(",
"obj",
",",
"datetime",
".",
"datetime",
")",
":",
"obj",
"=",
"{",
"'__datetime__'",
":",
"True",
",",
"'as_str'",
":",
"obj",
".",
"strftime",
"(",
"\"%Y%m%dT%H:%M:%S.%f\"",
")",
... | Encode a msgpck'ed datetime. | [
"Encode",
"a",
"msgpck",
"ed",
"datetime",
"."
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/transport_plugins/websocket/iotile_transport_websocket/generic/packing.py#L27-L32 | train |
iotile/coretools | iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/cyglink.py | _versioned_lib_suffix | def _versioned_lib_suffix(env, suffix, version):
"""Generate versioned shared library suffix from a unversioned one.
If suffix='.dll', and version='0.1.2', then it returns '-0-1-2.dll'"""
Verbose = False
if Verbose:
print("_versioned_lib_suffix: suffix= ", suffix)
print("_versioned_li... | python | def _versioned_lib_suffix(env, suffix, version):
"""Generate versioned shared library suffix from a unversioned one.
If suffix='.dll', and version='0.1.2', then it returns '-0-1-2.dll'"""
Verbose = False
if Verbose:
print("_versioned_lib_suffix: suffix= ", suffix)
print("_versioned_li... | [
"def",
"_versioned_lib_suffix",
"(",
"env",
",",
"suffix",
",",
"version",
")",
":",
"Verbose",
"=",
"False",
"if",
"Verbose",
":",
"print",
"(",
"\"_versioned_lib_suffix: suffix= \"",
",",
"suffix",
")",
"print",
"(",
"\"_versioned_lib_suffix: version= \"",
",",
... | Generate versioned shared library suffix from a unversioned one.
If suffix='.dll', and version='0.1.2', then it returns '-0-1-2.dll | [
"Generate",
"versioned",
"shared",
"library",
"suffix",
"from",
"a",
"unversioned",
"one",
".",
"If",
"suffix",
"=",
".",
"dll",
"and",
"version",
"=",
"0",
".",
"1",
".",
"2",
"then",
"it",
"returns",
"-",
"0",
"-",
"1",
"-",
"2",
".",
"dll"
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/cyglink.py#L128-L140 | train |
iotile/coretools | iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/cyglink.py | generate | def generate(env):
"""Add Builders and construction variables for cyglink to an Environment."""
gnulink.generate(env)
env['LINKFLAGS'] = SCons.Util.CLVar('-Wl,-no-undefined')
env['SHLINKCOM'] = shlib_action
env['LDMODULECOM'] = ldmod_action
env.Append(SHLIBEMITTER = [shlib_emitter])
env.... | python | def generate(env):
"""Add Builders and construction variables for cyglink to an Environment."""
gnulink.generate(env)
env['LINKFLAGS'] = SCons.Util.CLVar('-Wl,-no-undefined')
env['SHLINKCOM'] = shlib_action
env['LDMODULECOM'] = ldmod_action
env.Append(SHLIBEMITTER = [shlib_emitter])
env.... | [
"def",
"generate",
"(",
"env",
")",
":",
"gnulink",
".",
"generate",
"(",
"env",
")",
"env",
"[",
"'LINKFLAGS'",
"]",
"=",
"SCons",
".",
"Util",
".",
"CLVar",
"(",
"'-Wl,-no-undefined'",
")",
"env",
"[",
"'SHLINKCOM'",
"]",
"=",
"shlib_action",
"env",
... | Add Builders and construction variables for cyglink to an Environment. | [
"Add",
"Builders",
"and",
"construction",
"variables",
"for",
"cyglink",
"to",
"an",
"Environment",
"."
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/cyglink.py#L185-L225 | train |
iotile/coretools | iotilecore/iotile/core/utilities/validating_dispatcher.py | ValidatingDispatcher.dispatch | def dispatch(self, message):
"""Dispatch a message to a callback based on its schema.
Args:
message (dict): The message to dispatch
"""
for validator, callback in self.validators:
if not validator.matches(message):
continue
callback(... | python | def dispatch(self, message):
"""Dispatch a message to a callback based on its schema.
Args:
message (dict): The message to dispatch
"""
for validator, callback in self.validators:
if not validator.matches(message):
continue
callback(... | [
"def",
"dispatch",
"(",
"self",
",",
"message",
")",
":",
"for",
"validator",
",",
"callback",
"in",
"self",
".",
"validators",
":",
"if",
"not",
"validator",
".",
"matches",
"(",
"message",
")",
":",
"continue",
"callback",
"(",
"message",
")",
"return"... | Dispatch a message to a callback based on its schema.
Args:
message (dict): The message to dispatch | [
"Dispatch",
"a",
"message",
"to",
"a",
"callback",
"based",
"on",
"its",
"schema",
"."
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilecore/iotile/core/utilities/validating_dispatcher.py#L27-L41 | train |
iotile/coretools | iotilebuild/iotile/build/scripts/iotile_emulate.py | main | def main(raw_args=None):
"""Run the iotile-emulate script.
Args:
raw_args (list): Optional list of commmand line arguments. If not
passed these are pulled from sys.argv.
"""
if raw_args is None:
raw_args = sys.argv[1:]
parser = build_parser()
args = parser.parse_a... | python | def main(raw_args=None):
"""Run the iotile-emulate script.
Args:
raw_args (list): Optional list of commmand line arguments. If not
passed these are pulled from sys.argv.
"""
if raw_args is None:
raw_args = sys.argv[1:]
parser = build_parser()
args = parser.parse_a... | [
"def",
"main",
"(",
"raw_args",
"=",
"None",
")",
":",
"if",
"raw_args",
"is",
"None",
":",
"raw_args",
"=",
"sys",
".",
"argv",
"[",
"1",
":",
"]",
"parser",
"=",
"build_parser",
"(",
")",
"args",
"=",
"parser",
".",
"parse_args",
"(",
"raw_args",
... | Run the iotile-emulate script.
Args:
raw_args (list): Optional list of commmand line arguments. If not
passed these are pulled from sys.argv. | [
"Run",
"the",
"iotile",
"-",
"emulate",
"script",
"."
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/scripts/iotile_emulate.py#L30-L65 | train |
iotile/coretools | iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/qt.py | _detect | def _detect(env):
"""Not really safe, but fast method to detect the QT library"""
QTDIR = None
if not QTDIR:
QTDIR = env.get('QTDIR',None)
if not QTDIR:
QTDIR = os.environ.get('QTDIR',None)
if not QTDIR:
moc = env.WhereIs('moc')
if moc:
QTDIR = os.path.dir... | python | def _detect(env):
"""Not really safe, but fast method to detect the QT library"""
QTDIR = None
if not QTDIR:
QTDIR = env.get('QTDIR',None)
if not QTDIR:
QTDIR = os.environ.get('QTDIR',None)
if not QTDIR:
moc = env.WhereIs('moc')
if moc:
QTDIR = os.path.dir... | [
"def",
"_detect",
"(",
"env",
")",
":",
"QTDIR",
"=",
"None",
"if",
"not",
"QTDIR",
":",
"QTDIR",
"=",
"env",
".",
"get",
"(",
"'QTDIR'",
",",
"None",
")",
"if",
"not",
"QTDIR",
":",
"QTDIR",
"=",
"os",
".",
"environ",
".",
"get",
"(",
"'QTDIR'",... | Not really safe, but fast method to detect the QT library | [
"Not",
"really",
"safe",
"but",
"fast",
"method",
"to",
"detect",
"the",
"QT",
"library"
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/qt.py#L188-L207 | train |
iotile/coretools | iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/qt.py | generate | def generate(env):
"""Add Builders and construction variables for qt to an Environment."""
CLVar = SCons.Util.CLVar
Action = SCons.Action.Action
Builder = SCons.Builder.Builder
env.SetDefault(QTDIR = _detect(env),
QT_BINPATH = os.path.join('$QTDIR', 'bin'),
QT... | python | def generate(env):
"""Add Builders and construction variables for qt to an Environment."""
CLVar = SCons.Util.CLVar
Action = SCons.Action.Action
Builder = SCons.Builder.Builder
env.SetDefault(QTDIR = _detect(env),
QT_BINPATH = os.path.join('$QTDIR', 'bin'),
QT... | [
"def",
"generate",
"(",
"env",
")",
":",
"CLVar",
"=",
"SCons",
".",
"Util",
".",
"CLVar",
"Action",
"=",
"SCons",
".",
"Action",
".",
"Action",
"Builder",
"=",
"SCons",
".",
"Builder",
".",
"Builder",
"env",
".",
"SetDefault",
"(",
"QTDIR",
"=",
"_d... | Add Builders and construction variables for qt to an Environment. | [
"Add",
"Builders",
"and",
"construction",
"variables",
"for",
"qt",
"to",
"an",
"Environment",
"."
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/qt.py#L244-L334 | train |
iotile/coretools | iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/cpp.py | CPP_to_Python | def CPP_to_Python(s):
"""
Converts a C pre-processor expression into an equivalent
Python expression that can be evaluated.
"""
s = CPP_to_Python_Ops_Expression.sub(CPP_to_Python_Ops_Sub, s)
for expr, repl in CPP_to_Python_Eval_List:
s = expr.sub(repl, s)
return s | python | def CPP_to_Python(s):
"""
Converts a C pre-processor expression into an equivalent
Python expression that can be evaluated.
"""
s = CPP_to_Python_Ops_Expression.sub(CPP_to_Python_Ops_Sub, s)
for expr, repl in CPP_to_Python_Eval_List:
s = expr.sub(repl, s)
return s | [
"def",
"CPP_to_Python",
"(",
"s",
")",
":",
"s",
"=",
"CPP_to_Python_Ops_Expression",
".",
"sub",
"(",
"CPP_to_Python_Ops_Sub",
",",
"s",
")",
"for",
"expr",
",",
"repl",
"in",
"CPP_to_Python_Eval_List",
":",
"s",
"=",
"expr",
".",
"sub",
"(",
"repl",
",",... | Converts a C pre-processor expression into an equivalent
Python expression that can be evaluated. | [
"Converts",
"a",
"C",
"pre",
"-",
"processor",
"expression",
"into",
"an",
"equivalent",
"Python",
"expression",
"that",
"can",
"be",
"evaluated",
"."
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/cpp.py#L158-L166 | train |
iotile/coretools | iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/cpp.py | PreProcessor.tupleize | def tupleize(self, contents):
"""
Turns the contents of a file into a list of easily-processed
tuples describing the CPP lines in the file.
The first element of each tuple is the line's preprocessor
directive (#if, #include, #define, etc., minus the initial '#').
The rem... | python | def tupleize(self, contents):
"""
Turns the contents of a file into a list of easily-processed
tuples describing the CPP lines in the file.
The first element of each tuple is the line's preprocessor
directive (#if, #include, #define, etc., minus the initial '#').
The rem... | [
"def",
"tupleize",
"(",
"self",
",",
"contents",
")",
":",
"global",
"CPP_Expression",
",",
"Table",
"contents",
"=",
"line_continuations",
".",
"sub",
"(",
"''",
",",
"contents",
")",
"cpp_tuples",
"=",
"CPP_Expression",
".",
"findall",
"(",
"contents",
")"... | Turns the contents of a file into a list of easily-processed
tuples describing the CPP lines in the file.
The first element of each tuple is the line's preprocessor
directive (#if, #include, #define, etc., minus the initial '#').
The remaining elements are specific to the type of direct... | [
"Turns",
"the",
"contents",
"of",
"a",
"file",
"into",
"a",
"list",
"of",
"easily",
"-",
"processed",
"tuples",
"describing",
"the",
"CPP",
"lines",
"in",
"the",
"file",
"."
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/cpp.py#L274-L287 | train |
iotile/coretools | iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/cpp.py | PreProcessor.process_contents | def process_contents(self, contents, fname=None):
"""
Pre-processes a file contents.
This is the main internal entry point.
"""
self.stack = []
self.dispatch_table = self.default_table.copy()
self.current_file = fname
self.tuples = self.tupleize(contents)... | python | def process_contents(self, contents, fname=None):
"""
Pre-processes a file contents.
This is the main internal entry point.
"""
self.stack = []
self.dispatch_table = self.default_table.copy()
self.current_file = fname
self.tuples = self.tupleize(contents)... | [
"def",
"process_contents",
"(",
"self",
",",
"contents",
",",
"fname",
"=",
"None",
")",
":",
"self",
".",
"stack",
"=",
"[",
"]",
"self",
".",
"dispatch_table",
"=",
"self",
".",
"default_table",
".",
"copy",
"(",
")",
"self",
".",
"current_file",
"="... | Pre-processes a file contents.
This is the main internal entry point. | [
"Pre",
"-",
"processes",
"a",
"file",
"contents",
"."
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/cpp.py#L298-L316 | train |
iotile/coretools | iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/cpp.py | PreProcessor.save | def save(self):
"""
Pushes the current dispatch table on the stack and re-initializes
the current dispatch table to the default.
"""
self.stack.append(self.dispatch_table)
self.dispatch_table = self.default_table.copy() | python | def save(self):
"""
Pushes the current dispatch table on the stack and re-initializes
the current dispatch table to the default.
"""
self.stack.append(self.dispatch_table)
self.dispatch_table = self.default_table.copy() | [
"def",
"save",
"(",
"self",
")",
":",
"self",
".",
"stack",
".",
"append",
"(",
"self",
".",
"dispatch_table",
")",
"self",
".",
"dispatch_table",
"=",
"self",
".",
"default_table",
".",
"copy",
"(",
")"
] | Pushes the current dispatch table on the stack and re-initializes
the current dispatch table to the default. | [
"Pushes",
"the",
"current",
"dispatch",
"table",
"on",
"the",
"stack",
"and",
"re",
"-",
"initializes",
"the",
"current",
"dispatch",
"table",
"to",
"the",
"default",
"."
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/cpp.py#L320-L326 | train |
iotile/coretools | iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/cpp.py | PreProcessor.eval_expression | def eval_expression(self, t):
"""
Evaluates a C preprocessor expression.
This is done by converting it to a Python equivalent and
eval()ing it in the C preprocessor namespace we use to
track #define values.
"""
t = CPP_to_Python(' '.join(t[1:]))
try: retu... | python | def eval_expression(self, t):
"""
Evaluates a C preprocessor expression.
This is done by converting it to a Python equivalent and
eval()ing it in the C preprocessor namespace we use to
track #define values.
"""
t = CPP_to_Python(' '.join(t[1:]))
try: retu... | [
"def",
"eval_expression",
"(",
"self",
",",
"t",
")",
":",
"t",
"=",
"CPP_to_Python",
"(",
"' '",
".",
"join",
"(",
"t",
"[",
"1",
":",
"]",
")",
")",
"try",
":",
"return",
"eval",
"(",
"t",
",",
"self",
".",
"cpp_namespace",
")",
"except",
"(",
... | Evaluates a C preprocessor expression.
This is done by converting it to a Python equivalent and
eval()ing it in the C preprocessor namespace we use to
track #define values. | [
"Evaluates",
"a",
"C",
"preprocessor",
"expression",
"."
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/cpp.py#L348-L358 | train |
iotile/coretools | iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/rmic.py | emit_rmic_classes | def emit_rmic_classes(target, source, env):
"""Create and return lists of Java RMI stub and skeleton
class files to be created from a set of class files.
"""
class_suffix = env.get('JAVACLASSSUFFIX', '.class')
classdir = env.get('JAVACLASSDIR')
if not classdir:
try:
s = sour... | python | def emit_rmic_classes(target, source, env):
"""Create and return lists of Java RMI stub and skeleton
class files to be created from a set of class files.
"""
class_suffix = env.get('JAVACLASSSUFFIX', '.class')
classdir = env.get('JAVACLASSDIR')
if not classdir:
try:
s = sour... | [
"def",
"emit_rmic_classes",
"(",
"target",
",",
"source",
",",
"env",
")",
":",
"class_suffix",
"=",
"env",
".",
"get",
"(",
"'JAVACLASSSUFFIX'",
",",
"'.class'",
")",
"classdir",
"=",
"env",
".",
"get",
"(",
"'JAVACLASSDIR'",
")",
"if",
"not",
"classdir",... | Create and return lists of Java RMI stub and skeleton
class files to be created from a set of class files. | [
"Create",
"and",
"return",
"lists",
"of",
"Java",
"RMI",
"stub",
"and",
"skeleton",
"class",
"files",
"to",
"be",
"created",
"from",
"a",
"set",
"of",
"class",
"files",
"."
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/rmic.py#L43-L94 | train |
iotile/coretools | iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/rmic.py | generate | def generate(env):
"""Add Builders and construction variables for rmic to an Environment."""
env['BUILDERS']['RMIC'] = RMICBuilder
env['RMIC'] = 'rmic'
env['RMICFLAGS'] = SCons.Util.CLVar('')
env['RMICCOM'] = '$RMIC $RMICFLAGS -d ${TARGET.attributes.java_lookupdir} -classpa... | python | def generate(env):
"""Add Builders and construction variables for rmic to an Environment."""
env['BUILDERS']['RMIC'] = RMICBuilder
env['RMIC'] = 'rmic'
env['RMICFLAGS'] = SCons.Util.CLVar('')
env['RMICCOM'] = '$RMIC $RMICFLAGS -d ${TARGET.attributes.java_lookupdir} -classpa... | [
"def",
"generate",
"(",
"env",
")",
":",
"env",
"[",
"'BUILDERS'",
"]",
"[",
"'RMIC'",
"]",
"=",
"RMICBuilder",
"env",
"[",
"'RMIC'",
"]",
"=",
"'rmic'",
"env",
"[",
"'RMICFLAGS'",
"]",
"=",
"SCons",
".",
"Util",
".",
"CLVar",
"(",
"''",
")",
"env"... | Add Builders and construction variables for rmic to an Environment. | [
"Add",
"Builders",
"and",
"construction",
"variables",
"for",
"rmic",
"to",
"an",
"Environment",
"."
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/rmic.py#L104-L111 | train |
iotile/coretools | transport_plugins/bled112/iotile_transport_bled112/bled112_cmd.py | BLED112CommandProcessor._set_scan_parameters | def _set_scan_parameters(self, interval=2100, window=2100, active=False):
"""
Set the scan interval and window in units of ms and set whether active scanning is performed
"""
active_num = 0
if bool(active):
active_num = 1
interval_num = int(interval*1000/625... | python | def _set_scan_parameters(self, interval=2100, window=2100, active=False):
"""
Set the scan interval and window in units of ms and set whether active scanning is performed
"""
active_num = 0
if bool(active):
active_num = 1
interval_num = int(interval*1000/625... | [
"def",
"_set_scan_parameters",
"(",
"self",
",",
"interval",
"=",
"2100",
",",
"window",
"=",
"2100",
",",
"active",
"=",
"False",
")",
":",
"active_num",
"=",
"0",
"if",
"bool",
"(",
"active",
")",
":",
"active_num",
"=",
"1",
"interval_num",
"=",
"in... | Set the scan interval and window in units of ms and set whether active scanning is performed | [
"Set",
"the",
"scan",
"interval",
"and",
"window",
"in",
"units",
"of",
"ms",
"and",
"set",
"whether",
"active",
"scanning",
"is",
"performed"
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/transport_plugins/bled112/iotile_transport_bled112/bled112_cmd.py#L76-L97 | train |
iotile/coretools | transport_plugins/bled112/iotile_transport_bled112/bled112_cmd.py | BLED112CommandProcessor._query_systemstate | def _query_systemstate(self):
"""Query the maximum number of connections supported by this adapter
"""
def status_filter_func(event):
if event.command_class == 3 and event.command == 0:
return True
return False
try:
response = self._... | python | def _query_systemstate(self):
"""Query the maximum number of connections supported by this adapter
"""
def status_filter_func(event):
if event.command_class == 3 and event.command == 0:
return True
return False
try:
response = self._... | [
"def",
"_query_systemstate",
"(",
"self",
")",
":",
"def",
"status_filter_func",
"(",
"event",
")",
":",
"if",
"event",
".",
"command_class",
"==",
"3",
"and",
"event",
".",
"command",
"==",
"0",
":",
"return",
"True",
"return",
"False",
"try",
":",
"res... | Query the maximum number of connections supported by this adapter | [
"Query",
"the",
"maximum",
"number",
"of",
"connections",
"supported",
"by",
"this",
"adapter"
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/transport_plugins/bled112/iotile_transport_bled112/bled112_cmd.py#L99-L124 | train |
iotile/coretools | transport_plugins/bled112/iotile_transport_bled112/bled112_cmd.py | BLED112CommandProcessor._start_scan | def _start_scan(self, active):
"""Begin scanning forever
"""
success, retval = self._set_scan_parameters(active=active)
if not success:
return success, retval
try:
response = self._send_command(6, 2, [2])
if response.payload[0] != 0:
... | python | def _start_scan(self, active):
"""Begin scanning forever
"""
success, retval = self._set_scan_parameters(active=active)
if not success:
return success, retval
try:
response = self._send_command(6, 2, [2])
if response.payload[0] != 0:
... | [
"def",
"_start_scan",
"(",
"self",
",",
"active",
")",
":",
"success",
",",
"retval",
"=",
"self",
".",
"_set_scan_parameters",
"(",
"active",
"=",
"active",
")",
"if",
"not",
"success",
":",
"return",
"success",
",",
"retval",
"try",
":",
"response",
"=... | Begin scanning forever | [
"Begin",
"scanning",
"forever"
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/transport_plugins/bled112/iotile_transport_bled112/bled112_cmd.py#L126-L142 | train |
iotile/coretools | transport_plugins/bled112/iotile_transport_bled112/bled112_cmd.py | BLED112CommandProcessor._stop_scan | def _stop_scan(self):
"""Stop scanning for BLE devices
"""
try:
response = self._send_command(6, 4, [])
if response.payload[0] != 0:
# Error code 129 means we just were not currently scanning
if response.payload[0] != 129:
... | python | def _stop_scan(self):
"""Stop scanning for BLE devices
"""
try:
response = self._send_command(6, 4, [])
if response.payload[0] != 0:
# Error code 129 means we just were not currently scanning
if response.payload[0] != 129:
... | [
"def",
"_stop_scan",
"(",
"self",
")",
":",
"try",
":",
"response",
"=",
"self",
".",
"_send_command",
"(",
"6",
",",
"4",
",",
"[",
"]",
")",
"if",
"response",
".",
"payload",
"[",
"0",
"]",
"!=",
"0",
":",
"if",
"response",
".",
"payload",
"[",... | Stop scanning for BLE devices | [
"Stop",
"scanning",
"for",
"BLE",
"devices"
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/transport_plugins/bled112/iotile_transport_bled112/bled112_cmd.py#L144-L161 | train |
iotile/coretools | transport_plugins/bled112/iotile_transport_bled112/bled112_cmd.py | BLED112CommandProcessor._probe_services | def _probe_services(self, handle):
"""Probe for all primary services and characteristics in those services
Args:
handle (int): the connection handle to probe
"""
code = 0x2800
def event_filter_func(event):
if (event.command_class == 4 and event.command ... | python | def _probe_services(self, handle):
"""Probe for all primary services and characteristics in those services
Args:
handle (int): the connection handle to probe
"""
code = 0x2800
def event_filter_func(event):
if (event.command_class == 4 and event.command ... | [
"def",
"_probe_services",
"(",
"self",
",",
"handle",
")",
":",
"code",
"=",
"0x2800",
"def",
"event_filter_func",
"(",
"event",
")",
":",
"if",
"(",
"event",
".",
"command_class",
"==",
"4",
"and",
"event",
".",
"command",
"==",
"2",
")",
":",
"event_... | Probe for all primary services and characteristics in those services
Args:
handle (int): the connection handle to probe | [
"Probe",
"for",
"all",
"primary",
"services",
"and",
"characteristics",
"in",
"those",
"services"
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/transport_plugins/bled112/iotile_transport_bled112/bled112_cmd.py#L163-L215 | train |
iotile/coretools | transport_plugins/bled112/iotile_transport_bled112/bled112_cmd.py | BLED112CommandProcessor._probe_characteristics | def _probe_characteristics(self, conn, services, timeout=5.0):
"""Probe gatt services for all associated characteristics in a BLE device
Args:
conn (int): the connection handle to probe
services (dict): a dictionary of services produced by probe_services()
timeout (f... | python | def _probe_characteristics(self, conn, services, timeout=5.0):
"""Probe gatt services for all associated characteristics in a BLE device
Args:
conn (int): the connection handle to probe
services (dict): a dictionary of services produced by probe_services()
timeout (f... | [
"def",
"_probe_characteristics",
"(",
"self",
",",
"conn",
",",
"services",
",",
"timeout",
"=",
"5.0",
")",
":",
"for",
"service",
"in",
"services",
".",
"values",
"(",
")",
":",
"success",
",",
"result",
"=",
"self",
".",
"_enumerate_handles",
"(",
"co... | Probe gatt services for all associated characteristics in a BLE device
Args:
conn (int): the connection handle to probe
services (dict): a dictionary of services produced by probe_services()
timeout (float): the maximum number of seconds to spend in any single task | [
"Probe",
"gatt",
"services",
"for",
"all",
"associated",
"characteristics",
"in",
"a",
"BLE",
"device"
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/transport_plugins/bled112/iotile_transport_bled112/bled112_cmd.py#L217-L262 | train |
iotile/coretools | transport_plugins/bled112/iotile_transport_bled112/bled112_cmd.py | BLED112CommandProcessor._enable_rpcs | def _enable_rpcs(self, conn, services, timeout=1.0):
"""Prepare this device to receive RPCs
"""
#FIXME: Check for characteristic existence in a try/catch and return failure if not found
success, result = self._set_notification(conn, services[TileBusService]['characteristics'][TileBusRe... | python | def _enable_rpcs(self, conn, services, timeout=1.0):
"""Prepare this device to receive RPCs
"""
#FIXME: Check for characteristic existence in a try/catch and return failure if not found
success, result = self._set_notification(conn, services[TileBusService]['characteristics'][TileBusRe... | [
"def",
"_enable_rpcs",
"(",
"self",
",",
"conn",
",",
"services",
",",
"timeout",
"=",
"1.0",
")",
":",
"success",
",",
"result",
"=",
"self",
".",
"_set_notification",
"(",
"conn",
",",
"services",
"[",
"TileBusService",
"]",
"[",
"'characteristics'",
"]"... | Prepare this device to receive RPCs | [
"Prepare",
"this",
"device",
"to",
"receive",
"RPCs"
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/transport_plugins/bled112/iotile_transport_bled112/bled112_cmd.py#L264-L274 | train |
iotile/coretools | transport_plugins/bled112/iotile_transport_bled112/bled112_cmd.py | BLED112CommandProcessor._disable_rpcs | def _disable_rpcs(self, conn, services, timeout=1.0):
"""Prevent this device from receiving more RPCs
"""
success, result = self._set_notification(conn, services[TileBusService]['characteristics'][TileBusReceiveHeaderCharacteristic], False, timeout)
if not success:
return su... | python | def _disable_rpcs(self, conn, services, timeout=1.0):
"""Prevent this device from receiving more RPCs
"""
success, result = self._set_notification(conn, services[TileBusService]['characteristics'][TileBusReceiveHeaderCharacteristic], False, timeout)
if not success:
return su... | [
"def",
"_disable_rpcs",
"(",
"self",
",",
"conn",
",",
"services",
",",
"timeout",
"=",
"1.0",
")",
":",
"success",
",",
"result",
"=",
"self",
".",
"_set_notification",
"(",
"conn",
",",
"services",
"[",
"TileBusService",
"]",
"[",
"'characteristics'",
"]... | Prevent this device from receiving more RPCs | [
"Prevent",
"this",
"device",
"from",
"receiving",
"more",
"RPCs"
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/transport_plugins/bled112/iotile_transport_bled112/bled112_cmd.py#L290-L298 | train |
iotile/coretools | transport_plugins/bled112/iotile_transport_bled112/bled112_cmd.py | BLED112CommandProcessor._write_handle | def _write_handle(self, conn, handle, ack, value, timeout=1.0):
"""Write to a BLE device characteristic by its handle
Args:
conn (int): The connection handle for the device we should read from
handle (int): The characteristics handle we should read
ack (bool): Should... | python | def _write_handle(self, conn, handle, ack, value, timeout=1.0):
"""Write to a BLE device characteristic by its handle
Args:
conn (int): The connection handle for the device we should read from
handle (int): The characteristics handle we should read
ack (bool): Should... | [
"def",
"_write_handle",
"(",
"self",
",",
"conn",
",",
"handle",
",",
"ack",
",",
"value",
",",
"timeout",
"=",
"1.0",
")",
":",
"conn_handle",
"=",
"conn",
"char_handle",
"=",
"handle",
"def",
"write_handle_acked",
"(",
"event",
")",
":",
"if",
"event",... | Write to a BLE device characteristic by its handle
Args:
conn (int): The connection handle for the device we should read from
handle (int): The characteristics handle we should read
ack (bool): Should this be an acknowledges write or unacknowledged
timeout (float... | [
"Write",
"to",
"a",
"BLE",
"device",
"characteristic",
"by",
"its",
"handle"
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/transport_plugins/bled112/iotile_transport_bled112/bled112_cmd.py#L373-L420 | train |
iotile/coretools | transport_plugins/bled112/iotile_transport_bled112/bled112_cmd.py | BLED112CommandProcessor._set_advertising_data | def _set_advertising_data(self, packet_type, data):
"""Set the advertising data for advertisements sent out by this bled112
Args:
packet_type (int): 0 for advertisement, 1 for scan response
data (bytearray): the data to set
"""
payload = struct.pack("<BB%ss" % (... | python | def _set_advertising_data(self, packet_type, data):
"""Set the advertising data for advertisements sent out by this bled112
Args:
packet_type (int): 0 for advertisement, 1 for scan response
data (bytearray): the data to set
"""
payload = struct.pack("<BB%ss" % (... | [
"def",
"_set_advertising_data",
"(",
"self",
",",
"packet_type",
",",
"data",
")",
":",
"payload",
"=",
"struct",
".",
"pack",
"(",
"\"<BB%ss\"",
"%",
"(",
"len",
"(",
"data",
")",
")",
",",
"packet_type",
",",
"len",
"(",
"data",
")",
",",
"bytes",
... | Set the advertising data for advertisements sent out by this bled112
Args:
packet_type (int): 0 for advertisement, 1 for scan response
data (bytearray): the data to set | [
"Set",
"the",
"advertising",
"data",
"for",
"advertisements",
"sent",
"out",
"by",
"this",
"bled112"
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/transport_plugins/bled112/iotile_transport_bled112/bled112_cmd.py#L513-L528 | train |
iotile/coretools | transport_plugins/bled112/iotile_transport_bled112/bled112_cmd.py | BLED112CommandProcessor._set_mode | def _set_mode(self, discover_mode, connect_mode):
"""Set the mode of the BLED112, used to enable and disable advertising
To enable advertising, use 4, 2.
To disable advertising use 0, 0.
Args:
discover_mode (int): The discoverability mode, 0 for off, 4 for on (user data)
... | python | def _set_mode(self, discover_mode, connect_mode):
"""Set the mode of the BLED112, used to enable and disable advertising
To enable advertising, use 4, 2.
To disable advertising use 0, 0.
Args:
discover_mode (int): The discoverability mode, 0 for off, 4 for on (user data)
... | [
"def",
"_set_mode",
"(",
"self",
",",
"discover_mode",
",",
"connect_mode",
")",
":",
"payload",
"=",
"struct",
".",
"pack",
"(",
"\"<BB\"",
",",
"discover_mode",
",",
"connect_mode",
")",
"response",
"=",
"self",
".",
"_send_command",
"(",
"6",
",",
"1",
... | Set the mode of the BLED112, used to enable and disable advertising
To enable advertising, use 4, 2.
To disable advertising use 0, 0.
Args:
discover_mode (int): The discoverability mode, 0 for off, 4 for on (user data)
connect_mode (int): The connectability mode, 0 for ... | [
"Set",
"the",
"mode",
"of",
"the",
"BLED112",
"used",
"to",
"enable",
"and",
"disable",
"advertising"
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/transport_plugins/bled112/iotile_transport_bled112/bled112_cmd.py#L530-L548 | train |
iotile/coretools | transport_plugins/bled112/iotile_transport_bled112/bled112_cmd.py | BLED112CommandProcessor._send_notification | def _send_notification(self, handle, value):
"""Send a notification to all connected clients on a characteristic
Args:
handle (int): The handle we wish to notify on
value (bytearray): The value we wish to send
"""
value_len = len(value)
value = bytes(val... | python | def _send_notification(self, handle, value):
"""Send a notification to all connected clients on a characteristic
Args:
handle (int): The handle we wish to notify on
value (bytearray): The value we wish to send
"""
value_len = len(value)
value = bytes(val... | [
"def",
"_send_notification",
"(",
"self",
",",
"handle",
",",
"value",
")",
":",
"value_len",
"=",
"len",
"(",
"value",
")",
"value",
"=",
"bytes",
"(",
"value",
")",
"payload",
"=",
"struct",
".",
"pack",
"(",
"\"<BHB%ds\"",
"%",
"value_len",
",",
"0x... | Send a notification to all connected clients on a characteristic
Args:
handle (int): The handle we wish to notify on
value (bytearray): The value we wish to send | [
"Send",
"a",
"notification",
"to",
"all",
"connected",
"clients",
"on",
"a",
"characteristic"
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/transport_plugins/bled112/iotile_transport_bled112/bled112_cmd.py#L550-L568 | train |
iotile/coretools | transport_plugins/bled112/iotile_transport_bled112/bled112_cmd.py | BLED112CommandProcessor._disconnect | def _disconnect(self, handle):
"""Disconnect from a device that we have previously connected to
"""
payload = struct.pack('<B', handle)
response = self._send_command(3, 0, payload)
conn_handle, result = unpack("<BH", response.payload)
if result != 0:
self._l... | python | def _disconnect(self, handle):
"""Disconnect from a device that we have previously connected to
"""
payload = struct.pack('<B', handle)
response = self._send_command(3, 0, payload)
conn_handle, result = unpack("<BH", response.payload)
if result != 0:
self._l... | [
"def",
"_disconnect",
"(",
"self",
",",
"handle",
")",
":",
"payload",
"=",
"struct",
".",
"pack",
"(",
"'<B'",
",",
"handle",
")",
"response",
"=",
"self",
".",
"_send_command",
"(",
"3",
",",
"0",
",",
"payload",
")",
"conn_handle",
",",
"result",
... | Disconnect from a device that we have previously connected to | [
"Disconnect",
"from",
"a",
"device",
"that",
"we",
"have",
"previously",
"connected",
"to"
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/transport_plugins/bled112/iotile_transport_bled112/bled112_cmd.py#L657-L683 | train |
iotile/coretools | transport_plugins/bled112/iotile_transport_bled112/bled112_cmd.py | BLED112CommandProcessor._send_command | def _send_command(self, cmd_class, command, payload, timeout=3.0):
"""
Send a BGAPI packet to the dongle and return the response
"""
if len(payload) > 60:
return ValueError("Attempting to send a BGAPI packet with length > 60 is not allowed", actual_length=len(payload), comma... | python | def _send_command(self, cmd_class, command, payload, timeout=3.0):
"""
Send a BGAPI packet to the dongle and return the response
"""
if len(payload) > 60:
return ValueError("Attempting to send a BGAPI packet with length > 60 is not allowed", actual_length=len(payload), comma... | [
"def",
"_send_command",
"(",
"self",
",",
"cmd_class",
",",
"command",
",",
"payload",
",",
"timeout",
"=",
"3.0",
")",
":",
"if",
"len",
"(",
"payload",
")",
">",
"60",
":",
"return",
"ValueError",
"(",
"\"Attempting to send a BGAPI packet with length > 60 is n... | Send a BGAPI packet to the dongle and return the response | [
"Send",
"a",
"BGAPI",
"packet",
"to",
"the",
"dongle",
"and",
"return",
"the",
"response"
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/transport_plugins/bled112/iotile_transport_bled112/bled112_cmd.py#L685-L704 | train |
iotile/coretools | transport_plugins/bled112/iotile_transport_bled112/bled112_cmd.py | BLED112CommandProcessor._receive_packet | def _receive_packet(self, timeout=3.0):
"""
Receive a response packet to a command
"""
while True:
response_data = self._stream.read_packet(timeout=timeout)
response = BGAPIPacket(is_event=(response_data[0] == 0x80), command_class=response_data[2], command=respon... | python | def _receive_packet(self, timeout=3.0):
"""
Receive a response packet to a command
"""
while True:
response_data = self._stream.read_packet(timeout=timeout)
response = BGAPIPacket(is_event=(response_data[0] == 0x80), command_class=response_data[2], command=respon... | [
"def",
"_receive_packet",
"(",
"self",
",",
"timeout",
"=",
"3.0",
")",
":",
"while",
"True",
":",
"response_data",
"=",
"self",
".",
"_stream",
".",
"read_packet",
"(",
"timeout",
"=",
"timeout",
")",
"response",
"=",
"BGAPIPacket",
"(",
"is_event",
"=",
... | Receive a response packet to a command | [
"Receive",
"a",
"response",
"packet",
"to",
"a",
"command"
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/transport_plugins/bled112/iotile_transport_bled112/bled112_cmd.py#L706-L721 | train |
iotile/coretools | transport_plugins/bled112/iotile_transport_bled112/bled112_cmd.py | BLED112CommandProcessor._wait_process_events | def _wait_process_events(self, total_time, return_filter, end_filter):
"""Synchronously process events until a specific event is found or we timeout
Args:
total_time (float): The aproximate maximum number of seconds we should wait for the end event
return_filter (callable): A fu... | python | def _wait_process_events(self, total_time, return_filter, end_filter):
"""Synchronously process events until a specific event is found or we timeout
Args:
total_time (float): The aproximate maximum number of seconds we should wait for the end event
return_filter (callable): A fu... | [
"def",
"_wait_process_events",
"(",
"self",
",",
"total_time",
",",
"return_filter",
",",
"end_filter",
")",
":",
"acc",
"=",
"[",
"]",
"delta",
"=",
"0.01",
"start_time",
"=",
"time",
".",
"time",
"(",
")",
"end_time",
"=",
"start_time",
"+",
"total_time"... | Synchronously process events until a specific event is found or we timeout
Args:
total_time (float): The aproximate maximum number of seconds we should wait for the end event
return_filter (callable): A function that returns True for events we should return and not process
... | [
"Synchronously",
"process",
"events",
"until",
"a",
"specific",
"event",
"is",
"found",
"or",
"we",
"timeout"
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/transport_plugins/bled112/iotile_transport_bled112/bled112_cmd.py#L774-L805 | train |
iotile/coretools | transport_plugins/awsiot/iotile_transport_awsiot/mqtt_client.py | OrderedAWSIOTClient.connect | def connect(self, client_id):
"""Connect to AWS IOT with the given client_id
Args:
client_id (string): The client ID passed to the MQTT message broker
"""
if self.client is not None:
raise InternalError("Connect called on an alreaded connected MQTT client")
... | python | def connect(self, client_id):
"""Connect to AWS IOT with the given client_id
Args:
client_id (string): The client ID passed to the MQTT message broker
"""
if self.client is not None:
raise InternalError("Connect called on an alreaded connected MQTT client")
... | [
"def",
"connect",
"(",
"self",
",",
"client_id",
")",
":",
"if",
"self",
".",
"client",
"is",
"not",
"None",
":",
"raise",
"InternalError",
"(",
"\"Connect called on an alreaded connected MQTT client\"",
")",
"client",
"=",
"AWSIoTPythonSDK",
".",
"MQTTLib",
".",
... | Connect to AWS IOT with the given client_id
Args:
client_id (string): The client ID passed to the MQTT message broker | [
"Connect",
"to",
"AWS",
"IOT",
"with",
"the",
"given",
"client_id"
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/transport_plugins/awsiot/iotile_transport_awsiot/mqtt_client.py#L78-L110 | train |
iotile/coretools | transport_plugins/awsiot/iotile_transport_awsiot/mqtt_client.py | OrderedAWSIOTClient.disconnect | def disconnect(self):
"""Disconnect from AWS IOT message broker
"""
if self.client is None:
return
try:
self.client.disconnect()
except operationError as exc:
raise InternalError("Could not disconnect from AWS IOT", message=exc.message) | python | def disconnect(self):
"""Disconnect from AWS IOT message broker
"""
if self.client is None:
return
try:
self.client.disconnect()
except operationError as exc:
raise InternalError("Could not disconnect from AWS IOT", message=exc.message) | [
"def",
"disconnect",
"(",
"self",
")",
":",
"if",
"self",
".",
"client",
"is",
"None",
":",
"return",
"try",
":",
"self",
".",
"client",
".",
"disconnect",
"(",
")",
"except",
"operationError",
"as",
"exc",
":",
"raise",
"InternalError",
"(",
"\"Could no... | Disconnect from AWS IOT message broker | [
"Disconnect",
"from",
"AWS",
"IOT",
"message",
"broker"
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/transport_plugins/awsiot/iotile_transport_awsiot/mqtt_client.py#L112-L122 | train |
iotile/coretools | transport_plugins/awsiot/iotile_transport_awsiot/mqtt_client.py | OrderedAWSIOTClient.publish | def publish(self, topic, message):
"""Publish a json message to a topic with a type and a sequence number
The actual message will be published as a JSON object:
{
"sequence": <incrementing id>,
"message": message
}
Args:
topic (string): The M... | python | def publish(self, topic, message):
"""Publish a json message to a topic with a type and a sequence number
The actual message will be published as a JSON object:
{
"sequence": <incrementing id>,
"message": message
}
Args:
topic (string): The M... | [
"def",
"publish",
"(",
"self",
",",
"topic",
",",
"message",
")",
":",
"seq",
"=",
"self",
".",
"sequencer",
".",
"next_id",
"(",
"topic",
")",
"packet",
"=",
"{",
"'sequence'",
":",
"seq",
",",
"'message'",
":",
"message",
"}",
"if",
"'key'",
"in",
... | Publish a json message to a topic with a type and a sequence number
The actual message will be published as a JSON object:
{
"sequence": <incrementing id>,
"message": message
}
Args:
topic (string): The MQTT topic to publish in
message (s... | [
"Publish",
"a",
"json",
"message",
"to",
"a",
"topic",
"with",
"a",
"type",
"and",
"a",
"sequence",
"number"
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/transport_plugins/awsiot/iotile_transport_awsiot/mqtt_client.py#L124-L165 | train |
iotile/coretools | transport_plugins/awsiot/iotile_transport_awsiot/mqtt_client.py | OrderedAWSIOTClient.subscribe | def subscribe(self, topic, callback, ordered=True):
"""Subscribe to future messages in the given topic
The contents of topic should be in the format created by self.publish with a
sequence number of message type encoded as a json string.
Wildcard topics containing + and # are allowed a... | python | def subscribe(self, topic, callback, ordered=True):
"""Subscribe to future messages in the given topic
The contents of topic should be in the format created by self.publish with a
sequence number of message type encoded as a json string.
Wildcard topics containing + and # are allowed a... | [
"def",
"subscribe",
"(",
"self",
",",
"topic",
",",
"callback",
",",
"ordered",
"=",
"True",
")",
":",
"if",
"'+'",
"in",
"topic",
"or",
"'#'",
"in",
"topic",
":",
"regex",
"=",
"re",
".",
"compile",
"(",
"topic",
".",
"replace",
"(",
"'+'",
",",
... | Subscribe to future messages in the given topic
The contents of topic should be in the format created by self.publish with a
sequence number of message type encoded as a json string.
Wildcard topics containing + and # are allowed and
Args:
topic (string): The MQTT topic to... | [
"Subscribe",
"to",
"future",
"messages",
"in",
"the",
"given",
"topic"
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/transport_plugins/awsiot/iotile_transport_awsiot/mqtt_client.py#L167-L192 | train |
iotile/coretools | transport_plugins/awsiot/iotile_transport_awsiot/mqtt_client.py | OrderedAWSIOTClient.reset_sequence | def reset_sequence(self, topic):
"""Reset the expected sequence number for a topic
If the topic is unknown, this does nothing. This behaviour is
useful when you have wildcard topics that only create queues
once they receive the first message matching the topic.
Args:
... | python | def reset_sequence(self, topic):
"""Reset the expected sequence number for a topic
If the topic is unknown, this does nothing. This behaviour is
useful when you have wildcard topics that only create queues
once they receive the first message matching the topic.
Args:
... | [
"def",
"reset_sequence",
"(",
"self",
",",
"topic",
")",
":",
"if",
"topic",
"in",
"self",
".",
"queues",
":",
"self",
".",
"queues",
"[",
"topic",
"]",
".",
"reset",
"(",
")"
] | Reset the expected sequence number for a topic
If the topic is unknown, this does nothing. This behaviour is
useful when you have wildcard topics that only create queues
once they receive the first message matching the topic.
Args:
topic (string): The topic to reset the pa... | [
"Reset",
"the",
"expected",
"sequence",
"number",
"for",
"a",
"topic"
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/transport_plugins/awsiot/iotile_transport_awsiot/mqtt_client.py#L194-L206 | train |
iotile/coretools | transport_plugins/awsiot/iotile_transport_awsiot/mqtt_client.py | OrderedAWSIOTClient.unsubscribe | def unsubscribe(self, topic):
"""Unsubscribe from messages on a given topic
Args:
topic (string): The MQTT topic to unsubscribe from
"""
del self.queues[topic]
try:
self.client.unsubscribe(topic)
except operationError as exc:
raise I... | python | def unsubscribe(self, topic):
"""Unsubscribe from messages on a given topic
Args:
topic (string): The MQTT topic to unsubscribe from
"""
del self.queues[topic]
try:
self.client.unsubscribe(topic)
except operationError as exc:
raise I... | [
"def",
"unsubscribe",
"(",
"self",
",",
"topic",
")",
":",
"del",
"self",
".",
"queues",
"[",
"topic",
"]",
"try",
":",
"self",
".",
"client",
".",
"unsubscribe",
"(",
"topic",
")",
"except",
"operationError",
"as",
"exc",
":",
"raise",
"InternalError",
... | Unsubscribe from messages on a given topic
Args:
topic (string): The MQTT topic to unsubscribe from | [
"Unsubscribe",
"from",
"messages",
"on",
"a",
"given",
"topic"
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/transport_plugins/awsiot/iotile_transport_awsiot/mqtt_client.py#L208-L220 | train |
iotile/coretools | transport_plugins/awsiot/iotile_transport_awsiot/mqtt_client.py | OrderedAWSIOTClient._on_receive | def _on_receive(self, client, userdata, message):
"""Callback called whenever we receive a message on a subscribed topic
Args:
client (string): The client id of the client receiving the message
userdata (string): Any user data set with the underlying MQTT client
mess... | python | def _on_receive(self, client, userdata, message):
"""Callback called whenever we receive a message on a subscribed topic
Args:
client (string): The client id of the client receiving the message
userdata (string): Any user data set with the underlying MQTT client
mess... | [
"def",
"_on_receive",
"(",
"self",
",",
"client",
",",
"userdata",
",",
"message",
")",
":",
"topic",
"=",
"message",
".",
"topic",
"encoded",
"=",
"message",
".",
"payload",
"try",
":",
"packet",
"=",
"json",
".",
"loads",
"(",
"encoded",
")",
"except... | Callback called whenever we receive a message on a subscribed topic
Args:
client (string): The client id of the client receiving the message
userdata (string): Any user data set with the underlying MQTT client
message (object): The mesage with a topic and payload. | [
"Callback",
"called",
"whenever",
"we",
"receive",
"a",
"message",
"on",
"a",
"subscribed",
"topic"
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/transport_plugins/awsiot/iotile_transport_awsiot/mqtt_client.py#L222-L261 | train |
iotile/coretools | iotileship/iotile/ship/actions/sync_rtc_step.py | SyncRTCStep.run | def run(self, resources):
"""Sets the RTC timestamp to UTC.
Args:
resources (dict): A dictionary containing the required resources that
we needed access to in order to perform this step.
"""
hwman = resources['connection']
con = hwman.hwman.controller... | python | def run(self, resources):
"""Sets the RTC timestamp to UTC.
Args:
resources (dict): A dictionary containing the required resources that
we needed access to in order to perform this step.
"""
hwman = resources['connection']
con = hwman.hwman.controller... | [
"def",
"run",
"(",
"self",
",",
"resources",
")",
":",
"hwman",
"=",
"resources",
"[",
"'connection'",
"]",
"con",
"=",
"hwman",
".",
"hwman",
".",
"controller",
"(",
")",
"test_interface",
"=",
"con",
".",
"test_interface",
"(",
")",
"try",
":",
"test... | Sets the RTC timestamp to UTC.
Args:
resources (dict): A dictionary containing the required resources that
we needed access to in order to perform this step. | [
"Sets",
"the",
"RTC",
"timestamp",
"to",
"UTC",
"."
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotileship/iotile/ship/actions/sync_rtc_step.py#L21-L35 | train |
iotile/coretools | iotilecore/iotile/core/utilities/command_file.py | CommandFile.add | def add(self, command, *args):
"""Add a command to this command file.
Args:
command (str): The command to add
*args (str): The parameters to call the command with
"""
cmd = Command(command, args)
self.commands.append(cmd) | python | def add(self, command, *args):
"""Add a command to this command file.
Args:
command (str): The command to add
*args (str): The parameters to call the command with
"""
cmd = Command(command, args)
self.commands.append(cmd) | [
"def",
"add",
"(",
"self",
",",
"command",
",",
"*",
"args",
")",
":",
"cmd",
"=",
"Command",
"(",
"command",
",",
"args",
")",
"self",
".",
"commands",
".",
"append",
"(",
"cmd",
")"
] | Add a command to this command file.
Args:
command (str): The command to add
*args (str): The parameters to call the command with | [
"Add",
"a",
"command",
"to",
"this",
"command",
"file",
"."
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilecore/iotile/core/utilities/command_file.py#L38-L47 | train |
iotile/coretools | iotilecore/iotile/core/utilities/command_file.py | CommandFile.save | def save(self, outpath):
"""Save this command file as an ascii file.
Agrs:
outpath (str): The output path to save.
"""
with open(outpath, "w") as outfile:
outfile.write(self.dump()) | python | def save(self, outpath):
"""Save this command file as an ascii file.
Agrs:
outpath (str): The output path to save.
"""
with open(outpath, "w") as outfile:
outfile.write(self.dump()) | [
"def",
"save",
"(",
"self",
",",
"outpath",
")",
":",
"with",
"open",
"(",
"outpath",
",",
"\"w\"",
")",
"as",
"outfile",
":",
"outfile",
".",
"write",
"(",
"self",
".",
"dump",
"(",
")",
")"
] | Save this command file as an ascii file.
Agrs:
outpath (str): The output path to save. | [
"Save",
"this",
"command",
"file",
"as",
"an",
"ascii",
"file",
"."
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilecore/iotile/core/utilities/command_file.py#L49-L57 | train |
iotile/coretools | iotilecore/iotile/core/utilities/command_file.py | CommandFile.dump | def dump(self):
"""Dump all commands in this object to a string.
Returns:
str: An encoded list of commands separated by
\n characters suitable for saving to a file.
"""
out = []
out.append(self.filetype)
out.append("Format: {}".format(self.v... | python | def dump(self):
"""Dump all commands in this object to a string.
Returns:
str: An encoded list of commands separated by
\n characters suitable for saving to a file.
"""
out = []
out.append(self.filetype)
out.append("Format: {}".format(self.v... | [
"def",
"dump",
"(",
"self",
")",
":",
"out",
"=",
"[",
"]",
"out",
".",
"append",
"(",
"self",
".",
"filetype",
")",
"out",
".",
"append",
"(",
"\"Format: {}\"",
".",
"format",
"(",
"self",
".",
"version",
")",
")",
"out",
".",
"append",
"(",
"\"... | Dump all commands in this object to a string.
Returns:
str: An encoded list of commands separated by
\n characters suitable for saving to a file. | [
"Dump",
"all",
"commands",
"in",
"this",
"object",
"to",
"a",
"string",
"."
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilecore/iotile/core/utilities/command_file.py#L59-L77 | train |
iotile/coretools | iotilecore/iotile/core/utilities/command_file.py | CommandFile.FromString | def FromString(cls, indata):
"""Load a CommandFile from a string.
The string should be produced from a previous call to
encode.
Args:
indata (str): The encoded input data.
Returns:
CommandFile: The decoded CommandFile object.
"""
lines ... | python | def FromString(cls, indata):
"""Load a CommandFile from a string.
The string should be produced from a previous call to
encode.
Args:
indata (str): The encoded input data.
Returns:
CommandFile: The decoded CommandFile object.
"""
lines ... | [
"def",
"FromString",
"(",
"cls",
",",
"indata",
")",
":",
"lines",
"=",
"[",
"x",
".",
"strip",
"(",
")",
"for",
"x",
"in",
"indata",
".",
"split",
"(",
"\"\\n\"",
")",
"if",
"not",
"x",
".",
"startswith",
"(",
"'#'",
")",
"and",
"not",
"x",
".... | Load a CommandFile from a string.
The string should be produced from a previous call to
encode.
Args:
indata (str): The encoded input data.
Returns:
CommandFile: The decoded CommandFile object. | [
"Load",
"a",
"CommandFile",
"from",
"a",
"string",
"."
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilecore/iotile/core/utilities/command_file.py#L80-L109 | train |
iotile/coretools | iotilecore/iotile/core/utilities/command_file.py | CommandFile.FromFile | def FromFile(cls, inpath):
"""Load a CommandFile from a path.
Args:
inpath (str): The path to the file to load
Returns:
CommandFile: The decoded CommandFile object.
"""
with open(inpath, "r") as infile:
indata = infile.read()
return... | python | def FromFile(cls, inpath):
"""Load a CommandFile from a path.
Args:
inpath (str): The path to the file to load
Returns:
CommandFile: The decoded CommandFile object.
"""
with open(inpath, "r") as infile:
indata = infile.read()
return... | [
"def",
"FromFile",
"(",
"cls",
",",
"inpath",
")",
":",
"with",
"open",
"(",
"inpath",
",",
"\"r\"",
")",
"as",
"infile",
":",
"indata",
"=",
"infile",
".",
"read",
"(",
")",
"return",
"cls",
".",
"FromString",
"(",
"indata",
")"
] | Load a CommandFile from a path.
Args:
inpath (str): The path to the file to load
Returns:
CommandFile: The decoded CommandFile object. | [
"Load",
"a",
"CommandFile",
"from",
"a",
"path",
"."
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilecore/iotile/core/utilities/command_file.py#L112-L125 | train |
iotile/coretools | iotilecore/iotile/core/utilities/command_file.py | CommandFile.encode | def encode(cls, command):
"""Encode a command as an unambiguous string.
Args:
command (Command): The command to encode.
Returns:
str: The encoded command
"""
args = []
for arg in command.args:
if not isinstance(arg, str):
... | python | def encode(cls, command):
"""Encode a command as an unambiguous string.
Args:
command (Command): The command to encode.
Returns:
str: The encoded command
"""
args = []
for arg in command.args:
if not isinstance(arg, str):
... | [
"def",
"encode",
"(",
"cls",
",",
"command",
")",
":",
"args",
"=",
"[",
"]",
"for",
"arg",
"in",
"command",
".",
"args",
":",
"if",
"not",
"isinstance",
"(",
"arg",
",",
"str",
")",
":",
"arg",
"=",
"str",
"(",
"arg",
")",
"if",
"\",\"",
"in",... | Encode a command as an unambiguous string.
Args:
command (Command): The command to encode.
Returns:
str: The encoded command | [
"Encode",
"a",
"command",
"as",
"an",
"unambiguous",
"string",
"."
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilecore/iotile/core/utilities/command_file.py#L128-L153 | train |
iotile/coretools | iotilecore/iotile/core/utilities/command_file.py | CommandFile.decode | def decode(cls, command_str):
"""Decode a string encoded command back into a Command object.
Args:
command_str (str): The encoded command string output from a
previous call to encode.
Returns:
Command: The decoded Command object.
"""
nam... | python | def decode(cls, command_str):
"""Decode a string encoded command back into a Command object.
Args:
command_str (str): The encoded command string output from a
previous call to encode.
Returns:
Command: The decoded Command object.
"""
nam... | [
"def",
"decode",
"(",
"cls",
",",
"command_str",
")",
":",
"name",
",",
"_",
",",
"arg",
"=",
"command_str",
".",
"partition",
"(",
"\" \"",
")",
"args",
"=",
"[",
"]",
"if",
"len",
"(",
"arg",
")",
">",
"0",
":",
"if",
"arg",
"[",
"0",
"]",
... | Decode a string encoded command back into a Command object.
Args:
command_str (str): The encoded command string output from a
previous call to encode.
Returns:
Command: The decoded Command object. | [
"Decode",
"a",
"string",
"encoded",
"command",
"back",
"into",
"a",
"Command",
"object",
"."
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilecore/iotile/core/utilities/command_file.py#L156-L186 | train |
iotile/coretools | transport_plugins/awsiot/iotile_transport_awsiot/packet_queue.py | PacketQueue.receive | def receive(self, sequence, args):
"""Receive one packet
If the sequence number is one we've already seen before, it is dropped.
If it is not the next expected sequence number, it is put into the
_out_of_order queue to be processed once the holes in sequence number
are filled i... | python | def receive(self, sequence, args):
"""Receive one packet
If the sequence number is one we've already seen before, it is dropped.
If it is not the next expected sequence number, it is put into the
_out_of_order queue to be processed once the holes in sequence number
are filled i... | [
"def",
"receive",
"(",
"self",
",",
"sequence",
",",
"args",
")",
":",
"if",
"not",
"self",
".",
"_reorder",
":",
"self",
".",
"_callback",
"(",
"*",
"args",
")",
"return",
"if",
"self",
".",
"_next_expected",
"is",
"not",
"None",
"and",
"sequence",
... | Receive one packet
If the sequence number is one we've already seen before, it is dropped.
If it is not the next expected sequence number, it is put into the
_out_of_order queue to be processed once the holes in sequence number
are filled in.
Args:
sequence (int): ... | [
"Receive",
"one",
"packet"
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/transport_plugins/awsiot/iotile_transport_awsiot/packet_queue.py#L33-L70 | train |
iotile/coretools | iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/mwcc.py | set_vars | def set_vars(env):
"""Set MWCW_VERSION, MWCW_VERSIONS, and some codewarrior environment vars
MWCW_VERSIONS is set to a list of objects representing installed versions
MWCW_VERSION is set to the version object that will be used for building.
MWCW_VERSION can be set to a string during Env... | python | def set_vars(env):
"""Set MWCW_VERSION, MWCW_VERSIONS, and some codewarrior environment vars
MWCW_VERSIONS is set to a list of objects representing installed versions
MWCW_VERSION is set to the version object that will be used for building.
MWCW_VERSION can be set to a string during Env... | [
"def",
"set_vars",
"(",
"env",
")",
":",
"desired",
"=",
"env",
".",
"get",
"(",
"'MWCW_VERSION'",
",",
"''",
")",
"if",
"isinstance",
"(",
"desired",
",",
"MWVersion",
")",
":",
"return",
"1",
"elif",
"desired",
"is",
"None",
":",
"return",
"0",
"ve... | Set MWCW_VERSION, MWCW_VERSIONS, and some codewarrior environment vars
MWCW_VERSIONS is set to a list of objects representing installed versions
MWCW_VERSION is set to the version object that will be used for building.
MWCW_VERSION can be set to a string during Environment
... | [
"Set",
"MWCW_VERSION",
"MWCW_VERSIONS",
"and",
"some",
"codewarrior",
"environment",
"vars"
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/mwcc.py#L40-L84 | train |
iotile/coretools | iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/mwcc.py | find_versions | def find_versions():
"""Return a list of MWVersion objects representing installed versions"""
versions = []
### This function finds CodeWarrior by reading from the registry on
### Windows. Some other method needs to be implemented for other
### platforms, maybe something that calls env.WhereIs('mwc... | python | def find_versions():
"""Return a list of MWVersion objects representing installed versions"""
versions = []
### This function finds CodeWarrior by reading from the registry on
### Windows. Some other method needs to be implemented for other
### platforms, maybe something that calls env.WhereIs('mwc... | [
"def",
"find_versions",
"(",
")",
":",
"versions",
"=",
"[",
"]",
"if",
"SCons",
".",
"Util",
".",
"can_read_reg",
":",
"try",
":",
"HLM",
"=",
"SCons",
".",
"Util",
".",
"HKEY_LOCAL_MACHINE",
"product",
"=",
"'SOFTWARE\\\\Metrowerks\\\\CodeWarrior\\\\Product Ve... | Return a list of MWVersion objects representing installed versions | [
"Return",
"a",
"list",
"of",
"MWVersion",
"objects",
"representing",
"installed",
"versions"
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/mwcc.py#L87-L119 | train |
iotile/coretools | iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/mwcc.py | generate | def generate(env):
"""Add Builders and construction variables for the mwcc to an Environment."""
import SCons.Defaults
import SCons.Tool
set_vars(env)
static_obj, shared_obj = SCons.Tool.createObjBuilders(env)
for suffix in CSuffixes:
static_obj.add_action(suffix, SCons.Defaults.CActi... | python | def generate(env):
"""Add Builders and construction variables for the mwcc to an Environment."""
import SCons.Defaults
import SCons.Tool
set_vars(env)
static_obj, shared_obj = SCons.Tool.createObjBuilders(env)
for suffix in CSuffixes:
static_obj.add_action(suffix, SCons.Defaults.CActi... | [
"def",
"generate",
"(",
"env",
")",
":",
"import",
"SCons",
".",
"Defaults",
"import",
"SCons",
".",
"Tool",
"set_vars",
"(",
"env",
")",
"static_obj",
",",
"shared_obj",
"=",
"SCons",
".",
"Tool",
".",
"createObjBuilders",
"(",
"env",
")",
"for",
"suffi... | Add Builders and construction variables for the mwcc to an Environment. | [
"Add",
"Builders",
"and",
"construction",
"variables",
"for",
"the",
"mwcc",
"to",
"an",
"Environment",
"."
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/mwcc.py#L155-L194 | train |
iotile/coretools | iotilecore/iotile/core/hw/debug/flash_board_step.py | FlashBoardStep.run | def run(self, resources):
"""Runs the flash step
Args:
resources (dict): A dictionary containing the required resources that
we needed access to in order to perform this step.
"""
if not resources['connection']._port.startswith('jlink'):
raise Arg... | python | def run(self, resources):
"""Runs the flash step
Args:
resources (dict): A dictionary containing the required resources that
we needed access to in order to perform this step.
"""
if not resources['connection']._port.startswith('jlink'):
raise Arg... | [
"def",
"run",
"(",
"self",
",",
"resources",
")",
":",
"if",
"not",
"resources",
"[",
"'connection'",
"]",
".",
"_port",
".",
"startswith",
"(",
"'jlink'",
")",
":",
"raise",
"ArgumentError",
"(",
"\"FlashBoardStep is currently only possible through jlink\"",
",",... | Runs the flash step
Args:
resources (dict): A dictionary containing the required resources that
we needed access to in order to perform this step. | [
"Runs",
"the",
"flash",
"step"
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilecore/iotile/core/hw/debug/flash_board_step.py#L26-L38 | train |
iotile/coretools | iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/filesystem.py | copyto_emitter | def copyto_emitter(target, source, env):
""" changes the path of the source to be under the target (which
are assumed to be directories.
"""
n_target = []
for t in target:
n_target = n_target + [t.File( str( s ) ) for s in source]
return (n_target, source) | python | def copyto_emitter(target, source, env):
""" changes the path of the source to be under the target (which
are assumed to be directories.
"""
n_target = []
for t in target:
n_target = n_target + [t.File( str( s ) ) for s in source]
return (n_target, source) | [
"def",
"copyto_emitter",
"(",
"target",
",",
"source",
",",
"env",
")",
":",
"n_target",
"=",
"[",
"]",
"for",
"t",
"in",
"target",
":",
"n_target",
"=",
"n_target",
"+",
"[",
"t",
".",
"File",
"(",
"str",
"(",
"s",
")",
")",
"for",
"s",
"in",
... | changes the path of the source to be under the target (which
are assumed to be directories. | [
"changes",
"the",
"path",
"of",
"the",
"source",
"to",
"be",
"under",
"the",
"target",
"(",
"which",
"are",
"assumed",
"to",
"be",
"directories",
"."
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/filesystem.py#L40-L49 | train |
iotile/coretools | iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/PharLapCommon.py | getPharLapPath | def getPharLapPath():
"""Reads the registry to find the installed path of the Phar Lap ETS
development kit.
Raises UserError if no installed version of Phar Lap can
be found."""
if not SCons.Util.can_read_reg:
raise SCons.Errors.InternalError("No Windows registry module was found")
try... | python | def getPharLapPath():
"""Reads the registry to find the installed path of the Phar Lap ETS
development kit.
Raises UserError if no installed version of Phar Lap can
be found."""
if not SCons.Util.can_read_reg:
raise SCons.Errors.InternalError("No Windows registry module was found")
try... | [
"def",
"getPharLapPath",
"(",
")",
":",
"if",
"not",
"SCons",
".",
"Util",
".",
"can_read_reg",
":",
"raise",
"SCons",
".",
"Errors",
".",
"InternalError",
"(",
"\"No Windows registry module was found\"",
")",
"try",
":",
"k",
"=",
"SCons",
".",
"Util",
".",... | Reads the registry to find the installed path of the Phar Lap ETS
development kit.
Raises UserError if no installed version of Phar Lap can
be found. | [
"Reads",
"the",
"registry",
"to",
"find",
"the",
"installed",
"path",
"of",
"the",
"Phar",
"Lap",
"ETS",
"development",
"kit",
"."
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/PharLapCommon.py#L40-L64 | train |
iotile/coretools | iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/PharLapCommon.py | addPharLapPaths | def addPharLapPaths(env):
"""This function adds the path to the Phar Lap binaries, includes,
and libraries, if they are not already there."""
ph_path = getPharLapPath()
try:
env_dict = env['ENV']
except KeyError:
env_dict = {}
env['ENV'] = env_dict
SCons.Util.AddPathIfNo... | python | def addPharLapPaths(env):
"""This function adds the path to the Phar Lap binaries, includes,
and libraries, if they are not already there."""
ph_path = getPharLapPath()
try:
env_dict = env['ENV']
except KeyError:
env_dict = {}
env['ENV'] = env_dict
SCons.Util.AddPathIfNo... | [
"def",
"addPharLapPaths",
"(",
"env",
")",
":",
"ph_path",
"=",
"getPharLapPath",
"(",
")",
"try",
":",
"env_dict",
"=",
"env",
"[",
"'ENV'",
"]",
"except",
"KeyError",
":",
"env_dict",
"=",
"{",
"}",
"env",
"[",
"'ENV'",
"]",
"=",
"env_dict",
"SCons",... | This function adds the path to the Phar Lap binaries, includes,
and libraries, if they are not already there. | [
"This",
"function",
"adds",
"the",
"path",
"to",
"the",
"Phar",
"Lap",
"binaries",
"includes",
"and",
"libraries",
"if",
"they",
"are",
"not",
"already",
"there",
"."
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/PharLapCommon.py#L88-L108 | train |
iotile/coretools | iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/msgmerge.py | _update_or_init_po_files | def _update_or_init_po_files(target, source, env):
""" Action function for `POUpdate` builder """
import SCons.Action
from SCons.Tool.GettextCommon import _init_po_files
for tgt in target:
if tgt.rexists():
action = SCons.Action.Action('$MSGMERGECOM', '$MSGMERGECOMSTR')
else:
action = _init_... | python | def _update_or_init_po_files(target, source, env):
""" Action function for `POUpdate` builder """
import SCons.Action
from SCons.Tool.GettextCommon import _init_po_files
for tgt in target:
if tgt.rexists():
action = SCons.Action.Action('$MSGMERGECOM', '$MSGMERGECOMSTR')
else:
action = _init_... | [
"def",
"_update_or_init_po_files",
"(",
"target",
",",
"source",
",",
"env",
")",
":",
"import",
"SCons",
".",
"Action",
"from",
"SCons",
".",
"Tool",
".",
"GettextCommon",
"import",
"_init_po_files",
"for",
"tgt",
"in",
"target",
":",
"if",
"tgt",
".",
"r... | Action function for `POUpdate` builder | [
"Action",
"function",
"for",
"POUpdate",
"builder"
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/msgmerge.py#L30-L41 | train |
iotile/coretools | iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/msgmerge.py | _POUpdateBuilder | def _POUpdateBuilder(env, **kw):
""" Create an object of `POUpdate` builder """
import SCons.Action
from SCons.Tool.GettextCommon import _POFileBuilder
action = SCons.Action.Action(_update_or_init_po_files, None)
return _POFileBuilder(env, action=action, target_alias='$POUPDATE_ALIAS') | python | def _POUpdateBuilder(env, **kw):
""" Create an object of `POUpdate` builder """
import SCons.Action
from SCons.Tool.GettextCommon import _POFileBuilder
action = SCons.Action.Action(_update_or_init_po_files, None)
return _POFileBuilder(env, action=action, target_alias='$POUPDATE_ALIAS') | [
"def",
"_POUpdateBuilder",
"(",
"env",
",",
"**",
"kw",
")",
":",
"import",
"SCons",
".",
"Action",
"from",
"SCons",
".",
"Tool",
".",
"GettextCommon",
"import",
"_POFileBuilder",
"action",
"=",
"SCons",
".",
"Action",
".",
"Action",
"(",
"_update_or_init_po... | Create an object of `POUpdate` builder | [
"Create",
"an",
"object",
"of",
"POUpdate",
"builder"
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/msgmerge.py#L45-L50 | train |
iotile/coretools | iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/msgmerge.py | _POUpdateBuilderWrapper | def _POUpdateBuilderWrapper(env, target=None, source=_null, **kw):
""" Wrapper for `POUpdate` builder - make user's life easier """
if source is _null:
if 'POTDOMAIN' in kw:
domain = kw['POTDOMAIN']
elif 'POTDOMAIN' in env and env['POTDOMAIN']:
domain = env['POTDOMAIN']
else:
domain = ... | python | def _POUpdateBuilderWrapper(env, target=None, source=_null, **kw):
""" Wrapper for `POUpdate` builder - make user's life easier """
if source is _null:
if 'POTDOMAIN' in kw:
domain = kw['POTDOMAIN']
elif 'POTDOMAIN' in env and env['POTDOMAIN']:
domain = env['POTDOMAIN']
else:
domain = ... | [
"def",
"_POUpdateBuilderWrapper",
"(",
"env",
",",
"target",
"=",
"None",
",",
"source",
"=",
"_null",
",",
"**",
"kw",
")",
":",
"if",
"source",
"is",
"_null",
":",
"if",
"'POTDOMAIN'",
"in",
"kw",
":",
"domain",
"=",
"kw",
"[",
"'POTDOMAIN'",
"]",
... | Wrapper for `POUpdate` builder - make user's life easier | [
"Wrapper",
"for",
"POUpdate",
"builder",
"-",
"make",
"user",
"s",
"life",
"easier"
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/msgmerge.py#L56-L66 | train |
iotile/coretools | iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/msgmerge.py | generate | def generate(env,**kw):
""" Generate the `xgettext` tool """
from SCons.Tool.GettextCommon import _detect_msgmerge
try:
env['MSGMERGE'] = _detect_msgmerge(env)
except:
env['MSGMERGE'] = 'msgmerge'
env.SetDefault(
POTSUFFIX = ['.pot'],
POSUFFIX = ['.po'],
MSGMERGECOM = '$MSGMERGE $MSGMERGE... | python | def generate(env,**kw):
""" Generate the `xgettext` tool """
from SCons.Tool.GettextCommon import _detect_msgmerge
try:
env['MSGMERGE'] = _detect_msgmerge(env)
except:
env['MSGMERGE'] = 'msgmerge'
env.SetDefault(
POTSUFFIX = ['.pot'],
POSUFFIX = ['.po'],
MSGMERGECOM = '$MSGMERGE $MSGMERGE... | [
"def",
"generate",
"(",
"env",
",",
"**",
"kw",
")",
":",
"from",
"SCons",
".",
"Tool",
".",
"GettextCommon",
"import",
"_detect_msgmerge",
"try",
":",
"env",
"[",
"'MSGMERGE'",
"]",
"=",
"_detect_msgmerge",
"(",
"env",
")",
"except",
":",
"env",
"[",
... | Generate the `xgettext` tool | [
"Generate",
"the",
"xgettext",
"tool"
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/msgmerge.py#L70-L87 | train |
iotile/coretools | iotilebuild/iotile/build/build/depends.py | ProductResolver._create_filter | def _create_filter(self):
"""Create a filter of all of the dependency products that we have selected."""
self._product_filter = {}
for chip in itertools.chain(iter(self._family.targets(self._tile.short_name)),
iter([self._family.platform_independent_target()... | python | def _create_filter(self):
"""Create a filter of all of the dependency products that we have selected."""
self._product_filter = {}
for chip in itertools.chain(iter(self._family.targets(self._tile.short_name)),
iter([self._family.platform_independent_target()... | [
"def",
"_create_filter",
"(",
"self",
")",
":",
"self",
".",
"_product_filter",
"=",
"{",
"}",
"for",
"chip",
"in",
"itertools",
".",
"chain",
"(",
"iter",
"(",
"self",
".",
"_family",
".",
"targets",
"(",
"self",
".",
"_tile",
".",
"short_name",
")",
... | Create a filter of all of the dependency products that we have selected. | [
"Create",
"a",
"filter",
"of",
"all",
"of",
"the",
"dependency",
"products",
"that",
"we",
"have",
"selected",
"."
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/build/depends.py#L38-L52 | train |
iotile/coretools | iotilebuild/iotile/build/build/depends.py | ProductResolver._create_product_map | def _create_product_map(self):
"""Create a map of all products produced by this or a dependency."""
self._product_map = {}
for dep in self._tile.dependencies:
try:
dep_tile = IOTile(os.path.join('build', 'deps', dep['unique_id']))
except (ArgumentError, ... | python | def _create_product_map(self):
"""Create a map of all products produced by this or a dependency."""
self._product_map = {}
for dep in self._tile.dependencies:
try:
dep_tile = IOTile(os.path.join('build', 'deps', dep['unique_id']))
except (ArgumentError, ... | [
"def",
"_create_product_map",
"(",
"self",
")",
":",
"self",
".",
"_product_map",
"=",
"{",
"}",
"for",
"dep",
"in",
"self",
".",
"_tile",
".",
"dependencies",
":",
"try",
":",
"dep_tile",
"=",
"IOTile",
"(",
"os",
".",
"path",
".",
"join",
"(",
"'bu... | Create a map of all products produced by this or a dependency. | [
"Create",
"a",
"map",
"of",
"all",
"products",
"produced",
"by",
"this",
"or",
"a",
"dependency",
"."
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/build/depends.py#L63-L76 | train |
iotile/coretools | iotilebuild/iotile/build/build/depends.py | ProductResolver._add_products | def _add_products(self, tile, show_all=False):
"""Add all products from a tile into our product map."""
products = tile.products
unique_id = tile.unique_id
base_path = tile.output_folder
for prod_path, prod_type in products.items():
# We need to handle include_direc... | python | def _add_products(self, tile, show_all=False):
"""Add all products from a tile into our product map."""
products = tile.products
unique_id = tile.unique_id
base_path = tile.output_folder
for prod_path, prod_type in products.items():
# We need to handle include_direc... | [
"def",
"_add_products",
"(",
"self",
",",
"tile",
",",
"show_all",
"=",
"False",
")",
":",
"products",
"=",
"tile",
".",
"products",
"unique_id",
"=",
"tile",
".",
"unique_id",
"base_path",
"=",
"tile",
".",
"output_folder",
"for",
"prod_path",
",",
"prod_... | Add all products from a tile into our product map. | [
"Add",
"all",
"products",
"from",
"a",
"tile",
"into",
"our",
"product",
"map",
"."
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/build/depends.py#L78-L106 | train |
iotile/coretools | iotilebuild/iotile/build/build/depends.py | ProductResolver.find_all | def find_all(self, product_type, short_name, include_hidden=False):
"""Find all providers of a given product by its short name.
This function will return all providers of a given product. If you
want to ensure that a product's name is unique among all dependencies,
you should use find_u... | python | def find_all(self, product_type, short_name, include_hidden=False):
"""Find all providers of a given product by its short name.
This function will return all providers of a given product. If you
want to ensure that a product's name is unique among all dependencies,
you should use find_u... | [
"def",
"find_all",
"(",
"self",
",",
"product_type",
",",
"short_name",
",",
"include_hidden",
"=",
"False",
")",
":",
"all_prods",
"=",
"[",
"]",
"if",
"product_type",
"is",
"None",
":",
"for",
"prod_dict",
"in",
"self",
".",
"_product_map",
".",
"values"... | Find all providers of a given product by its short name.
This function will return all providers of a given product. If you
want to ensure that a product's name is unique among all dependencies,
you should use find_unique.
Args:
product_type (str): The type of product that ... | [
"Find",
"all",
"providers",
"of",
"a",
"given",
"product",
"by",
"its",
"short",
"name",
"."
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/build/depends.py#L108-L140 | train |
iotile/coretools | iotilebuild/iotile/build/build/depends.py | ProductResolver.find_unique | def find_unique(self, product_type, short_name, include_hidden=False):
"""Find the unique provider of a given product by its short name.
This function will ensure that the product is only provided by exactly
one tile (either this tile or one of its dependencies and raise a
BuildError if... | python | def find_unique(self, product_type, short_name, include_hidden=False):
"""Find the unique provider of a given product by its short name.
This function will ensure that the product is only provided by exactly
one tile (either this tile or one of its dependencies and raise a
BuildError if... | [
"def",
"find_unique",
"(",
"self",
",",
"product_type",
",",
"short_name",
",",
"include_hidden",
"=",
"False",
")",
":",
"prods",
"=",
"self",
".",
"find_all",
"(",
"product_type",
",",
"short_name",
",",
"include_hidden",
")",
"if",
"len",
"(",
"prods",
... | Find the unique provider of a given product by its short name.
This function will ensure that the product is only provided by exactly
one tile (either this tile or one of its dependencies and raise a
BuildError if not.
Args:
product_type (str): The type of product that we a... | [
"Find",
"the",
"unique",
"provider",
"of",
"a",
"given",
"product",
"by",
"its",
"short",
"name",
"."
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/build/depends.py#L142-L173 | train |
iotile/coretools | iotilebuild/iotile/build/scripts/iotile_tbcompile.py | main | def main(raw_args=None):
"""Run the iotile-tbcompile script.
Args:
raw_args (list): Optional list of command line arguments. If not
passed these are pulled from sys.argv.
"""
multifile_choices = frozenset(['c_files'])
if raw_args is None:
raw_args = sys.argv[1:]
... | python | def main(raw_args=None):
"""Run the iotile-tbcompile script.
Args:
raw_args (list): Optional list of command line arguments. If not
passed these are pulled from sys.argv.
"""
multifile_choices = frozenset(['c_files'])
if raw_args is None:
raw_args = sys.argv[1:]
... | [
"def",
"main",
"(",
"raw_args",
"=",
"None",
")",
":",
"multifile_choices",
"=",
"frozenset",
"(",
"[",
"'c_files'",
"]",
")",
"if",
"raw_args",
"is",
"None",
":",
"raw_args",
"=",
"sys",
".",
"argv",
"[",
"1",
":",
"]",
"parser",
"=",
"build_parser",
... | Run the iotile-tbcompile script.
Args:
raw_args (list): Optional list of command line arguments. If not
passed these are pulled from sys.argv. | [
"Run",
"the",
"iotile",
"-",
"tbcompile",
"script",
"."
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/scripts/iotile_tbcompile.py#L37-L77 | train |
iotile/coretools | iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/rpcgen.py | generate | def generate(env):
"Add RPCGEN Builders and construction variables for an Environment."
client = Builder(action=rpcgen_client, suffix='_clnt.c', src_suffix='.x')
header = Builder(action=rpcgen_header, suffix='.h', src_suffix='.x')
service = Builder(action=rpcgen_service, suffix='_svc.c', ... | python | def generate(env):
"Add RPCGEN Builders and construction variables for an Environment."
client = Builder(action=rpcgen_client, suffix='_clnt.c', src_suffix='.x')
header = Builder(action=rpcgen_header, suffix='.h', src_suffix='.x')
service = Builder(action=rpcgen_service, suffix='_svc.c', ... | [
"def",
"generate",
"(",
"env",
")",
":",
"\"Add RPCGEN Builders and construction variables for an Environment.\"",
"client",
"=",
"Builder",
"(",
"action",
"=",
"rpcgen_client",
",",
"suffix",
"=",
"'_clnt.c'",
",",
"src_suffix",
"=",
"'.x'",
")",
"header",
"=",
"Bu... | Add RPCGEN Builders and construction variables for an Environment. | [
"Add",
"RPCGEN",
"Builders",
"and",
"construction",
"variables",
"for",
"an",
"Environment",
"."
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/rpcgen.py#L45-L61 | train |
iotile/coretools | scripts/release.py | build_parser | def build_parser():
"""Build argument parsers."""
parser = argparse.ArgumentParser("Release packages to pypi")
parser.add_argument('--check', '-c', action="store_true", help="Do a dry run without uploading")
parser.add_argument('component', help="The component to release as component-version")
retu... | python | def build_parser():
"""Build argument parsers."""
parser = argparse.ArgumentParser("Release packages to pypi")
parser.add_argument('--check', '-c', action="store_true", help="Do a dry run without uploading")
parser.add_argument('component', help="The component to release as component-version")
retu... | [
"def",
"build_parser",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"\"Release packages to pypi\"",
")",
"parser",
".",
"add_argument",
"(",
"'--check'",
",",
"'-c'",
",",
"action",
"=",
"\"store_true\"",
",",
"help",
"=",
"\"Do a dry ru... | Build argument parsers. | [
"Build",
"argument",
"parsers",
"."
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/scripts/release.py#L21-L27 | train |
iotile/coretools | scripts/release.py | get_release_component | def get_release_component(comp):
"""Split the argument passed on the command line into a component name and expected version"""
name, vers = comp.split("-")
if name not in comp_names:
print("Known components:")
for comp in comp_names:
print("- %s" % comp)
raise Environ... | python | def get_release_component(comp):
"""Split the argument passed on the command line into a component name and expected version"""
name, vers = comp.split("-")
if name not in comp_names:
print("Known components:")
for comp in comp_names:
print("- %s" % comp)
raise Environ... | [
"def",
"get_release_component",
"(",
"comp",
")",
":",
"name",
",",
"vers",
"=",
"comp",
".",
"split",
"(",
"\"-\"",
")",
"if",
"name",
"not",
"in",
"comp_names",
":",
"print",
"(",
"\"Known components:\"",
")",
"for",
"comp",
"in",
"comp_names",
":",
"p... | Split the argument passed on the command line into a component name and expected version | [
"Split",
"the",
"argument",
"passed",
"on",
"the",
"command",
"line",
"into",
"a",
"component",
"name",
"and",
"expected",
"version"
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/scripts/release.py#L43-L55 | train |
iotile/coretools | scripts/release.py | check_compatibility | def check_compatibility(name):
"""Verify if we can release this component on the running interpreter.
All components are released from python 2.7 by default unless they specify
that they are python 3 only, in which case they are released from python 3.6
"""
comp = comp_names[name]
if sys.vers... | python | def check_compatibility(name):
"""Verify if we can release this component on the running interpreter.
All components are released from python 2.7 by default unless they specify
that they are python 3 only, in which case they are released from python 3.6
"""
comp = comp_names[name]
if sys.vers... | [
"def",
"check_compatibility",
"(",
"name",
")",
":",
"comp",
"=",
"comp_names",
"[",
"name",
"]",
"if",
"sys",
".",
"version_info",
".",
"major",
"<",
"3",
"and",
"comp",
".",
"compat",
"==",
"\"python3\"",
":",
"return",
"False",
"if",
"sys",
".",
"ve... | Verify if we can release this component on the running interpreter.
All components are released from python 2.7 by default unless they specify
that they are python 3 only, in which case they are released from python 3.6 | [
"Verify",
"if",
"we",
"can",
"release",
"this",
"component",
"on",
"the",
"running",
"interpreter",
"."
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/scripts/release.py#L58-L73 | train |
iotile/coretools | scripts/release.py | build_component | def build_component(component):
"""Create an sdist and a wheel for the desired component"""
comp = comp_names[component]
curr = os.getcwd()
os.chdir(comp.path)
args = ['-q', 'clean', 'sdist', 'bdist_wheel']
if comp.compat == 'universal':
args.append('--universal')
try:
se... | python | def build_component(component):
"""Create an sdist and a wheel for the desired component"""
comp = comp_names[component]
curr = os.getcwd()
os.chdir(comp.path)
args = ['-q', 'clean', 'sdist', 'bdist_wheel']
if comp.compat == 'universal':
args.append('--universal')
try:
se... | [
"def",
"build_component",
"(",
"component",
")",
":",
"comp",
"=",
"comp_names",
"[",
"component",
"]",
"curr",
"=",
"os",
".",
"getcwd",
"(",
")",
"os",
".",
"chdir",
"(",
"comp",
".",
"path",
")",
"args",
"=",
"[",
"'-q'",
",",
"'clean'",
",",
"'... | Create an sdist and a wheel for the desired component | [
"Create",
"an",
"sdist",
"and",
"a",
"wheel",
"for",
"the",
"desired",
"component"
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/scripts/release.py#L90-L105 | train |
iotile/coretools | iotilecore/iotile/core/utilities/gid.py | uuid_to_slug | def uuid_to_slug(uuid):
"""
Return IOTile Cloud compatible Device Slug
:param uuid: UUID
:return: string in the form of d--0000-0000-0000-0001
"""
if not isinstance(uuid, int):
raise ArgumentError("Invalid id that is not an integer", id=uuid)
if uuid < 0 or uuid > 0x7fffffff:
... | python | def uuid_to_slug(uuid):
"""
Return IOTile Cloud compatible Device Slug
:param uuid: UUID
:return: string in the form of d--0000-0000-0000-0001
"""
if not isinstance(uuid, int):
raise ArgumentError("Invalid id that is not an integer", id=uuid)
if uuid < 0 or uuid > 0x7fffffff:
... | [
"def",
"uuid_to_slug",
"(",
"uuid",
")",
":",
"if",
"not",
"isinstance",
"(",
"uuid",
",",
"int",
")",
":",
"raise",
"ArgumentError",
"(",
"\"Invalid id that is not an integer\"",
",",
"id",
"=",
"uuid",
")",
"if",
"uuid",
"<",
"0",
"or",
"uuid",
">",
"0... | Return IOTile Cloud compatible Device Slug
:param uuid: UUID
:return: string in the form of d--0000-0000-0000-0001 | [
"Return",
"IOTile",
"Cloud",
"compatible",
"Device",
"Slug"
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilecore/iotile/core/utilities/gid.py#L7-L21 | train |
iotile/coretools | iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/packaging/ipk.py | package | def package(env, target, source, PACKAGEROOT, NAME, VERSION, DESCRIPTION,
SUMMARY, X_IPK_PRIORITY, X_IPK_SECTION, SOURCE_URL,
X_IPK_MAINTAINER, X_IPK_DEPENDS, **kw):
""" This function prepares the packageroot directory for packaging with the
ipkg builder.
"""
SCons.Tool.Tool('ipk... | python | def package(env, target, source, PACKAGEROOT, NAME, VERSION, DESCRIPTION,
SUMMARY, X_IPK_PRIORITY, X_IPK_SECTION, SOURCE_URL,
X_IPK_MAINTAINER, X_IPK_DEPENDS, **kw):
""" This function prepares the packageroot directory for packaging with the
ipkg builder.
"""
SCons.Tool.Tool('ipk... | [
"def",
"package",
"(",
"env",
",",
"target",
",",
"source",
",",
"PACKAGEROOT",
",",
"NAME",
",",
"VERSION",
",",
"DESCRIPTION",
",",
"SUMMARY",
",",
"X_IPK_PRIORITY",
",",
"X_IPK_SECTION",
",",
"SOURCE_URL",
",",
"X_IPK_MAINTAINER",
",",
"X_IPK_DEPENDS",
",",... | This function prepares the packageroot directory for packaging with the
ipkg builder. | [
"This",
"function",
"prepares",
"the",
"packageroot",
"directory",
"for",
"packaging",
"with",
"the",
"ipkg",
"builder",
"."
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/packaging/ipk.py#L35-L79 | train |
iotile/coretools | iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/packaging/ipk.py | build_specfiles | def build_specfiles(source, target, env):
""" Filter the targets for the needed files and use the variables in env
to create the specfile.
"""
#
# At first we care for the CONTROL/control file, which is the main file for ipk.
#
# For this we need to open multiple files in random order, so we... | python | def build_specfiles(source, target, env):
""" Filter the targets for the needed files and use the variables in env
to create the specfile.
"""
#
# At first we care for the CONTROL/control file, which is the main file for ipk.
#
# For this we need to open multiple files in random order, so we... | [
"def",
"build_specfiles",
"(",
"source",
",",
"target",
",",
"env",
")",
":",
"opened_files",
"=",
"{",
"}",
"def",
"open_file",
"(",
"needle",
",",
"haystack",
")",
":",
"try",
":",
"return",
"opened_files",
"[",
"needle",
"]",
"except",
"KeyError",
":"... | Filter the targets for the needed files and use the variables in env
to create the specfile. | [
"Filter",
"the",
"targets",
"for",
"the",
"needed",
"files",
"and",
"use",
"the",
"variables",
"in",
"env",
"to",
"create",
"the",
"specfile",
"."
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/packaging/ipk.py#L106-L179 | train |
iotile/coretools | iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/javah.py | emit_java_headers | def emit_java_headers(target, source, env):
"""Create and return lists of Java stub header files that will
be created from a set of class files.
"""
class_suffix = env.get('JAVACLASSSUFFIX', '.class')
classdir = env.get('JAVACLASSDIR')
if not classdir:
try:
s = source[0]
... | python | def emit_java_headers(target, source, env):
"""Create and return lists of Java stub header files that will
be created from a set of class files.
"""
class_suffix = env.get('JAVACLASSSUFFIX', '.class')
classdir = env.get('JAVACLASSDIR')
if not classdir:
try:
s = source[0]
... | [
"def",
"emit_java_headers",
"(",
"target",
",",
"source",
",",
"env",
")",
":",
"class_suffix",
"=",
"env",
".",
"get",
"(",
"'JAVACLASSSUFFIX'",
",",
"'.class'",
")",
"classdir",
"=",
"env",
".",
"get",
"(",
"'JAVACLASSDIR'",
")",
"if",
"not",
"classdir",... | Create and return lists of Java stub header files that will
be created from a set of class files. | [
"Create",
"and",
"return",
"lists",
"of",
"Java",
"stub",
"header",
"files",
"that",
"will",
"be",
"created",
"from",
"a",
"set",
"of",
"class",
"files",
"."
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/javah.py#L44-L100 | train |
iotile/coretools | iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/javah.py | generate | def generate(env):
"""Add Builders and construction variables for javah to an Environment."""
java_javah = SCons.Tool.CreateJavaHBuilder(env)
java_javah.emitter = emit_java_headers
env['_JAVAHOUTFLAG'] = JavaHOutFlagGenerator
env['JAVAH'] = 'javah'
env['JAVAHFLAGS'] = SCons.... | python | def generate(env):
"""Add Builders and construction variables for javah to an Environment."""
java_javah = SCons.Tool.CreateJavaHBuilder(env)
java_javah.emitter = emit_java_headers
env['_JAVAHOUTFLAG'] = JavaHOutFlagGenerator
env['JAVAH'] = 'javah'
env['JAVAHFLAGS'] = SCons.... | [
"def",
"generate",
"(",
"env",
")",
":",
"java_javah",
"=",
"SCons",
".",
"Tool",
".",
"CreateJavaHBuilder",
"(",
"env",
")",
"java_javah",
".",
"emitter",
"=",
"emit_java_headers",
"env",
"[",
"'_JAVAHOUTFLAG'",
"]",
"=",
"JavaHOutFlagGenerator",
"env",
"[",
... | Add Builders and construction variables for javah to an Environment. | [
"Add",
"Builders",
"and",
"construction",
"variables",
"for",
"javah",
"to",
"an",
"Environment",
"."
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/javah.py#L118-L128 | train |
iotile/coretools | iotilesensorgraph/iotile/sg/engine/in_memory.py | InMemoryStorageEngine.dump | def dump(self):
"""Serialize the state of this InMemoryStorageEngine to a dict.
Returns:
dict: The serialized data.
"""
return {
u'storage_data': [x.asdict() for x in self.storage_data],
u'streaming_data': [x.asdict() for x in self.streaming_data]
... | python | def dump(self):
"""Serialize the state of this InMemoryStorageEngine to a dict.
Returns:
dict: The serialized data.
"""
return {
u'storage_data': [x.asdict() for x in self.storage_data],
u'streaming_data': [x.asdict() for x in self.streaming_data]
... | [
"def",
"dump",
"(",
"self",
")",
":",
"return",
"{",
"u'storage_data'",
":",
"[",
"x",
".",
"asdict",
"(",
")",
"for",
"x",
"in",
"self",
".",
"storage_data",
"]",
",",
"u'streaming_data'",
":",
"[",
"x",
".",
"asdict",
"(",
")",
"for",
"x",
"in",
... | Serialize the state of this InMemoryStorageEngine to a dict.
Returns:
dict: The serialized data. | [
"Serialize",
"the",
"state",
"of",
"this",
"InMemoryStorageEngine",
"to",
"a",
"dict",
"."
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilesensorgraph/iotile/sg/engine/in_memory.py#L26-L36 | train |
iotile/coretools | iotilesensorgraph/iotile/sg/engine/in_memory.py | InMemoryStorageEngine.restore | def restore(self, state):
"""Restore the state of this InMemoryStorageEngine from a dict."""
storage_data = state.get(u'storage_data', [])
streaming_data = state.get(u'streaming_data', [])
if len(storage_data) > self.storage_length or len(streaming_data) > self.streaming_length:
... | python | def restore(self, state):
"""Restore the state of this InMemoryStorageEngine from a dict."""
storage_data = state.get(u'storage_data', [])
streaming_data = state.get(u'streaming_data', [])
if len(storage_data) > self.storage_length or len(streaming_data) > self.streaming_length:
... | [
"def",
"restore",
"(",
"self",
",",
"state",
")",
":",
"storage_data",
"=",
"state",
".",
"get",
"(",
"u'storage_data'",
",",
"[",
"]",
")",
"streaming_data",
"=",
"state",
".",
"get",
"(",
"u'streaming_data'",
",",
"[",
"]",
")",
"if",
"len",
"(",
"... | Restore the state of this InMemoryStorageEngine from a dict. | [
"Restore",
"the",
"state",
"of",
"this",
"InMemoryStorageEngine",
"from",
"a",
"dict",
"."
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilesensorgraph/iotile/sg/engine/in_memory.py#L38-L50 | train |
iotile/coretools | iotilesensorgraph/iotile/sg/engine/in_memory.py | InMemoryStorageEngine.count_matching | def count_matching(self, selector, offset=0):
"""Count the number of readings matching selector.
Args:
selector (DataStreamSelector): The selector that we want to
count matching readings for.
offset (int): The starting offset that we should begin counting at.
... | python | def count_matching(self, selector, offset=0):
"""Count the number of readings matching selector.
Args:
selector (DataStreamSelector): The selector that we want to
count matching readings for.
offset (int): The starting offset that we should begin counting at.
... | [
"def",
"count_matching",
"(",
"self",
",",
"selector",
",",
"offset",
"=",
"0",
")",
":",
"if",
"selector",
".",
"output",
":",
"data",
"=",
"self",
".",
"streaming_data",
"elif",
"selector",
".",
"buffered",
":",
"data",
"=",
"self",
".",
"storage_data"... | Count the number of readings matching selector.
Args:
selector (DataStreamSelector): The selector that we want to
count matching readings for.
offset (int): The starting offset that we should begin counting at.
Returns:
int: The number of matching re... | [
"Count",
"the",
"number",
"of",
"readings",
"matching",
"selector",
"."
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilesensorgraph/iotile/sg/engine/in_memory.py#L61-L88 | train |
iotile/coretools | iotilesensorgraph/iotile/sg/engine/in_memory.py | InMemoryStorageEngine.scan_storage | def scan_storage(self, area_name, callable, start=0, stop=None):
"""Iterate over streaming or storage areas, calling callable.
Args:
area_name (str): Either 'storage' or 'streaming' to indicate which
storage area to scan.
callable (callable): A function that will... | python | def scan_storage(self, area_name, callable, start=0, stop=None):
"""Iterate over streaming or storage areas, calling callable.
Args:
area_name (str): Either 'storage' or 'streaming' to indicate which
storage area to scan.
callable (callable): A function that will... | [
"def",
"scan_storage",
"(",
"self",
",",
"area_name",
",",
"callable",
",",
"start",
"=",
"0",
",",
"stop",
"=",
"None",
")",
":",
"if",
"area_name",
"==",
"u'storage'",
":",
"data",
"=",
"self",
".",
"storage_data",
"elif",
"area_name",
"==",
"u'streami... | Iterate over streaming or storage areas, calling callable.
Args:
area_name (str): Either 'storage' or 'streaming' to indicate which
storage area to scan.
callable (callable): A function that will be called as (offset, reading)
for each reading between sta... | [
"Iterate",
"over",
"streaming",
"or",
"storage",
"areas",
"calling",
"callable",
"."
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilesensorgraph/iotile/sg/engine/in_memory.py#L90-L130 | train |
iotile/coretools | iotilesensorgraph/iotile/sg/engine/in_memory.py | InMemoryStorageEngine.push | def push(self, value):
"""Store a new value for the given stream.
Args:
value (IOTileReading): The value to store. The stream
parameter must have the correct value
"""
stream = DataStream.FromEncoded(value.stream)
if stream.stream_type == DataStrea... | python | def push(self, value):
"""Store a new value for the given stream.
Args:
value (IOTileReading): The value to store. The stream
parameter must have the correct value
"""
stream = DataStream.FromEncoded(value.stream)
if stream.stream_type == DataStrea... | [
"def",
"push",
"(",
"self",
",",
"value",
")",
":",
"stream",
"=",
"DataStream",
".",
"FromEncoded",
"(",
"value",
".",
"stream",
")",
"if",
"stream",
".",
"stream_type",
"==",
"DataStream",
".",
"OutputType",
":",
"if",
"len",
"(",
"self",
".",
"strea... | Store a new value for the given stream.
Args:
value (IOTileReading): The value to store. The stream
parameter must have the correct value | [
"Store",
"a",
"new",
"value",
"for",
"the",
"given",
"stream",
"."
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilesensorgraph/iotile/sg/engine/in_memory.py#L138-L157 | train |
iotile/coretools | iotilesensorgraph/iotile/sg/engine/in_memory.py | InMemoryStorageEngine.get | def get(self, buffer_type, offset):
"""Get a reading from the buffer at offset.
Offset is specified relative to the start of the data buffer.
This means that if the buffer rolls over, the offset for a given
item will appear to change. Anyone holding an offset outside of this
en... | python | def get(self, buffer_type, offset):
"""Get a reading from the buffer at offset.
Offset is specified relative to the start of the data buffer.
This means that if the buffer rolls over, the offset for a given
item will appear to change. Anyone holding an offset outside of this
en... | [
"def",
"get",
"(",
"self",
",",
"buffer_type",
",",
"offset",
")",
":",
"if",
"buffer_type",
"==",
"u'streaming'",
":",
"chosen_buffer",
"=",
"self",
".",
"streaming_data",
"else",
":",
"chosen_buffer",
"=",
"self",
".",
"storage_data",
"if",
"offset",
">=",... | Get a reading from the buffer at offset.
Offset is specified relative to the start of the data buffer.
This means that if the buffer rolls over, the offset for a given
item will appear to change. Anyone holding an offset outside of this
engine object will need to be notified when rollo... | [
"Get",
"a",
"reading",
"from",
"the",
"buffer",
"at",
"offset",
"."
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilesensorgraph/iotile/sg/engine/in_memory.py#L159-L181 | train |
iotile/coretools | iotilesensorgraph/iotile/sg/engine/in_memory.py | InMemoryStorageEngine.popn | def popn(self, buffer_type, count):
"""Remove and return the oldest count values from the named buffer
Args:
buffer_type (str): The buffer to pop from (either u"storage" or u"streaming")
count (int): The number of readings to pop
Returns:
list(IOTileReading)... | python | def popn(self, buffer_type, count):
"""Remove and return the oldest count values from the named buffer
Args:
buffer_type (str): The buffer to pop from (either u"storage" or u"streaming")
count (int): The number of readings to pop
Returns:
list(IOTileReading)... | [
"def",
"popn",
"(",
"self",
",",
"buffer_type",
",",
"count",
")",
":",
"buffer_type",
"=",
"str",
"(",
"buffer_type",
")",
"if",
"buffer_type",
"==",
"u'streaming'",
":",
"chosen_buffer",
"=",
"self",
".",
"streaming_data",
"else",
":",
"chosen_buffer",
"="... | Remove and return the oldest count values from the named buffer
Args:
buffer_type (str): The buffer to pop from (either u"storage" or u"streaming")
count (int): The number of readings to pop
Returns:
list(IOTileReading): The values popped from the buffer | [
"Remove",
"and",
"return",
"the",
"oldest",
"count",
"values",
"from",
"the",
"named",
"buffer"
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilesensorgraph/iotile/sg/engine/in_memory.py#L183-L212 | train |
iotile/coretools | transport_plugins/websocket/iotile_transport_websocket/device_adapter.py | WebSocketDeviceAdapter.send_script | async def send_script(self, conn_id, data):
"""Send a a script to this IOTile device
Args:
conn_id (int): A unique identifier that will refer to this connection
data (bytes): the script to send to the device
"""
self._ensure_connection(conn_id, True)
con... | python | async def send_script(self, conn_id, data):
"""Send a a script to this IOTile device
Args:
conn_id (int): A unique identifier that will refer to this connection
data (bytes): the script to send to the device
"""
self._ensure_connection(conn_id, True)
con... | [
"async",
"def",
"send_script",
"(",
"self",
",",
"conn_id",
",",
"data",
")",
":",
"self",
".",
"_ensure_connection",
"(",
"conn_id",
",",
"True",
")",
"connection_string",
"=",
"self",
".",
"_get_property",
"(",
"conn_id",
",",
"\"connection_string\"",
")",
... | Send a a script to this IOTile device
Args:
conn_id (int): A unique identifier that will refer to this connection
data (bytes): the script to send to the device | [
"Send",
"a",
"a",
"script",
"to",
"this",
"IOTile",
"device"
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/transport_plugins/websocket/iotile_transport_websocket/device_adapter.py#L154-L167 | train |
iotile/coretools | transport_plugins/websocket/iotile_transport_websocket/device_adapter.py | WebSocketDeviceAdapter._on_report_notification | async def _on_report_notification(self, event):
"""Callback function called when a report event is received.
Args:
event (dict): The report_event
"""
conn_string = event.get('connection_string')
report = self._report_parser.deserialize_report(event.get('serialized_r... | python | async def _on_report_notification(self, event):
"""Callback function called when a report event is received.
Args:
event (dict): The report_event
"""
conn_string = event.get('connection_string')
report = self._report_parser.deserialize_report(event.get('serialized_r... | [
"async",
"def",
"_on_report_notification",
"(",
"self",
",",
"event",
")",
":",
"conn_string",
"=",
"event",
".",
"get",
"(",
"'connection_string'",
")",
"report",
"=",
"self",
".",
"_report_parser",
".",
"deserialize_report",
"(",
"event",
".",
"get",
"(",
... | Callback function called when a report event is received.
Args:
event (dict): The report_event | [
"Callback",
"function",
"called",
"when",
"a",
"report",
"event",
"is",
"received",
"."
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/transport_plugins/websocket/iotile_transport_websocket/device_adapter.py#L178-L188 | train |
iotile/coretools | transport_plugins/websocket/iotile_transport_websocket/device_adapter.py | WebSocketDeviceAdapter._on_trace_notification | async def _on_trace_notification(self, trace_event):
"""Callback function called when a trace chunk is received.
Args:
trace_chunk (dict): The received trace chunk information
"""
conn_string = trace_event.get('connection_string')
payload = trace_event.get('payload'... | python | async def _on_trace_notification(self, trace_event):
"""Callback function called when a trace chunk is received.
Args:
trace_chunk (dict): The received trace chunk information
"""
conn_string = trace_event.get('connection_string')
payload = trace_event.get('payload'... | [
"async",
"def",
"_on_trace_notification",
"(",
"self",
",",
"trace_event",
")",
":",
"conn_string",
"=",
"trace_event",
".",
"get",
"(",
"'connection_string'",
")",
"payload",
"=",
"trace_event",
".",
"get",
"(",
"'payload'",
")",
"await",
"self",
".",
"notify... | Callback function called when a trace chunk is received.
Args:
trace_chunk (dict): The received trace chunk information | [
"Callback",
"function",
"called",
"when",
"a",
"trace",
"chunk",
"is",
"received",
"."
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/transport_plugins/websocket/iotile_transport_websocket/device_adapter.py#L202-L212 | train |
iotile/coretools | transport_plugins/websocket/iotile_transport_websocket/device_adapter.py | WebSocketDeviceAdapter._on_progress_notification | async def _on_progress_notification(self, progress):
"""Callback function called when a progress notification is received.
Args:
progress (dict): The received notification containing the progress information
"""
conn_string = progress.get('connection_string')
done =... | python | async def _on_progress_notification(self, progress):
"""Callback function called when a progress notification is received.
Args:
progress (dict): The received notification containing the progress information
"""
conn_string = progress.get('connection_string')
done =... | [
"async",
"def",
"_on_progress_notification",
"(",
"self",
",",
"progress",
")",
":",
"conn_string",
"=",
"progress",
".",
"get",
"(",
"'connection_string'",
")",
"done",
"=",
"progress",
".",
"get",
"(",
"'done_count'",
")",
"total",
"=",
"progress",
".",
"g... | Callback function called when a progress notification is received.
Args:
progress (dict): The received notification containing the progress information | [
"Callback",
"function",
"called",
"when",
"a",
"progress",
"notification",
"is",
"received",
"."
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/transport_plugins/websocket/iotile_transport_websocket/device_adapter.py#L214-L226 | train |
iotile/coretools | iotileship/iotile/ship/recipe.py | _extract_variables | def _extract_variables(param):
"""Find all template variables in args."""
variables = set()
if isinstance(param, list):
variables.update(*[_extract_variables(x) for x in param])
elif isinstance(param, dict):
variables.update(*[_extract_variables(x) for x in param.values()])
elif is... | python | def _extract_variables(param):
"""Find all template variables in args."""
variables = set()
if isinstance(param, list):
variables.update(*[_extract_variables(x) for x in param])
elif isinstance(param, dict):
variables.update(*[_extract_variables(x) for x in param.values()])
elif is... | [
"def",
"_extract_variables",
"(",
"param",
")",
":",
"variables",
"=",
"set",
"(",
")",
"if",
"isinstance",
"(",
"param",
",",
"list",
")",
":",
"variables",
".",
"update",
"(",
"*",
"[",
"_extract_variables",
"(",
"x",
")",
"for",
"x",
"in",
"param",
... | Find all template variables in args. | [
"Find",
"all",
"template",
"variables",
"in",
"args",
"."
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotileship/iotile/ship/recipe.py#L506-L522 | train |
iotile/coretools | iotileship/iotile/ship/recipe.py | _run_step | def _run_step(step_obj, step_declaration, initialized_resources):
"""Actually run a step."""
start_time = time.time()
# Open any resources that need to be opened before we run this step
for res_name in step_declaration.resources.opened:
initialized_resources[res_name].open()
# Create a di... | python | def _run_step(step_obj, step_declaration, initialized_resources):
"""Actually run a step."""
start_time = time.time()
# Open any resources that need to be opened before we run this step
for res_name in step_declaration.resources.opened:
initialized_resources[res_name].open()
# Create a di... | [
"def",
"_run_step",
"(",
"step_obj",
",",
"step_declaration",
",",
"initialized_resources",
")",
":",
"start_time",
"=",
"time",
".",
"time",
"(",
")",
"for",
"res_name",
"in",
"step_declaration",
".",
"resources",
".",
"opened",
":",
"initialized_resources",
"[... | Actually run a step. | [
"Actually",
"run",
"a",
"step",
"."
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotileship/iotile/ship/recipe.py#L525-L549 | train |
iotile/coretools | iotileship/iotile/ship/recipe.py | RecipeObject.archive | def archive(self, output_path):
"""Archive this recipe and all associated files into a .ship archive.
Args:
output_path (str): The path where the .ship file should be saved.
"""
if self.path is None:
raise ArgumentError("Cannot archive a recipe yet without a ref... | python | def archive(self, output_path):
"""Archive this recipe and all associated files into a .ship archive.
Args:
output_path (str): The path where the .ship file should be saved.
"""
if self.path is None:
raise ArgumentError("Cannot archive a recipe yet without a ref... | [
"def",
"archive",
"(",
"self",
",",
"output_path",
")",
":",
"if",
"self",
".",
"path",
"is",
"None",
":",
"raise",
"ArgumentError",
"(",
"\"Cannot archive a recipe yet without a reference to its original yaml file in self.path\"",
")",
"outfile",
"=",
"zipfile",
".",
... | Archive this recipe and all associated files into a .ship archive.
Args:
output_path (str): The path where the .ship file should be saved. | [
"Archive",
"this",
"recipe",
"and",
"all",
"associated",
"files",
"into",
"a",
".",
"ship",
"archive",
"."
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotileship/iotile/ship/recipe.py#L86-L114 | train |
iotile/coretools | iotileship/iotile/ship/recipe.py | RecipeObject.FromArchive | def FromArchive(cls, path, actions_dict, resources_dict, temp_dir=None):
"""Create a RecipeObject from a .ship archive.
This archive should have been generated from a previous call to
iotile-ship -a <path to yaml file>
or via iotile-build using autobuild_shiparchive().
Args:
... | python | def FromArchive(cls, path, actions_dict, resources_dict, temp_dir=None):
"""Create a RecipeObject from a .ship archive.
This archive should have been generated from a previous call to
iotile-ship -a <path to yaml file>
or via iotile-build using autobuild_shiparchive().
Args:
... | [
"def",
"FromArchive",
"(",
"cls",
",",
"path",
",",
"actions_dict",
",",
"resources_dict",
",",
"temp_dir",
"=",
"None",
")",
":",
"if",
"not",
"path",
".",
"endswith",
"(",
"\".ship\"",
")",
":",
"raise",
"ArgumentError",
"(",
"\"Attempted to unpack a recipe ... | Create a RecipeObject from a .ship archive.
This archive should have been generated from a previous call to
iotile-ship -a <path to yaml file>
or via iotile-build using autobuild_shiparchive().
Args:
path (str): The path to the recipe file that we wish to load
... | [
"Create",
"a",
"RecipeObject",
"from",
"a",
".",
"ship",
"archive",
"."
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotileship/iotile/ship/recipe.py#L117-L153 | train |
iotile/coretools | iotileship/iotile/ship/recipe.py | RecipeObject.FromFile | def FromFile(cls, path, actions_dict, resources_dict, file_format="yaml", name=None):
"""Create a RecipeObject from a file.
The file should be a specially constructed yaml file that describes
the recipe as well as the actions that it performs.
Args:
path (str): The path to ... | python | def FromFile(cls, path, actions_dict, resources_dict, file_format="yaml", name=None):
"""Create a RecipeObject from a file.
The file should be a specially constructed yaml file that describes
the recipe as well as the actions that it performs.
Args:
path (str): The path to ... | [
"def",
"FromFile",
"(",
"cls",
",",
"path",
",",
"actions_dict",
",",
"resources_dict",
",",
"file_format",
"=",
"\"yaml\"",
",",
"name",
"=",
"None",
")",
":",
"format_map",
"=",
"{",
"\"yaml\"",
":",
"cls",
".",
"_process_yaml",
"}",
"format_handler",
"=... | Create a RecipeObject from a file.
The file should be a specially constructed yaml file that describes
the recipe as well as the actions that it performs.
Args:
path (str): The path to the recipe file that we wish to load
actions_dict (dict): A dictionary of named Recip... | [
"Create",
"a",
"RecipeObject",
"from",
"a",
"file",
"."
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotileship/iotile/ship/recipe.py#L156-L225 | train |
iotile/coretools | iotileship/iotile/ship/recipe.py | RecipeObject._parse_file_usage | def _parse_file_usage(cls, action_class, args):
"""Find all external files referenced by an action."""
fixed_files = {}
variable_files = []
if not hasattr(action_class, 'FILES'):
return fixed_files, variable_files
for file_arg in action_class.FILES:
arg... | python | def _parse_file_usage(cls, action_class, args):
"""Find all external files referenced by an action."""
fixed_files = {}
variable_files = []
if not hasattr(action_class, 'FILES'):
return fixed_files, variable_files
for file_arg in action_class.FILES:
arg... | [
"def",
"_parse_file_usage",
"(",
"cls",
",",
"action_class",
",",
"args",
")",
":",
"fixed_files",
"=",
"{",
"}",
"variable_files",
"=",
"[",
"]",
"if",
"not",
"hasattr",
"(",
"action_class",
",",
"'FILES'",
")",
":",
"return",
"fixed_files",
",",
"variabl... | Find all external files referenced by an action. | [
"Find",
"all",
"external",
"files",
"referenced",
"by",
"an",
"action",
"."
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotileship/iotile/ship/recipe.py#L240-L260 | train |
iotile/coretools | iotileship/iotile/ship/recipe.py | RecipeObject._parse_resource_declarations | def _parse_resource_declarations(cls, declarations, resource_map):
"""Parse out what resources are declared as shared for this recipe."""
resources = {}
for decl in declarations:
name = decl.pop('name')
typename = decl.pop('type')
desc = decl.pop('descriptio... | python | def _parse_resource_declarations(cls, declarations, resource_map):
"""Parse out what resources are declared as shared for this recipe."""
resources = {}
for decl in declarations:
name = decl.pop('name')
typename = decl.pop('type')
desc = decl.pop('descriptio... | [
"def",
"_parse_resource_declarations",
"(",
"cls",
",",
"declarations",
",",
"resource_map",
")",
":",
"resources",
"=",
"{",
"}",
"for",
"decl",
"in",
"declarations",
":",
"name",
"=",
"decl",
".",
"pop",
"(",
"'name'",
")",
"typename",
"=",
"decl",
".",
... | Parse out what resources are declared as shared for this recipe. | [
"Parse",
"out",
"what",
"resources",
"are",
"declared",
"as",
"shared",
"for",
"this",
"recipe",
"."
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotileship/iotile/ship/recipe.py#L263-L293 | train |
iotile/coretools | iotileship/iotile/ship/recipe.py | RecipeObject._parse_variable_defaults | def _parse_variable_defaults(cls, defaults):
"""Parse out all of the variable defaults."""
default_dict = {}
for item in defaults:
key = next(iter(item))
value = item[key]
if key in default_dict:
raise RecipeFileInvalid("Default variable val... | python | def _parse_variable_defaults(cls, defaults):
"""Parse out all of the variable defaults."""
default_dict = {}
for item in defaults:
key = next(iter(item))
value = item[key]
if key in default_dict:
raise RecipeFileInvalid("Default variable val... | [
"def",
"_parse_variable_defaults",
"(",
"cls",
",",
"defaults",
")",
":",
"default_dict",
"=",
"{",
"}",
"for",
"item",
"in",
"defaults",
":",
"key",
"=",
"next",
"(",
"iter",
"(",
"item",
")",
")",
"value",
"=",
"item",
"[",
"key",
"]",
"if",
"key",... | Parse out all of the variable defaults. | [
"Parse",
"out",
"all",
"of",
"the",
"variable",
"defaults",
"."
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotileship/iotile/ship/recipe.py#L296-L310 | train |
iotile/coretools | iotileship/iotile/ship/recipe.py | RecipeObject._parse_resource_usage | def _parse_resource_usage(cls, action_dict, declarations):
"""Parse out what resources are used, opened and closed in an action step."""
raw_used = action_dict.pop('use', [])
opened = [x.strip() for x in action_dict.pop('open_before', [])]
closed = [x.strip() for x in action_dict.pop('c... | python | def _parse_resource_usage(cls, action_dict, declarations):
"""Parse out what resources are used, opened and closed in an action step."""
raw_used = action_dict.pop('use', [])
opened = [x.strip() for x in action_dict.pop('open_before', [])]
closed = [x.strip() for x in action_dict.pop('c... | [
"def",
"_parse_resource_usage",
"(",
"cls",
",",
"action_dict",
",",
"declarations",
")",
":",
"raw_used",
"=",
"action_dict",
".",
"pop",
"(",
"'use'",
",",
"[",
"]",
")",
"opened",
"=",
"[",
"x",
".",
"strip",
"(",
")",
"for",
"x",
"in",
"action_dict... | Parse out what resources are used, opened and closed in an action step. | [
"Parse",
"out",
"what",
"resources",
"are",
"used",
"opened",
"and",
"closed",
"in",
"an",
"action",
"step",
"."
] | 2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotileship/iotile/ship/recipe.py#L313-L349 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.