Code stringlengths 103 85.9k | Summary listlengths 0 94 |
|---|---|
Please provide a description of the function:def ParseConfig(self, command, function=None, unique=1):
if function is None:
def parse_conf(env, cmd, unique=unique):
return env.MergeFlags(cmd, unique)
function = parse_conf
if SCons.Util.is_List(command):
... | [
"\n Use the specified function to parse the output of the command\n in order to modify the current environment. The 'command' can\n be a string or a list of strings representing a command and\n its arguments. 'Function' is an optional argument that takes\n the environment, the o... |
Please provide a description of the function:def ParseDepends(self, filename, must_exist=None, only_one=0):
filename = self.subst(filename)
try:
fp = open(filename, 'r')
except IOError:
if must_exist:
raise
return
lines = SCons... | [
"\n Parse a mkdep-style file for explicit dependencies. This is\n completely abusable, and should be unnecessary in the \"normal\"\n case of proper SCons configuration, but it may help make\n the transition from a Make hierarchy easier for some people\n to swallow. It can also b... |
Please provide a description of the function:def Prepend(self, **kw):
kw = copy_non_reserved_keywords(kw)
for key, val in kw.items():
# It would be easier on the eyes to write this using
# "continue" statements whenever we finish processing an item,
# but Pyt... | [
"Prepend values to existing construction variables\n in an Environment.\n "
] |
Please provide a description of the function:def PrependENVPath(self, name, newpath, envname = 'ENV', sep = os.pathsep,
delete_existing=1):
orig = ''
if envname in self._dict and name in self._dict[envname]:
orig = self._dict[envname][name]
nv = SCon... | [
"Prepend path elements to the path 'name' in the 'ENV'\n dictionary for this environment. Will only add any particular\n path once, and will normpath and normcase all paths to help\n assure this. This can also handle the case where the env\n variable is a list instead of a string.\n\n ... |
Please provide a description of the function:def PrependUnique(self, delete_existing=0, **kw):
kw = copy_non_reserved_keywords(kw)
for key, val in kw.items():
if SCons.Util.is_List(val):
val = _delete_duplicates(val, not delete_existing)
if key not in sel... | [
"Prepend values to existing construction variables\n in an Environment, if they're not already there.\n If delete_existing is 1, removes existing values first, so\n values move to front.\n "
] |
Please provide a description of the function:def Replace(self, **kw):
try:
kwbd = kw['BUILDERS']
except KeyError:
pass
else:
kwbd = BuilderDict(kwbd,self)
del kw['BUILDERS']
self.__setitem__('BUILDERS', kwbd)
kw = copy_... | [
"Replace existing construction variables in an Environment\n with new construction variables and/or values.\n "
] |
Please provide a description of the function:def ReplaceIxes(self, path, old_prefix, old_suffix, new_prefix, new_suffix):
old_prefix = self.subst('$'+old_prefix)
old_suffix = self.subst('$'+old_suffix)
new_prefix = self.subst('$'+new_prefix)
new_suffix = self.subst('$'+new_suff... | [
"\n Replace old_prefix with new_prefix and old_suffix with new_suffix.\n\n env - Environment used to interpolate variables.\n path - the path that will be modified.\n old_prefix - construction variable for the old prefix.\n old_suffix - construction variable for the old suffix.\n ... |
Please provide a description of the function:def WhereIs(self, prog, path=None, pathext=None, reject=[]):
if path is None:
try:
path = self['ENV']['PATH']
except KeyError:
pass
elif SCons.Util.is_String(path):
path = self.subst... | [
"Find prog in the path.\n "
] |
Please provide a description of the function:def Command(self, target, source, action, **kw):
bkw = {
'action' : action,
'target_factory' : self.fs.Entry,
'source_factory' : self.fs.Entry,
}
try: bkw['source_scanner'] = kw['source_scanner']
ex... | [
"Builds the supplied target files from the supplied\n source files using the supplied action. Action may\n be any type that the Builder constructor will accept\n for an action."
] |
Please provide a description of the function:def Depends(self, target, dependency):
tlist = self.arg2nodes(target, self.fs.Entry)
dlist = self.arg2nodes(dependency, self.fs.Entry)
for t in tlist:
t.add_dependency(dlist)
return tlist | [
"Explicity specify that 'target's depend on 'dependency'."
] |
Please provide a description of the function:def NoClean(self, *targets):
tlist = []
for t in targets:
tlist.extend(self.arg2nodes(t, self.fs.Entry))
for t in tlist:
t.set_noclean()
return tlist | [
"Tags a target so that it will not be cleaned by -c"
] |
Please provide a description of the function:def NoCache(self, *targets):
tlist = []
for t in targets:
tlist.extend(self.arg2nodes(t, self.fs.Entry))
for t in tlist:
t.set_nocache()
return tlist | [
"Tags a target so that it will not be cached"
] |
Please provide a description of the function:def Execute(self, action, *args, **kw):
action = self.Action(action, *args, **kw)
result = action([], [], self)
if isinstance(result, SCons.Errors.BuildError):
errstr = result.errstr
if result.filename:
... | [
"Directly execute an action through an Environment\n "
] |
Please provide a description of the function:def Ignore(self, target, dependency):
tlist = self.arg2nodes(target, self.fs.Entry)
dlist = self.arg2nodes(dependency, self.fs.Entry)
for t in tlist:
t.add_ignore(dlist)
return tlist | [
"Ignore a dependency."
] |
Please provide a description of the function:def Requires(self, target, prerequisite):
tlist = self.arg2nodes(target, self.fs.Entry)
plist = self.arg2nodes(prerequisite, self.fs.Entry)
for t in tlist:
t.add_prerequisite(plist)
return tlist | [
"Specify that 'prerequisite' must be built before 'target',\n (but 'target' does not actually depend on 'prerequisite'\n and need not be rebuilt if it changes)."
] |
Please provide a description of the function:def SideEffect(self, side_effect, target):
side_effects = self.arg2nodes(side_effect, self.fs.Entry)
targets = self.arg2nodes(target, self.fs.Entry)
for side_effect in side_effects:
if side_effect.multiple_side_effect_has_builder... | [
"Tell scons that side_effects are built as side\n effects of building targets."
] |
Please provide a description of the function:def SourceCode(self, entry, builder):
msg =
SCons.Warnings.warn(SCons.Warnings.DeprecatedSourceCodeWarning, msg)
entries = self.arg2nodes(entry, self.fs.Entry)
for entry in entries:
entry.set_src_builder(builder)
... | [
"Arrange for a source code builder for (part of) a tree.",
"SourceCode() has been deprecated and there is no replacement.\n\\tIf you need this function, please contact scons-dev@scons.org"
] |
Please provide a description of the function:def Split(self, arg):
if SCons.Util.is_List(arg):
return list(map(self.subst, arg))
elif SCons.Util.is_String(arg):
return self.subst(arg).split()
else:
return [self.subst(arg)] | [
"This function converts a string or list into a list of strings\n or Nodes. This makes things easier for users by allowing files to\n be specified as a white-space separated list to be split.\n\n The input rules are:\n - A single string containing names separated by spaces. These wi... |
Please provide a description of the function:def FindSourceFiles(self, node='.'):
node = self.arg2nodes(node, self.fs.Entry)[0]
sources = []
def build_source(ss):
for s in ss:
if isinstance(s, SCons.Node.FS.Dir):
build_source(s.all_childr... | [
" returns a list of all source files.\n "
] |
Please provide a description of the function:def FindInstalledFiles(self):
from SCons.Tool import install
if install._UNIQUE_INSTALLED_FILES is None:
install._UNIQUE_INSTALLED_FILES = SCons.Util.uniquer_hashables(install._INSTALLED_FILES)
return install._UNIQUE_INSTALLED_FIL... | [
" returns the list of all targets of the Install and InstallAs Builder.\n "
] |
Please provide a description of the function:def get(self, key, default=None):
try:
return self.__dict__['overrides'][key]
except KeyError:
return self.__dict__['__subject'].get(key, default) | [
"Emulates the get() method of dictionaries."
] |
Please provide a description of the function:def Dictionary(self):
d = self.__dict__['__subject'].Dictionary().copy()
d.update(self.__dict__['overrides'])
return d | [
"Emulates the items() method of dictionaries."
] |
Please provide a description of the function:def FromBinary(cls, record_data, record_count=1):
_cmd, address, _resp_length, payload = cls._parse_rpc_info(record_data)
try:
value, encoded_stream = struct.unpack("<LH", payload)
stream = DataStream.FromEncoded(encoded_str... | [
"Create an UpdateRecord subclass from binary record data.\n\n This should be called with a binary record blob (NOT including the\n record type header) and it will decode it into a SetConstantRecord.\n\n Args:\n record_data (bytearray): The raw record data that we wish to parse\n ... |
Please provide a description of the function:def generate(env):
global PDFLaTeXAction
if PDFLaTeXAction is None:
PDFLaTeXAction = SCons.Action.Action('$PDFLATEXCOM', '$PDFLATEXCOMSTR')
global PDFLaTeXAuxAction
if PDFLaTeXAuxAction is None:
PDFLaTeXAuxAction = SCons.Action.Action(PD... | [
"Add Builders and construction variables for pdflatex to an Environment."
] |
Please provide a description of the function:def scons_copytree(src, dst, symlinks=False):
names = os.listdir(src)
# garyo@genarts.com fix: check for dir before making dirs.
if not os.path.exists(dst):
os.makedirs(dst)
errors = []
for name in names:
srcname = os.path.join(src, n... | [
"Recursively copy a directory tree using copy2().\n\n The destination directory must not already exist.\n If exception(s) occur, an CopytreeError is raised with a list of reasons.\n\n If the optional symlinks flag is true, symbolic links in the\n source tree result in symbolic links in the destination t... |
Please provide a description of the function:def copyFunc(dest, source, env):
if os.path.isdir(source):
if os.path.exists(dest):
if not os.path.isdir(dest):
raise SCons.Errors.UserError("cannot overwrite non-directory `%s' with a directory `%s'" % (str(dest), str(source)))
... | [
"Install a source file or directory into a destination by copying,\n (including copying permission/mode bits)."
] |
Please provide a description of the function:def copyFuncVersionedLib(dest, source, env):
if os.path.isdir(source):
raise SCons.Errors.UserError("cannot install directory `%s' as a version library" % str(source) )
else:
# remove the link if it is already there
try:
os.r... | [
"Install a versioned library into a destination by copying,\n (including copying permission/mode bits) and then creating\n required symlinks."
] |
Please provide a description of the function:def installShlibLinks(dest, source, env):
Verbose = False
symlinks = listShlibLinksToInstall(dest, source, env)
if Verbose:
print('installShlibLinks: symlinks={:r}'.format(SCons.Tool.StringizeLibSymlinks(symlinks)))
if symlinks:
SCons.Too... | [
"If we are installing a versioned shared library create the required links."
] |
Please provide a description of the function:def installFunc(target, source, env):
try:
install = env['INSTALL']
except KeyError:
raise SCons.Errors.UserError('Missing INSTALL construction variable.')
assert len(target)==len(source), \
"Installing source %s into target %s: t... | [
"Install a source file into a target using the function specified\n as the INSTALL construction variable."
] |
Please provide a description of the function:def installFuncVersionedLib(target, source, env):
try:
install = env['INSTALLVERSIONEDLIB']
except KeyError:
raise SCons.Errors.UserError('Missing INSTALLVERSIONEDLIB construction variable.')
assert len(target)==len(source), \
"In... | [
"Install a versioned library into a target using the function specified\n as the INSTALLVERSIONEDLIB construction variable."
] |
Please provide a description of the function:def add_targets_to_INSTALLED_FILES(target, source, env):
global _INSTALLED_FILES, _UNIQUE_INSTALLED_FILES
_INSTALLED_FILES.extend(target)
_UNIQUE_INSTALLED_FILES = None
return (target, source) | [
" An emitter that adds all target files to the list stored in the\n _INSTALLED_FILES global variable. This way all installed files of one\n scons call will be collected.\n "
] |
Please provide a description of the function:def add_versioned_targets_to_INSTALLED_FILES(target, source, env):
global _INSTALLED_FILES, _UNIQUE_INSTALLED_FILES
Verbose = False
_INSTALLED_FILES.extend(target)
if Verbose:
print("add_versioned_targets_to_INSTALLED_FILES: target={:r}".format(l... | [
" An emitter that adds all target files to the list stored in the\n _INSTALLED_FILES global variable. This way all installed files of one\n scons call will be collected.\n "
] |
Please provide a description of the function:def encode_contents(self):
if self.variable_size:
resp_length = 1
else:
resp_length = self.fixed_response_size << 1
header = struct.pack("<HBB", self.rpc_id, self.address, resp_length)
return bytearray(header... | [
"Encode the contents of this update record without including a record header.\n\n Returns:\n bytearray: The encoded contents.\n "
] |
Please provide a description of the function:def FromBinary(cls, record_data, record_count=1):
cmd, address, resp_length, payload = cls._parse_rpc_info(record_data)
# The first bit is 1 if we do not have a fixed length
# The next 7 bits encode the fixed length if we do have a fixed le... | [
"Create an UpdateRecord subclass from binary record data.\n\n This should be called with a binary record blob (NOT including the\n record type header) and it will decode it into a SendRPCRecord.\n\n Args:\n record_data (bytearray): The raw record data that we wish to parse\n ... |
Please provide a description of the function:def parse_multiple_rpcs(cls, record_data):
rpcs = []
while len(record_data) > 0:
total_length, record_type = struct.unpack_from("<LB3x", record_data)
if record_type != SendErrorCheckingRPCRecord.RecordType:
r... | [
"Parse record_data into multiple error checking rpcs."
] |
Please provide a description of the function:def execute(self, sensor_graph, scope_stack):
if not isinstance(scope_stack[-1], RootScope):
raise SensorGraphSemanticError("You may only declare metadata at global scope in a sensorgraph.", identifier=self.identifier, value=self.value)
... | [
"Execute this statement on the sensor_graph given the current scope tree.\n\n This function will likely modify the sensor_graph and will possibly\n also add to or remove from the scope_tree. If there are children nodes\n they will be called after execute_before and before execute_after,\n ... |
Please provide a description of the function:def generate(env):
SCons.Tool.cc.generate(env)
env['CC'] = env.Detect(compilers) or 'clang'
if env['PLATFORM'] in ['cygwin', 'win32']:
env['SHCCFLAGS'] = SCons.Util.CLVar('$CCFLAGS')
else:
env['SHCCFLAGS'] = SCons.Util.CLVar('$CCFLAGS -f... | [
"Add Builders and construction variables for clang to an Environment."
] |
Please provide a description of the function:def run(self):
if self._generator:
try:
gen = self._routine(*self._worker_args, **self._worker_kwargs)
while True:
if self._stop_condition.is_set():
return
... | [
"The target routine called to start thread activity.\n\n If the thread is created with a generator function, this iterates\n the generator and checks for a stop condition between each iteration.\n\n If the thread is created with a normal function, that function is called\n in a loop with... |
Please provide a description of the function:def wait_running(self, timeout=None):
flag = self._running.wait(timeout)
if flag is False:
raise TimeoutExpiredError("Timeout waiting for thread to start running") | [
"Wait for the thread to pass control to its routine.\n\n Args:\n timeout (float): The maximum amount of time to wait\n "
] |
Please provide a description of the function:def create_event(self, register=False):
event = asyncio.Event(loop=self._loop)
if register:
self._events.add(event)
return event | [
"Create an asyncio.Event inside the emulation loop.\n\n This method exists as a convenience to create an Event object that is\n associated with the correct EventLoop(). If you pass register=True,\n then the event will be registered as an event that must be set for the\n EmulationLoop to... |
Please provide a description of the function:def create_queue(self, register=False):
queue = asyncio.Queue(loop=self._loop)
if register:
self._work_queues.add(queue)
return queue | [
"Create a new work queue and optionally register it.\n\n This will make sure the queue is attached to the correct event loop.\n You can optionally choose to automatically register it so that\n wait_idle() will block until the queue is empty.\n\n Args:\n register (bool): Whethe... |
Please provide a description of the function:def finish_async_rpc(self, address, rpc_id, *response):
self.verify_calling_thread(True, "All asynchronous rpcs must be finished from within the emulation loop")
if len(response) == 0:
response_bytes = b''
elif len(response) == ... | [
"Finish a previous asynchronous RPC.\n\n This method should be called by a peripheral tile that previously\n had an RPC called on it and chose to response asynchronously by\n raising ``AsynchronousRPCResponse`` in the RPC handler itself.\n\n The response passed to this function will be r... |
Please provide a description of the function:def start(self):
if self._started is True:
raise ArgumentError("EmulationLoop.start() called multiple times")
self._thread = threading.Thread(target=self._loop_thread_main)
self._thread.start()
self._started = True | [
"Start the background emulation loop."
] |
Please provide a description of the function:def stop(self):
if self._started is False:
raise ArgumentError("EmulationLoop.stop() called without calling start()")
self.verify_calling_thread(False, "Cannot call EmulationLoop.stop() from inside the event loop")
if self._thr... | [
"Stop the background emulation loop."
] |
Please provide a description of the function:def wait_idle(self, timeout=1.0):
async def _awaiter():
background_work = {x.join() for x in self._work_queues}
for event in self._events:
if not event.is_set():
background_work.add(event.wait())
... | [
"Wait until the rpc queue is empty.\n\n This method may be called either from within the event loop or from\n outside of it. If it is called outside of the event loop it will\n block the calling thread until the rpc queue is temporarily empty.\n\n If it is called from within the event l... |
Please provide a description of the function:def run_task_external(self, coroutine):
self.verify_calling_thread(False, 'run_task_external must not be called from the emulation thread')
future = asyncio.run_coroutine_threadsafe(coroutine, self._loop)
return future.result() | [
"Inject a task into the emulation loop and wait for it to finish.\n\n The coroutine parameter is run as a Task inside the EmulationLoop\n until it completes and the return value (or any raised Exception) is\n pased back into the caller's thread.\n\n Args:\n coroutine (coroutin... |
Please provide a description of the function:def call_rpc_external(self, address, rpc_id, arg_payload, timeout=10.0):
self.verify_calling_thread(False, "call_rpc_external is for use **outside** of the event loop")
response = CrossThreadResponse()
self._loop.call_soon_threadsafe(self.... | [
"Call an RPC from outside of the event loop and block until it finishes.\n\n This is the main method by which a caller outside of the EmulationLoop\n can inject an RPC into the EmulationLoop and wait for it to complete.\n This method is synchronous so it blocks until the RPC completes or the\n ... |
Please provide a description of the function:async def await_rpc(self, address, rpc_id, *args, **kwargs):
self.verify_calling_thread(True, "await_rpc must be called from **inside** the event loop")
if isinstance(rpc_id, RPCDeclaration):
arg_format = rpc_id.arg_format
r... | [
"Send an RPC from inside the EmulationLoop.\n\n This is the primary method by which tasks running inside the\n EmulationLoop dispatch RPCs. The RPC is added to the queue of waiting\n RPCs to be drained by the RPC dispatch task and this coroutine will\n block until it finishes.\n\n ... |
Please provide a description of the function:def verify_calling_thread(self, should_be_emulation, message=None):
if should_be_emulation == self._on_emulation_thread():
return
if message is None:
message = "Operation performed on invalid thread"
raise InternalE... | [
"Verify if the calling thread is or is not the emulation thread.\n\n This method can be called to make sure that an action is being taken\n in the appropriate context such as not blocking the event loop thread\n or modifying an emulate state outside of the event loop thread.\n\n If the v... |
Please provide a description of the function:def add_task(self, tile_address, coroutine):
self._loop.call_soon_threadsafe(self._add_task, tile_address, coroutine) | [
"Add a task into the event loop.\n\n This is the main entry point for registering background tasks that are\n associated with a tile. The tasks are added to the EmulationLoop and\n the tile they are a part of is recorded. When the tile is reset, all\n of its background tasks are cancele... |
Please provide a description of the function:async def stop_tasks(self, address):
tasks = self._tasks.get(address, [])
for task in tasks:
task.cancel()
asyncio.gather(*tasks, return_exceptions=True)
self._tasks[address] = [] | [
"Clear all tasks pertaining to a tile.\n\n This coroutine will synchronously cancel all running tasks that were\n attached to the given tile and wait for them to stop before returning.\n\n Args:\n address (int): The address of the tile we should stop.\n "
] |
Please provide a description of the function:async def _clean_shutdown(self):
# Cleanly stop any other outstanding tasks not associated with tiles
remaining_tasks = []
for task in self._tasks.get(None, []):
self._logger.debug("Cancelling task at shutdown %s", task)
... | [
"Cleanly shutdown the emulation loop."
] |
Please provide a description of the function:def _add_task(self, tile_address, coroutine):
self.verify_calling_thread(True, "_add_task is not thread safe")
if tile_address not in self._tasks:
self._tasks[tile_address] = []
task = self._loop.create_task(coroutine)
... | [
"Add a task from within the event loop.\n\n All tasks are associated with a tile so that they can be cleanly\n stopped when that tile is reset.\n "
] |
Please provide a description of the function:def key_rule(self, regex, verifier):
if regex is not None:
regex = re.compile(regex)
self._additional_key_rules.append((regex, verifier)) | [
"Add a rule with a pattern that should apply to all keys.\n\n Any key not explicitly listed in an add_required or add_optional rule\n must match ONE OF the rules given in a call to key_rule().\n So these rules are all OR'ed together.\n\n In this case you should pass a raw string specifyi... |
Please provide a description of the function:def verify(self, obj):
out_obj = {}
if not isinstance(obj, dict):
raise ValidationError("Invalid dictionary", reason="object is not a dictionary")
if self._fixed_length is not None and len(obj) != self._fixed_length:
... | [
"Verify that the object conforms to this verifier's schema\n\n Args:\n obj (object): A python object to verify\n\n Raises:\n ValidationError: If there is a problem verifying the dictionary, a\n ValidationError is thrown with at least the reason key set indicating\n... |
Please provide a description of the function:def stream(self, report, callback=None):
conn_id = self._find_connection(self.conn_string)
if isinstance(report, BroadcastReport):
self.adapter.notify_event_nowait(self.conn_string, 'broadcast', report)
elif conn_id is not None:... | [
"Queue data for streaming\n\n Args:\n report (IOTileReport): A report object to stream to a client\n callback (callable): An optional callback that will be called with\n a bool value of True when this report actually gets streamed.\n If the client disconnec... |
Please provide a description of the function:def trace(self, data, callback=None):
conn_id = self._find_connection(self.conn_string)
if conn_id is not None:
self.adapter.notify_event_nowait(self.conn_string, 'trace', data)
if callback is not None:
callback(con... | [
"Queue data for tracing\n\n Args:\n data (bytearray, string): Unstructured data to trace to any\n connected client.\n callback (callable): An optional callback that will be called with\n a bool value of True when this data actually gets traced.\n ... |
Please provide a description of the function:def _load_device(self, name, config):
if config is None:
config_dict = {}
elif isinstance(config, dict):
config_dict = config
elif config[0] == '#':
# Allow passing base64 encoded json directly in the port... | [
"Load a device either from a script or from an installed module"
] |
Please provide a description of the function:async def connect(self, conn_id, connection_string):
id_number = int(connection_string)
if id_number not in self.devices:
raise DeviceAdapterError(conn_id, 'connect', 'device not found')
if self._get_conn_id(connection_string) i... | [
"Asynchronously connect to a device\n\n Args:\n conn_id (int): A unique identifer that will refer to this connection\n connection_string (string): A DeviceAdapter specific string that can be used to connect to\n a device using this DeviceAdapter.\n callback (ca... |
Please provide a description of the function:async def disconnect(self, conn_id):
self._ensure_connection(conn_id, True)
dev = self._get_property(conn_id, 'device')
dev.connected = False
self._teardown_connection(conn_id) | [
"Asynchronously disconnect from a connected device\n\n Args:\n conn_id (int): A unique identifier that will refer to this connection\n callback (callback): A callback that will be called as\n callback(conn_id, adapter_id, success, failure_reason)\n "
] |
Please provide a description of the function:async def send_rpc(self, conn_id, address, rpc_id, payload, timeout):
self._ensure_connection(conn_id, True)
dev = self._get_property(conn_id, 'device')
try:
res = dev.call_rpc(address, rpc_id, bytes(payload))
if ins... | [
"Asynchronously send an RPC to this IOTile device\n\n Args:\n conn_id (int): A unique identifier that will refer to this connection\n address (int): the address of the tile that we wish to send the RPC to\n rpc_id (int): the 16-bit id of the RPC we want to call\n p... |
Please provide a description of the function:async def send_script(self, conn_id, data):
self._ensure_connection(conn_id, True)
dev = self._get_property(conn_id, 'device')
conn_string = self._get_property(conn_id, 'connection_string')
# Simulate some progress callbacks (0, 50%... | [
"Asynchronously send a a script to this IOTile device\n\n Args:\n conn_id (int): A unique identifier that will refer to this connection\n data (bytes or bytearray): the script to send to the device\n "
] |
Please provide a description of the function:async def debug(self, conn_id, name, cmd_args):
self._ensure_connection(conn_id, True)
dev = self._get_property(conn_id, 'device')
conn_string = self._get_property(conn_id, 'connection_string')
if name != 'inspect_property':
... | [
"Send a debug command to a device.\n\n This method responds to a single command 'inspect_property' that takes\n the name of a propery on the device and returns its value. The\n ``cmd_args`` dict should have a single key: 'properties' that is a\n list of strings with the property names t... |
Please provide a description of the function:async def _send_scan_event(self, device):
conn_string = str(device.iotile_id)
info = {
'connection_string': conn_string,
'uuid': device.iotile_id,
'signal_strength': 100,
'validity_period': self.Expira... | [
"Send a scan event from a device."
] |
Please provide a description of the function:def rpc_name(rpc_id):
name = _RPC_NAME_MAP.get(rpc_id)
if name is None:
name = 'RPC 0x%04X' % rpc_id
return name | [
"Map an RPC id to a string name.\n\n This function looks the RPC up in a map of all globally declared RPCs,\n and returns a nice name string. if the RPC is not found in the global\n name map, returns a generic name string such as 'rpc 0x%04X'.\n\n Args:\n rpc_id (int): The id of the RPC that we ... |
Please provide a description of the function:def stream_name(stream_id):
name = _STREAM_NAME_MAP.get(stream_id)
if name is None:
name = str(DataStream.FromEncoded(stream_id))
return "{} (0x{:04X})".format(name, stream_id) | [
"Map a stream id to a human readable name.\n\n The mapping process is as follows:\n\n If the stream id is globally known, its global name is used as <name>\n otherwise a string representation of the stream is used as <name>.\n\n In both cases the hex representation of the stream id is appended as a\n ... |
Please provide a description of the function:def Parser(version):
formatter = SConsIndentedHelpFormatter(max_help_position=30)
op = SConsOptionParser(option_class=SConsOption,
add_help_option=False,
formatter=formatter,
usag... | [
"\n Returns an options parser object initialized with the standard\n SCons options.\n "
] |
Please provide a description of the function:def set_option(self, name, value):
if not name in self.settable:
raise SCons.Errors.UserError("This option is not settable from a SConscript file: %s"%name)
if name == 'num_jobs':
try:
value = int(value)
... | [
"\n Sets an option from an SConscript file.\n "
] |
Please provide a description of the function:def format_help(self, formatter):
formatter.dedent()
result = formatter.format_heading(self.title)
formatter.indent()
result = result + optparse.OptionContainer.format_help(self, formatter)
return result | [
"\n Format an option group's help text, outdenting the title so it's\n flush with the \"SCons Options\" title we print at the top.\n "
] |
Please provide a description of the function:def _process_long_opt(self, rargs, values):
arg = rargs.pop(0)
# Value explicitly attached to arg? Pretend it's the next
# argument.
if "=" in arg:
(opt, next_arg) = arg.split("=", 1)
rargs.insert(0, next_arg... | [
"\n SCons-specific processing of long options.\n\n This is copied directly from the normal\n optparse._process_long_opt() method, except that, if configured\n to do so, we catch the exception thrown when an unknown option\n is encountered and just stick it back on the \"leftover\"... |
Please provide a description of the function:def reparse_local_options(self):
rargs = []
largs_restore = []
# Loop over all remaining arguments
skip = False
for l in self.largs:
if skip:
# Accept all remaining arguments as they are
... | [
"\n Re-parse the leftover command-line options stored\n in self.largs, so that any value overridden on the\n command line is immediately available if the user turns\n around and does a GetOption() right away.\n \n We mimic the processing of the single args\n in the o... |
Please provide a description of the function:def add_local_option(self, *args, **kw):
try:
group = self.local_option_group
except AttributeError:
group = SConsOptionGroup(self, 'Local Options')
group = self.add_option_group(group)
self.local_optio... | [
"\n Adds a local option to the parser.\n\n This is initiated by a SetOption() call to add a user-defined\n command-line option. We add the option to a separate option\n group for the local options, creating the group if necessary.\n "
] |
Please provide a description of the function:def format_heading(self, heading):
if heading == 'Options':
heading = "SCons Options"
return optparse.IndentedHelpFormatter.format_heading(self, heading) | [
"\n This translates any heading of \"options\" or \"Options\" into\n \"SCons Options.\" Unfortunately, we have to do this here,\n because those titles are hard-coded in the optparse calls.\n "
] |
Please provide a description of the function:def format_option(self, option):
# The help for each option consists of two parts:
# * the opt strings and metavars
# eg. ("-x", or "-fFILENAME, --file=FILENAME")
# * the user-supplied help string
# eg. ("turn on e... | [
"\n A copy of the normal optparse.IndentedHelpFormatter.format_option()\n method. This has been snarfed so we can modify text wrapping to\n out liking:\n\n -- add our own regular expression that doesn't break on hyphens\n (so things like --no-print-directory don't get broken... |
Please provide a description of the function:def to_dict(self):
out_dict = {}
out_dict['commands'] = self.commands
out_dict['configs'] = self.configs
out_dict['short_name'] = self.name
out_dict['versions'] = {
'module': self.module_version,
'api... | [
"Convert this object into a dictionary.\n\n Returns:\n dict: A dict with the same information as this object.\n "
] |
Please provide a description of the function:def set_api_version(self, major, minor):
if not self._is_byte(major) or not self._is_byte(minor):
raise ArgumentError("Invalid API version number with component that does not fit in 1 byte",
major=major, minor=min... | [
"Set the API version this module was designed for.\n\n Each module must declare the mib12 API version it was compiled with as a\n 2 byte major.minor number. This information is used by the pic12_executive\n to decide whether the application is compatible.\n "
] |
Please provide a description of the function:def set_module_version(self, major, minor, patch):
if not (self._is_byte(major) and self._is_byte(minor) and self._is_byte(patch)):
raise ArgumentError("Invalid module version number with component that does not fit in 1 byte",
... | [
"Set the module version for this module.\n\n Each module must declare a semantic version number in the form:\n major.minor.patch\n\n where each component is a 1 byte number between 0 and 255.\n "
] |
Please provide a description of the function:def set_name(self, name):
if len(name) > 6:
raise ArgumentError("Name must be at most 6 characters long", name=name)
if len(name) < 6:
name += ' '*(6 - len(name))
self.name = name | [
"Set the module name to a 6 byte string\n\n If the string is too short it is appended with space characters.\n "
] |
Please provide a description of the function:def add_command(self, cmd_id, handler):
if cmd_id < 0 or cmd_id >= 2**16:
raise ArgumentError("Command ID in mib block is not a non-negative 2-byte number",
cmd_id=cmd_id, handler=handler)
if cmd_id in se... | [
"Add a command to the TBBlock.\n\n The cmd_id must be a non-negative 2 byte number.\n handler should be the command handler\n "
] |
Please provide a description of the function:def add_config(self, config_id, config_data):
if config_id < 0 or config_id >= 2**16:
raise ArgumentError("Config ID in mib block is not a non-negative 2-byte number",
config_data=config_id, data=config_data)
... | [
"Add a configuration variable to the MIB block"
] |
Please provide a description of the function:def _parse_hwtype(self):
self.chip_name = KNOWN_HARDWARE_TYPES.get(self.hw_type, "Unknown Chip (type=%d)" % self.hw_type) | [
"Convert the numerical hardware id to a chip name."
] |
Please provide a description of the function:def render_template(self, template_name, out_path=None):
return render_template(template_name, self.to_dict(), out_path=out_path) | [
"Render a template based on this TileBus Block.\n\n The template has access to all of the attributes of this block as a\n dictionary (the result of calling self.to_dict()).\n\n You can optionally render to a file by passing out_path.\n\n Args:\n template_name (str): The name o... |
Please provide a description of the function:def Tag(env, target, source, *more_tags, **kw_tags):
if not target:
target=source
first_tag=None
else:
first_tag=source
if first_tag:
kw_tags[first_tag[0]] = ''
if len(kw_tags) == 0 and len(more_tags) == 0:
raise... | [
" Tag a file with the given arguments, just sets the accordingly named\n attribute on the file object.\n\n TODO: FIXME\n "
] |
Please provide a description of the function:def Package(env, target=None, source=None, **kw):
# check if we need to find the source files ourself
if not source:
source = env.FindInstalledFiles()
if len(source)==0:
raise UserError("No source for Package() given")
# decide which ty... | [
" Entry point for the package tool.\n "
] |
Please provide a description of the function:def copy_attr(f1, f2):
copyit = lambda x: not hasattr(f2, x) and x[:10] == 'PACKAGING_'
if f1._tags:
pattrs = [tag for tag in f1._tags if copyit(tag)]
for attr in pattrs:
f2.Tag(attr, f1.GetTag(attr)) | [
" copies the special packaging file attributes from f1 to f2.\n "
] |
Please provide a description of the function:def putintopackageroot(target, source, env, pkgroot, honor_install_location=1):
# make sure the packageroot is a Dir object.
if SCons.Util.is_String(pkgroot): pkgroot=env.Dir(pkgroot)
if not SCons.Util.is_List(source): source=[source]
new_source = []
... | [
" Uses the CopyAs builder to copy all source files to the directory given\n in pkgroot.\n\n If honor_install_location is set and the copied source file has an\n PACKAGING_INSTALL_LOCATION attribute, the PACKAGING_INSTALL_LOCATION is\n used as the new name of the source file under pkgroot.\n\n The sou... |
Please provide a description of the function:def stripinstallbuilder(target, source, env):
def has_no_install_location(file):
return not (file.has_builder() and\
hasattr(file.builder, 'name') and\
(file.builder.name=="InstallBuilder" or\
file.builder.name=="InstallA... | [
" Strips the install builder action from the source list and stores\n the final installation location as the \"PACKAGING_INSTALL_LOCATION\" of\n the source of the source file. This effectively removes the final installed\n files from the source list while remembering the installation location.\n\n It al... |
Please provide a description of the function:def restore(self, state):
selector = DataStreamSelector.FromString(state.get(u'selector'))
if selector != self.selector:
raise ArgumentError("Attempted to restore a BufferedStreamWalker with a different selector",
... | [
"Restore a previous state of this stream walker.\n\n Raises:\n ArgumentError: If the state refers to a different selector or the\n offset is invalid.\n "
] |
Please provide a description of the function:def pop(self):
if self._count == 0:
raise StreamEmptyError("Pop called on buffered stream walker without any data", selector=self.selector)
while True:
curr = self.engine.get(self.storage_type, self.offset)
self.... | [
"Pop a reading off of this stream and return it."
] |
Please provide a description of the function:def seek(self, value, target="offset"):
if target not in (u'offset', u'id'):
raise ArgumentError("You must specify target as either offset or id", target=target)
if target == u'offset':
self._verify_offset(value)
... | [
"Seek this stream to a specific offset or reading id.\n\n There are two modes of use. You can seek to a specific reading id,\n which means the walker will be positioned exactly at the reading\n pointed to by the reading ID. If the reading id cannot be found\n an exception will be raise... |
Please provide a description of the function:def skip_all(self):
storage, streaming = self.engine.count()
if self.selector.output:
self.offset = streaming
else:
self.offset = storage
self._count = 0 | [
"Skip all readings in this walker."
] |
Please provide a description of the function:def notify_rollover(self, stream):
self.offset -= 1
if not self.matches(stream):
return
if self._count == 0:
raise InternalError("BufferedStreamWalker out of sync with storage engine, count was wrong.")
sel... | [
"Notify that a reading in the given stream was overwritten.\n\n Args:\n stream (DataStream): The stream that had overwritten data.\n "
] |
Please provide a description of the function:def dump(self):
reading = self.reading
if reading is not None:
reading = reading.asdict()
return {
u'selector': str(self.selector),
u'reading': reading
} | [
"Serialize the state of this stream walker.\n\n Returns:\n dict: The serialized state.\n "
] |
Please provide a description of the function:def restore(self, state):
reading = state.get(u'reading')
if reading is not None:
reading = IOTileReading.FromDict(reading)
selector = DataStreamSelector.FromString(state.get(u'selector'))
if self.selector != selector:
... | [
"Restore the contents of this virtual stream walker.\n\n Args:\n state (dict): The previously serialized state.\n\n Raises:\n ArgumentError: If the serialized state does not have\n a matching selector.\n "
] |
Please provide a description of the function:def push(self, stream, value):
if not self.matches(stream):
raise ArgumentError("Attempting to push reading to stream walker that does not match", selector=self.selector, stream=stream)
self.reading = value | [
"Update this stream walker with a new responsive reading.\n\n Virtual stream walkers keep at most one reading so this function\n just overwrites whatever was previously stored.\n "
] |
Please provide a description of the function:def pop(self):
if self.reading is None:
raise StreamEmptyError("Pop called on virtual stream walker without any data", selector=self.selector)
reading = self.reading
# If we're not a constant stream, we just exhausted ourselves... | [
"Pop a reading off of this virtual stream and return it."
] |
Please provide a description of the function:def pop(self):
if self._count == 0:
raise StreamEmptyError("Pop called on virtual stream walker without any data", selector=self.selector)
self._count = self._count - 1
return self.reading | [
"Pop a reading off of this virtual stream and return it."
] |
Please provide a description of the function:def peek(self):
if self.reading is None:
raise StreamEmptyError("peek called on virtual stream walker without any data", selector=self.selector)
return self.reading | [
"Peek at the oldest reading in this virtual stream."
] |
Please provide a description of the function:def restore(self, state):
selector = DataStreamSelector.FromString(state.get(u'selector'))
if self.selector != selector:
raise ArgumentError("Attempted to restore an InvalidStreamWalker with a different selector",
... | [
"Restore the contents of this virtual stream walker.\n\n Args:\n state (dict): The previously serialized state.\n\n Raises:\n ArgumentError: If the serialized state does not have\n a matching selector.\n "
] |
Please provide a description of the function:def push(self, stream, value):
raise ArgumentError("Attempting to push reading to an invalid stream walker that cannot hold data", selector=self.selector, stream=stream) | [
"Update this stream walker with a new responsive reading.\n\n Args:\n stream (DataStream): The stream that we're pushing\n value (IOTileReading): The reading tha we're pushing\n "
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.