_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
75
19.8k
language
stringclasses
1 value
meta_information
dict
q239100
OrderedAWSIOTClient.subscribe
train
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
{ "resource": "" }
q239101
OrderedAWSIOTClient.reset_sequence
train
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
{ "resource": "" }
q239102
OrderedAWSIOTClient.unsubscribe
train
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
{ "resource": "" }
q239103
OrderedAWSIOTClient._on_receive
train
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
{ "resource": "" }
q239104
SyncRTCStep.run
train
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
{ "resource": "" }
q239105
CommandFile.add
train
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
{ "resource": "" }
q239106
CommandFile.save
train
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
{ "resource": "" }
q239107
CommandFile.dump
train
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
{ "resource": "" }
q239108
CommandFile.FromString
train
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
{ "resource": "" }
q239109
CommandFile.FromFile
train
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
{ "resource": "" }
q239110
CommandFile.encode
train
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
{ "resource": "" }
q239111
CommandFile.decode
train
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
{ "resource": "" }
q239112
PacketQueue.receive
train
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
{ "resource": "" }
q239113
set_vars
train
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
{ "resource": "" }
q239114
find_versions
train
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
{ "resource": "" }
q239115
generate
train
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
{ "resource": "" }
q239116
FlashBoardStep.run
train
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
{ "resource": "" }
q239117
copyto_emitter
train
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
{ "resource": "" }
q239118
getPharLapPath
train
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
{ "resource": "" }
q239119
addPharLapPaths
train
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
{ "resource": "" }
q239120
_update_or_init_po_files
train
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
{ "resource": "" }
q239121
_POUpdateBuilder
train
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
{ "resource": "" }
q239122
_POUpdateBuilderWrapper
train
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
{ "resource": "" }
q239123
generate
train
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
{ "resource": "" }
q239124
ProductResolver._create_filter
train
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
{ "resource": "" }
q239125
ProductResolver._create_product_map
train
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
{ "resource": "" }
q239126
ProductResolver._add_products
train
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
{ "resource": "" }
q239127
ProductResolver.find_all
train
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
{ "resource": "" }
q239128
ProductResolver.find_unique
train
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
{ "resource": "" }
q239129
main
train
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
{ "resource": "" }
q239130
generate
train
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
{ "resource": "" }
q239131
build_parser
train
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
{ "resource": "" }
q239132
get_release_component
train
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
{ "resource": "" }
q239133
check_compatibility
train
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
{ "resource": "" }
q239134
build_component
train
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
{ "resource": "" }
q239135
uuid_to_slug
train
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
{ "resource": "" }
q239136
package
train
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
{ "resource": "" }
q239137
build_specfiles
train
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
{ "resource": "" }
q239138
emit_java_headers
train
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
{ "resource": "" }
q239139
generate
train
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
{ "resource": "" }
q239140
InMemoryStorageEngine.dump
train
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
{ "resource": "" }
q239141
InMemoryStorageEngine.restore
train
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
{ "resource": "" }
q239142
InMemoryStorageEngine.count_matching
train
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
{ "resource": "" }
q239143
InMemoryStorageEngine.scan_storage
train
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
{ "resource": "" }
q239144
InMemoryStorageEngine.push
train
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
{ "resource": "" }
q239145
InMemoryStorageEngine.get
train
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
{ "resource": "" }
q239146
InMemoryStorageEngine.popn
train
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
{ "resource": "" }
q239147
WebSocketDeviceAdapter.send_script
train
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
{ "resource": "" }
q239148
WebSocketDeviceAdapter._on_report_notification
train
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
{ "resource": "" }
q239149
WebSocketDeviceAdapter._on_trace_notification
train
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
{ "resource": "" }
q239150
WebSocketDeviceAdapter._on_progress_notification
train
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
{ "resource": "" }
q239151
_extract_variables
train
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
{ "resource": "" }
q239152
_run_step
train
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
{ "resource": "" }
q239153
RecipeObject.archive
train
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
{ "resource": "" }
q239154
RecipeObject.FromArchive
train
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
{ "resource": "" }
q239155
RecipeObject.FromFile
train
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
{ "resource": "" }
q239156
RecipeObject._parse_file_usage
train
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
{ "resource": "" }
q239157
RecipeObject._parse_resource_declarations
train
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
{ "resource": "" }
q239158
RecipeObject._parse_variable_defaults
train
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
{ "resource": "" }
q239159
RecipeObject._parse_resource_usage
train
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
{ "resource": "" }
q239160
RecipeObject.prepare
train
def prepare(self, variables): """Initialize all steps in this recipe using their parameters. Args: variables (dict): A dictionary of global variable definitions that may be used to replace or augment the parameters given to each step. Returns: ...
python
{ "resource": "" }
q239161
RecipeObject._prepare_resources
train
def _prepare_resources(self, variables, overrides=None): """Create and optionally open all shared resources.""" if overrides is None: overrides = {} res_map = {} own_map = {} for decl in self.resources.values(): resource = overrides.get(decl.name) ...
python
{ "resource": "" }
q239162
RecipeObject._cleanup_resources
train
def _cleanup_resources(self, initialized_resources): """Cleanup all resources that we own that are open.""" cleanup_errors = [] # Make sure we clean up all resources that we can and don't error out at the # first one. for name, res in initialized_resources.items(): ...
python
{ "resource": "" }
q239163
RecipeObject.run
train
def run(self, variables=None, overrides=None): """Initialize and run this recipe. By default all necessary shared resources are created and destroyed in this function unless you pass them preinitizlied in overrides, in which case they are used as is. The overrides parameter is designed...
python
{ "resource": "" }
q239164
generate
train
def generate(env): """Add Builders and construction variables for yacc to an Environment.""" c_file, cxx_file = SCons.Tool.createCFileBuilders(env) # C c_file.add_action('.y', YaccAction) c_file.add_emitter('.y', yEmitter) c_file.add_action('.yacc', YaccAction) c_file.add_emitter('.yacc', ...
python
{ "resource": "" }
q239165
generate
train
def generate(env): """Add Builders and construction variables for Borland ilink to an Environment.""" SCons.Tool.createSharedLibBuilder(env) SCons.Tool.createProgBuilder(env) env['LINK'] = '$CC' env['LINKFLAGS'] = SCons.Util.CLVar('') env['LINKCOM'] = '$LINK -q $LINKFLAGS -e$TA...
python
{ "resource": "" }
q239166
SDKDefinition.find_sdk_dir
train
def find_sdk_dir(self): """Try to find the MS SDK from the registry. Return None if failed or the directory does not exist. """ if not SCons.Util.can_read_reg: debug('find_sdk_dir(): can not read registry') return None hkey = self.HKEY_FMT % self.hkey_da...
python
{ "resource": "" }
q239167
SDKDefinition.get_sdk_dir
train
def get_sdk_dir(self): """Return the MSSSDK given the version string.""" try: return self._sdk_dir except AttributeError: sdk_dir = self.find_sdk_dir() self._sdk_dir = sdk_dir return sdk_dir
python
{ "resource": "" }
q239168
SDKDefinition.get_sdk_vc_script
train
def get_sdk_vc_script(self,host_arch, target_arch): """ Return the script to initialize the VC compiler installed by SDK """ if (host_arch == 'amd64' and target_arch == 'x86'): # No cross tools needed compiling 32 bits on 64 bit machine host_arch=target_arch arc...
python
{ "resource": "" }
q239169
format_rpc
train
def format_rpc(data): """Format an RPC call and response. Args: data (tuple): A tuple containing the address, rpc_id, argument and response payloads and any error code. Returns: str: The formated RPC string. """ address, rpc_id, args, resp, _status = data name = r...
python
{ "resource": "" }
q239170
BLED112Server.start
train
async def start(self): """Start serving access to devices over bluetooth.""" self._command_task.start() try: await self._cleanup_old_connections() except Exception: await self.stop() raise #FIXME: This is a temporary hack, get the actual dev...
python
{ "resource": "" }
q239171
BLED112Server.stop
train
async def stop(self): """Safely shut down this interface""" await self._command_task.future_command(['_set_mode', 0, 0]) # Disable advertising await self._cleanup_old_connections() self._command_task.stop() self._stream.stop() self._serial_port.close() await su...
python
{ "resource": "" }
q239172
BLED112Server._call_rpc
train
async def _call_rpc(self, header): """Call an RPC given a header and possibly a previously sent payload Args: header (bytearray): The RPC header we should call """ length, _, cmd, feature, address = struct.unpack("<BBBBB", bytes(header)) rpc_id = (feature << 8) | cm...
python
{ "resource": "" }
q239173
format_script
train
def format_script(sensor_graph): """Create a binary script containing this sensor graph. This function produces a repeatable script by applying a known sorting order to all constants and config variables when iterating over those dictionaries. Args: sensor_graph (SensorGraph): the sensor g...
python
{ "resource": "" }
q239174
SensorLog.dump
train
def dump(self): """Dump the state of this SensorLog. The purpose of this method is to be able to restore the same state later. However there are links in the SensorLog for stream walkers. So the dump process saves the state of each stream walker and upon restore, it looks thro...
python
{ "resource": "" }
q239175
SensorLog.set_rollover
train
def set_rollover(self, area, enabled): """Configure whether rollover is enabled for streaming or storage streams. Normally a SensorLog is used in ring-buffer mode which means that old readings are automatically overwritten as needed when new data is saved. However, you can configure it...
python
{ "resource": "" }
q239176
SensorLog.watch
train
def watch(self, selector, callback): """Call a function whenever a stream changes. Args: selector (DataStreamSelector): The selector to watch. If this is None, it is treated as a wildcard selector that matches every stream. callback (callable): Th...
python
{ "resource": "" }
q239177
SensorLog.create_walker
train
def create_walker(self, selector, skip_all=True): """Create a stream walker based on the given selector. This function returns a StreamWalker subclass that will remain up to date and allow iterating over and popping readings from the stream(s) specified by the selector. When th...
python
{ "resource": "" }
q239178
SensorLog.destroy_walker
train
def destroy_walker(self, walker): """Destroy a previously created stream walker. Args: walker (StreamWalker): The walker to remove from internal updating lists. """ if walker.buffered: self._queue_walkers.remove(walker) else: ...
python
{ "resource": "" }
q239179
SensorLog.restore_walker
train
def restore_walker(self, dumped_state): """Restore a stream walker that was previously serialized. Since stream walkers need to be tracked in an internal list for notification purposes, we need to be careful with how we restore them to make sure they remain part of the right list. ...
python
{ "resource": "" }
q239180
SensorLog.clear
train
def clear(self): """Clear all data from this sensor_log. All readings in all walkers are skipped and buffered data is destroyed. """ for walker in self._virtual_walkers: walker.skip_all() self._engine.clear() for walker in self._queue_walkers: ...
python
{ "resource": "" }
q239181
SensorLog.push
train
def push(self, stream, reading): """Push a reading into a stream, updating any associated stream walkers. Args: stream (DataStream): the stream to push the reading into reading (IOTileReading): the reading to push """ # Make sure the stream is correct re...
python
{ "resource": "" }
q239182
SensorLog._erase_buffer
train
def _erase_buffer(self, output_buffer): """Erase readings in the specified buffer to make space.""" erase_size = self._model.get(u'buffer_erase_size') buffer_type = u'storage' if output_buffer: buffer_type = u'streaming' old_readings = self._engine.popn(buffer_type...
python
{ "resource": "" }
q239183
SensorLog.inspect_last
train
def inspect_last(self, stream, only_allocated=False): """Return the last value pushed into a stream. This function works even if the stream is virtual and no virtual walker has been created for it. It is primarily useful to aid in debugging sensor graphs. Args: str...
python
{ "resource": "" }
q239184
_run_exitfuncs
train
def _run_exitfuncs(): """run any registered exit functions _exithandlers is traversed in reverse order so functions are executed last in, first out. """ while _exithandlers: func, targs, kargs = _exithandlers.pop() func(*targs, **kargs)
python
{ "resource": "" }
q239185
_windowsLdmodTargets
train
def _windowsLdmodTargets(target, source, env, for_signature): """Get targets for loadable modules.""" return _dllTargets(target, source, env, for_signature, 'LDMODULE')
python
{ "resource": "" }
q239186
_windowsLdmodSources
train
def _windowsLdmodSources(target, source, env, for_signature): """Get sources for loadable modules.""" return _dllSources(target, source, env, for_signature, 'LDMODULE')
python
{ "resource": "" }
q239187
_dllEmitter
train
def _dllEmitter(target, source, env, paramtp): """Common implementation of dll emitter.""" SCons.Tool.msvc.validate_vars(env) extratargets = [] extrasources = [] dll = env.FindIxes(target, '%sPREFIX' % paramtp, '%sSUFFIX' % paramtp) no_import_lib = env.get('no_import_lib', 0) if not dll: ...
python
{ "resource": "" }
q239188
embedManifestDllCheck
train
def embedManifestDllCheck(target, source, env): """Function run by embedManifestDllCheckAction to check for existence of manifest and other conditions, and embed the manifest by calling embedManifestDllAction if so.""" if env.get('WINDOWS_EMBED_MANIFEST', 0): manifestSrc = target[0].get_abspath() + ...
python
{ "resource": "" }
q239189
embedManifestExeCheck
train
def embedManifestExeCheck(target, source, env): """Function run by embedManifestExeCheckAction to check for existence of manifest and other conditions, and embed the manifest by calling embedManifestExeAction if so.""" if env.get('WINDOWS_EMBED_MANIFEST', 0): manifestSrc = target[0].get_abspath() + ...
python
{ "resource": "" }
q239190
generate
train
def generate(env): """Add Builders and construction variables for dvips to an Environment.""" global PSAction if PSAction is None: PSAction = SCons.Action.Action('$PSCOM', '$PSCOMSTR') global DVIPSAction if DVIPSAction is None: DVIPSAction = SCons.Action.Action(DviPsFunction, strfun...
python
{ "resource": "" }
q239191
build_library
train
def build_library(tile, libname, chip): """Build a static ARM cortex library""" dirs = chip.build_dirs() output_name = '%s_%s.a' % (libname, chip.arch_name()) # Support both firmware/src and just src locations for source code if os.path.exists('firmware'): VariantDir(dirs['build'], os.pat...
python
{ "resource": "" }
q239192
setup_environment
train
def setup_environment(chip, args_file=None): """Setup the SCons environment for compiling arm cortex code. This will return an env that has all of the correct settings and create a command line arguments file for GCC that contains all of the required flags. The use of a command line argument file passe...
python
{ "resource": "" }
q239193
tb_h_file_creation
train
def tb_h_file_creation(target, source, env): """Compile tilebus file into only .h files corresponding to config variables for inclusion in a library""" files = [str(x) for x in source] try: desc = TBDescriptor(files) except pyparsing.ParseException as e: raise BuildError("Could not par...
python
{ "resource": "" }
q239194
checksum_creation_action
train
def checksum_creation_action(target, source, env): """Create a linker command file for patching an application checksum into a firmware image""" # Important Notes: # There are apparently many ways to calculate a CRC-32 checksum, we use the following options # Initial seed value prepended to the input: ...
python
{ "resource": "" }
q239195
create_arg_file
train
def create_arg_file(target, source, env): """Create an argument file containing -I and -D arguments to gcc. This file will be passed to gcc using @<path>. """ output_name = str(target[0]) with open(output_name, "w") as outfile: for define in env.get('CPPDEFINES', []): outfile....
python
{ "resource": "" }
q239196
merge_hex_executables
train
def merge_hex_executables(target, source, env): """Combine all hex files into a singular executable file.""" output_name = str(target[0]) hex_final = IntelHex() for image in source: file = str(image) root, ext = os.path.splitext(file) file_format = ext[1:] if file_format...
python
{ "resource": "" }
q239197
ensure_image_is_hex
train
def ensure_image_is_hex(input_path): """Return a path to a hex version of a firmware image. If the input file is already in hex format then input_path is returned and nothing is done. If it is not in hex format then an SCons action is added to convert it to hex and the target output file path is r...
python
{ "resource": "" }
q239198
EmulatedDevice._dispatch_rpc
train
def _dispatch_rpc(self, address, rpc_id, arg_payload): """Background work queue handler to dispatch RPCs.""" if self.emulator.is_tile_busy(address): self._track_change('device.rpc_busy_response', (address, rpc_id, arg_payload, None, None), formatter=format_rpc) raise BusyRPCResp...
python
{ "resource": "" }
q239199
EmulatedDevice.rpc
train
def rpc(self, address, rpc_id, *args, **kwargs): """Immediately dispatch an RPC inside this EmulatedDevice. This function is meant to be used for testing purposes as well as by tiles inside a complex EmulatedDevice subclass that need to communicate with each other. It should only be ca...
python
{ "resource": "" }