_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
75
19.8k
language
stringclasses
1 value
meta_information
dict
q238600
DataStreamer.build_report
train
def build_report(self, device_id, max_size=None, device_uptime=0, report_id=None, auth_chain=None): """Build a report with all of the readings in this streamer. This method will produce an IOTileReport subclass and, if necessary, sign it using the passed authentication chain. Args: ...
python
{ "resource": "" }
q238601
SlotIdentifier.matches
train
def matches(self, address, name=None): """Check if this slot identifier matches the given tile. Matching can happen either by address or by module name (not currently implemented). Returns: bool: True if there is a match, otherwise False. """ if self.controller: ...
python
{ "resource": "" }
q238602
SlotIdentifier.FromString
train
def FromString(cls, desc): """Create a slot identifier from a string description. The string needs to be either: controller OR slot <X> where X is an integer that can be converted with int(X, 0) Args: desc (str): The string description of the slot ...
python
{ "resource": "" }
q238603
SlotIdentifier.FromEncoded
train
def FromEncoded(cls, bindata): """Create a slot identifier from an encoded binary descriptor. These binary descriptors are used to communicate slot targeting to an embedded device. They are exactly 8 bytes in length. Args: bindata (bytes): The 8-byte binary descriptor. ...
python
{ "resource": "" }
q238604
SlotIdentifier.encode
train
def encode(self): """Encode this slot identifier into a binary descriptor. Returns: bytes: The 8-byte encoded slot identifier """ slot = 0 match_op = self.KNOWN_MATCH_NAMES['match_controller'] if not self.controller: slot = self.slot ...
python
{ "resource": "" }
q238605
_scons_syntax_error
train
def _scons_syntax_error(e): """Handle syntax errors. Print out a message and show where the error occurred. """ etype, value, tb = sys.exc_info() lines = traceback.format_exception_only(etype, value) for line in lines: sys.stderr.write(line+'\n') sys.exit(2)
python
{ "resource": "" }
q238606
find_deepest_user_frame
train
def find_deepest_user_frame(tb): """ Find the deepest stack frame that is not part of SCons. Input is a "pre-processed" stack trace in the form returned by traceback.extract_tb() or traceback.extract_stack() """ tb.reverse() # find the deepest traceback frame that is not part # of SCo...
python
{ "resource": "" }
q238607
_scons_user_error
train
def _scons_user_error(e): """Handle user errors. Print out a message and a description of the error, along with the line number and routine where it occured. The file and line number will be the deepest stack frame that is not part of SCons itself. """ global print_stacktrace etype, value, t...
python
{ "resource": "" }
q238608
_scons_user_warning
train
def _scons_user_warning(e): """Handle user warnings. Print out a message and a description of the warning, along with the line number and routine where it occured. The file and line number will be the deepest stack frame that is not part of SCons itself. """ etype, value, tb = sys.exc_info() ...
python
{ "resource": "" }
q238609
_SConstruct_exists
train
def _SConstruct_exists(dirname='', repositories=[], filelist=None): """This function checks that an SConstruct file exists in a directory. If so, it returns the path of the file. By default, it checks the current directory. """ if not filelist: filelist = ['SConstruct', 'Sconstruct', 'sconst...
python
{ "resource": "" }
q238610
BuildTask.make_ready
train
def make_ready(self): """Make a task ready for execution""" SCons.Taskmaster.OutOfDateTask.make_ready(self) if self.out_of_date and self.options.debug_explain: explanation = self.out_of_date[0].explain() if explanation: sys.stdout.write("scons: " + explana...
python
{ "resource": "" }
q238611
_unpack_version
train
def _unpack_version(tag_data): """Parse a packed version info struct into tag and major.minor version. The tag and version are parsed out according to 20 bits for tag and 6 bits each for major and minor. The more interesting part is the blacklisting performed for tags that are known to be untrustworth...
python
{ "resource": "" }
q238612
ReferenceController._handle_reset
train
def _handle_reset(self): """Reset this controller tile. This process will call _handle_reset() for all of the controller subsystem mixins in order to make sure they all return to their proper reset state. It will then reset all of the peripheral tiles to emulate the behavior ...
python
{ "resource": "" }
q238613
ReferenceController._reset_vector
train
async def _reset_vector(self): """Initialize the controller's subsystems inside the emulation thread.""" # Send ourselves all of our config variable assignments config_rpcs = self.config_database.stream_matching(8, self.name) for rpc in config_rpcs: await self._device.emulat...
python
{ "resource": "" }
q238614
ReferenceController.hardware_version
train
def hardware_version(self): """Get a hardware identification string.""" hardware_string = self.hardware_string if not isinstance(hardware_string, bytes): hardware_string = self.hardware_string.encode('utf-8') if len(hardware_string) > 10: self._logger.warn("Tru...
python
{ "resource": "" }
q238615
ReferenceController.controller_info
train
def controller_info(self): """Get the controller UUID, app tag and os tag.""" return [self._device.iotile_id, _pack_version(*self.os_info), _pack_version(*self.app_info)]
python
{ "resource": "" }
q238616
ReferenceController.load_sgf
train
def load_sgf(self, sgf_data): """Load, persist a sensor_graph file. The data passed in `sgf_data` can either be a path or the already loaded sgf lines as a string. It is determined to be sgf lines if there is a '\n' character in the data, otherwise it is interpreted as a path. ...
python
{ "resource": "" }
q238617
ParsedCFile._parse_file
train
def _parse_file(self): """Preprocess and parse C file into an AST""" # We need to set the CPU type to pull in the right register definitions # only preprocess the file (-E) and get rid of gcc extensions that aren't # supported in ISO C. args = utilities.build_includes(self.arch....
python
{ "resource": "" }
q238618
_clear_queue
train
def _clear_queue(to_clear): """Clear all items from a queue safely.""" while not to_clear.empty(): try: to_clear.get(False) to_clear.task_done() except queue.Empty: continue
python
{ "resource": "" }
q238619
_RecordedRPC.finish
train
def finish(self, status, response): """Mark the end of a recorded RPC.""" self.response = binascii.hexlify(response).decode('utf-8') self.status = status self.runtime = monotonic() - self._start_time
python
{ "resource": "" }
q238620
_RecordedRPC.serialize
train
def serialize(self): """Convert this recorded RPC into a string.""" return "{},{: <26},{:2d},{:#06x},{:#04x},{:5.0f},{: <40},{: <40},{}".\ format(self.connection, self.start_stamp.isoformat(), self.address, self.rpc_id, self.status, self.runtime * 1000, self.call, self.re...
python
{ "resource": "" }
q238621
AdapterStream.scan
train
def scan(self, wait=None): """Return the devices that have been found for this device adapter. If the adapter indicates that we need to explicitly tell it to probe for devices, probe now. By default we return the list of seen devices immediately, however there are two cases where we wil...
python
{ "resource": "" }
q238622
AdapterStream.connect
train
def connect(self, uuid_value, wait=None): """Connect to a specific device by its uuid Attempt to connect to a device that we have previously scanned using its UUID. If wait is not None, then it is used in the same was a scan(wait) to override default wait times with an explicit value. ...
python
{ "resource": "" }
q238623
AdapterStream.connect_direct
train
def connect_direct(self, connection_string, no_rpc=False, force=False): """Directly connect to a device using its stream specific connection string. Normally, all connections to a device include opening the RPC interface to send RPCs. However, there are certain, very specific, circumst...
python
{ "resource": "" }
q238624
AdapterStream.disconnect
train
def disconnect(self): """Disconnect from the device that we are currently connected to.""" if not self.connected: raise HardwareError("Cannot disconnect when we are not connected") # Close the streaming and tracing interfaces when we disconnect self._reports = None ...
python
{ "resource": "" }
q238625
AdapterStream._try_reconnect
train
def _try_reconnect(self): """Try to recover an interrupted connection.""" try: if self.connection_interrupted: self.connect_direct(self.connection_string, force=True) self.connection_interrupted = False self.connected = True #...
python
{ "resource": "" }
q238626
AdapterStream.send_rpc
train
def send_rpc(self, address, rpc_id, call_payload, timeout=3.0): """Send an rpc to our connected device. The device must already be connected and the rpc interface open. This method will synchronously send an RPC and wait for the response. Any RPC errors will be raised as exceptions an...
python
{ "resource": "" }
q238627
AdapterStream.send_highspeed
train
def send_highspeed(self, data, progress_callback): """Send a script to a device at highspeed, reporting progress. This method takes a binary blob and downloads it to the device as fast as possible, calling the passed progress_callback periodically with updates on how far it has gotten. ...
python
{ "resource": "" }
q238628
AdapterStream.enable_streaming
train
def enable_streaming(self): """Open the streaming interface and accumute reports in a queue. This method is safe to call multiple times in a single device connection. There is no way to check if the streaming interface is opened or to close it once it is opened (apart from disconnecting...
python
{ "resource": "" }
q238629
AdapterStream.enable_tracing
train
def enable_tracing(self): """Open the tracing interface and accumulate traces in a queue. This method is safe to call multiple times in a single device connection. There is no way to check if the tracing interface is opened or to close it once it is opened (apart from disconnecting from...
python
{ "resource": "" }
q238630
AdapterStream.enable_broadcasting
train
def enable_broadcasting(self): """Begin accumulating broadcast reports received from all devices. This method will allocate a queue to receive broadcast reports that will be filled asynchronously as broadcast reports are received. Returns: queue.Queue: A queue that will be ...
python
{ "resource": "" }
q238631
AdapterStream.enable_debug
train
def enable_debug(self): """Open the debug interface on the connected device.""" if not self.connected: raise HardwareError("Cannot enable debug if we are not in a connected state") self._loop.run_coroutine(self.adapter.open_interface(0, 'debug'))
python
{ "resource": "" }
q238632
AdapterStream.debug_command
train
def debug_command(self, cmd, args=None, progress_callback=None): """Send a debug command to the connected device. This generic method will send a named debug command with the given arguments to the connected device. Debug commands are typically used for things like forcible reflashing ...
python
{ "resource": "" }
q238633
AdapterStream.close
train
def close(self): """Close this adapter stream. This method may only be called once in the lifetime of an AdapterStream and it will shutdown the underlying device adapter, disconnect all devices and stop all background activity. If this stream is configured to save a record of a...
python
{ "resource": "" }
q238634
AdapterStream._on_scan
train
def _on_scan(self, info): """Callback called when a new device is discovered on this CMDStream Args: info (dict): Information about the scanned device """ device_id = info['uuid'] expiration_time = info.get('validity_period', 60) infocopy = deepcopy(info) ...
python
{ "resource": "" }
q238635
AdapterStream._on_disconnect
train
def _on_disconnect(self): """Callback when a device is disconnected unexpectedly. Args: adapter_id (int): An ID for the adapter that was connected to the device connection_id (int): An ID for the connection that has become disconnected """ self._logger.info("Con...
python
{ "resource": "" }
q238636
midl_emitter
train
def midl_emitter(target, source, env): """Produces a list of outputs from the MIDL compiler""" base, _ = SCons.Util.splitext(str(target[0])) tlb = target[0] incl = base + '.h' interface = base + '_i.c' targets = [tlb, incl, interface] midlcom = env['MIDLCOM'] if midlcom.find('/proxy') ...
python
{ "resource": "" }
q238637
generate
train
def generate(env): """Add Builders and construction variables for midl to an Environment.""" env['MIDL'] = 'MIDL.EXE' env['MIDLFLAGS'] = SCons.Util.CLVar('/nologo') env['MIDLCOM'] = '$MIDL $MIDLFLAGS /tlb ${TARGETS[0]} /h ${TARGETS[1]} /iid ${TARGETS[2]} /proxy ${TARGETS[3]} /dlldata...
python
{ "resource": "" }
q238638
Base.set_entry
train
def set_entry(self, filename, obj): """ Set the entry. """ self.entries[filename] = obj self.dirty = True
python
{ "resource": "" }
q238639
DirFile.write
train
def write(self, sync=1): """ Write the .sconsign file to disk. Try to write to a temporary file first, and rename it if we succeed. If we can't write to the temporary file, it's probably because the directory isn't writable (and if so, how did we build anything in this ...
python
{ "resource": "" }
q238640
generate
train
def generate(env): """Add Builders and construction variables for MIPSPro to an Environment.""" link.generate(env) env['LINK'] = env.Detect(linkers) or 'cc' env['SHLINKFLAGS'] = SCons.Util.CLVar('$LINKFLAGS -shared') # __RPATH is set to $_RPATH in the platform specification if that # platf...
python
{ "resource": "" }
q238641
IOTileSupervisor.start
train
async def start(self): """Start the supervisor server.""" await self.server.start() self.port = self.server.port
python
{ "resource": "" }
q238642
IOTileSupervisor.prepare_conn
train
async def prepare_conn(self, conn): """Setup a new connection from a client.""" client_id = str(uuid.uuid4()) monitor = functools.partial(self.send_event, client_id) self._logger.info("New client connection: %s", client_id) self.service_manager.add_monitor(monitor) se...
python
{ "resource": "" }
q238643
IOTileSupervisor.teardown_conn
train
async def teardown_conn(self, context): """Teardown a connection from a client.""" client_id = context.user_data self._logger.info("Tearing down client connection: %s", client_id) if client_id not in self.clients: self._logger.warning("client_id %s did not exist in teardown...
python
{ "resource": "" }
q238644
IOTileSupervisor.send_event
train
async def send_event(self, client_id, service_name, event_name, event_info, directed_client=None): """Send an event to a client.""" if directed_client is not None and directed_client != client_id: return client_info = self.clients.get(client_id) if client_info is None: ...
python
{ "resource": "" }
q238645
IOTileSupervisor.send_rpc
train
async def send_rpc(self, msg, _context): """Send an RPC to a service on behalf of a client.""" service = msg.get('name') rpc_id = msg.get('rpc_id') payload = msg.get('payload') timeout = msg.get('timeout') response_id = await self.service_manager.send_rpc_command(servic...
python
{ "resource": "" }
q238646
IOTileSupervisor.respond_rpc
train
async def respond_rpc(self, msg, _context): """Respond to an RPC previously sent to a service.""" rpc_id = msg.get('response_uuid') result = msg.get('result') payload = msg.get('response') self.service_manager.send_rpc_response(rpc_id, result, payload)
python
{ "resource": "" }
q238647
IOTileSupervisor.set_agent
train
async def set_agent(self, msg, context): """Mark a client as the RPC agent for a service.""" service = msg.get('name') client = context.user_data self.service_manager.set_agent(service, client)
python
{ "resource": "" }
q238648
IOTileSupervisor.service_messages
train
async def service_messages(self, msg, _context): """Get all messages for a service.""" msgs = self.service_manager.service_messages(msg.get('name')) return [x.to_dict() for x in msgs]
python
{ "resource": "" }
q238649
IOTileSupervisor.service_headline
train
async def service_headline(self, msg, _context): """Get the headline for a service.""" headline = self.service_manager.service_headline(msg.get('name')) if headline is not None: headline = headline.to_dict() return headline
python
{ "resource": "" }
q238650
generate
train
def generate(env): """Add Builders and construction variables for nasm to an Environment.""" static_obj, shared_obj = SCons.Tool.createObjBuilders(env) for suffix in ASSuffixes: static_obj.add_action(suffix, SCons.Defaults.ASAction) static_obj.add_emitter(suffix, SCons.Defaults.StaticObject...
python
{ "resource": "" }
q238651
generate
train
def generate(env): """Add Builders and construction variables for Forte to an Environment.""" link.generate(env) env['SHLINKFLAGS'] = SCons.Util.CLVar('$LINKFLAGS -G') env['RPATHPREFIX'] = '-R' env['RPATHSUFFIX'] = '' env['_RPATH'] = '${_concat(RPATHPREFIX, RPATH, RPATHSUFFIX, __env__)}' ...
python
{ "resource": "" }
q238652
Verifier._get_short_description
train
def _get_short_description(self): """Return the first line of a multiline description Returns: string: The short description, otherwise None """ if self.description is None: return None lines = [x for x in self.description.split('\n')] if len(li...
python
{ "resource": "" }
q238653
Verifier._get_long_description
train
def _get_long_description(self): """Return the subsequent lines of a multiline description Returns: string: The long description, otherwise None """ if self.description is None: return None lines = [x for x in self.description.split('\n')] if le...
python
{ "resource": "" }
q238654
Verifier.wrap_lines
train
def wrap_lines(self, text, indent_level, indent_size=4): """Indent a multiline string Args: text (string): The string to indent indent_level (int): The number of indent_size spaces to prepend to each line indent_size (int): The number of spaces to pre...
python
{ "resource": "" }
q238655
Verifier.format_name
train
def format_name(self, name, indent_size=4): """Format the name of this verifier The name will be formatted as: <name>: <short description> long description if one is given followed by \n otherwise no long description Args: name (string): ...
python
{ "resource": "" }
q238656
Verifier.trim_whitespace
train
def trim_whitespace(self, text): """Remove leading whitespace from each line of a multiline string Args: text (string): The text to be unindented Returns: string: The unindented block of text """ lines = text.split('\n') new_lines = [x.lstrip() ...
python
{ "resource": "" }
q238657
__extend_targets_sources
train
def __extend_targets_sources(target, source): """ Prepare the lists of target and source files. """ if not SCons.Util.is_List(target): target = [target] if not source: source = target[:] elif not SCons.Util.is_List(source): source = [source] if len(target) < len(source): ...
python
{ "resource": "" }
q238658
__select_builder
train
def __select_builder(lxml_builder, libxml2_builder, cmdline_builder): """ Selects a builder, based on which Python modules are present. """ if prefer_xsltproc: return cmdline_builder if not has_libxml2: # At the moment we prefer libxml2 over lxml, the latter can lead # to confli...
python
{ "resource": "" }
q238659
__ensure_suffix
train
def __ensure_suffix(t, suffix): """ Ensure that the target t has the given suffix. """ tpath = str(t) if not tpath.endswith(suffix): return tpath+suffix return t
python
{ "resource": "" }
q238660
__ensure_suffix_stem
train
def __ensure_suffix_stem(t, suffix): """ Ensure that the target t has the given suffix, and return the file's stem. """ tpath = str(t) if not tpath.endswith(suffix): stem = tpath tpath += suffix return tpath, stem else: stem, ext = os.path.splitext(tpath) ...
python
{ "resource": "" }
q238661
__create_output_dir
train
def __create_output_dir(base_dir): """ Ensure that the output directory base_dir exists. """ root, tail = os.path.split(base_dir) dir = None if tail: if base_dir.endswith('/'): dir = base_dir else: dir = root else: if base_dir.endswith('/'): ...
python
{ "resource": "" }
q238662
__detect_cl_tool
train
def __detect_cl_tool(env, chainkey, cdict, cpriority=None): """ Helper function, picks a command line tool from the list and initializes its environment variables. """ if env.get(chainkey,'') == '': clpath = '' if cpriority is None: cpriority = cdict.keys() for c...
python
{ "resource": "" }
q238663
_detect
train
def _detect(env): """ Detect all the command line tools that we might need for creating the requested output formats. """ global prefer_xsltproc if env.get('DOCBOOK_PREFER_XSLTPROC',''): prefer_xsltproc = True if ((not has_libxml2 and not has_lxml) or (prefer_xsltproc))...
python
{ "resource": "" }
q238664
__xml_scan
train
def __xml_scan(node, env, path, arg): """ Simple XML file scanner, detecting local images and XIncludes as implicit dependencies. """ # Does the node exist yet? if not os.path.isfile(str(node)): return [] if env.get('DOCBOOK_SCANENT',''): # Use simple pattern matching for system ent...
python
{ "resource": "" }
q238665
__xinclude_libxml2
train
def __xinclude_libxml2(target, source, env): """ Resolving XIncludes, using the libxml2 module. """ doc = libxml2.readFile(str(source[0]), None, libxml2.XML_PARSE_NOENT) doc.xincludeProcessFlags(libxml2.XML_PARSE_NOENT) doc.saveFile(str(target[0])) doc.freeDoc() return None
python
{ "resource": "" }
q238666
__xinclude_lxml
train
def __xinclude_lxml(target, source, env): """ Resolving XIncludes, using the lxml module. """ from lxml import etree doc = etree.parse(str(source[0])) doc.xinclude() try: doc.write(str(target[0]), xml_declaration=True, encoding="UTF-8", pretty_print=True) ...
python
{ "resource": "" }
q238667
DocbookHtml
train
def DocbookHtml(env, target, source=None, *args, **kw): """ A pseudo-Builder, providing a Docbook toolchain for HTML output. """ # Init list of targets/sources target, source = __extend_targets_sources(target, source) # Init XSL stylesheet __init_xsl_stylesheet(kw, env, '$DOCBOOK_DEFAUL...
python
{ "resource": "" }
q238668
DocbookMan
train
def DocbookMan(env, target, source=None, *args, **kw): """ A pseudo-Builder, providing a Docbook toolchain for Man page output. """ # Init list of targets/sources target, source = __extend_targets_sources(target, source) # Init XSL stylesheet __init_xsl_stylesheet(kw, env, '$DOCBOOK_DEFAULT...
python
{ "resource": "" }
q238669
DocbookSlidesPdf
train
def DocbookSlidesPdf(env, target, source=None, *args, **kw): """ A pseudo-Builder, providing a Docbook toolchain for PDF slides output. """ # Init list of targets/sources target, source = __extend_targets_sources(target, source) # Init XSL stylesheet __init_xsl_stylesheet(kw, env, '$DOCBOOK...
python
{ "resource": "" }
q238670
DocbookSlidesHtml
train
def DocbookSlidesHtml(env, target, source=None, *args, **kw): """ A pseudo-Builder, providing a Docbook toolchain for HTML slides output. """ # Init list of targets/sources if not SCons.Util.is_List(target): target = [target] if not source: source = target target = ['inde...
python
{ "resource": "" }
q238671
DocbookXInclude
train
def DocbookXInclude(env, target, source, *args, **kw): """ A pseudo-Builder, for resolving XIncludes in a separate processing step. """ # Init list of targets/sources target, source = __extend_targets_sources(target, source) # Setup builder __builder = __select_builder(__xinclude_lxml_build...
python
{ "resource": "" }
q238672
DocbookXslt
train
def DocbookXslt(env, target, source=None, *args, **kw): """ A pseudo-Builder, applying a simple XSL transformation to the input file. """ # Init list of targets/sources target, source = __extend_targets_sources(target, source) # Init XSL stylesheet kw['DOCBOOK_XSL'] = kw.get('xsl', 'tra...
python
{ "resource": "" }
q238673
generate
train
def generate(env): """Add Builders and construction variables for docbook to an Environment.""" env.SetDefault( # Default names for customized XSL stylesheets DOCBOOK_DEFAULT_XSL_EPUB = '', DOCBOOK_DEFAULT_XSL_HTML = '', DOCBOOK_DEFAULT_XSL_HTMLCHUNKED = '', DOCBOOK_DEFA...
python
{ "resource": "" }
q238674
RCFile.save
train
def save(self): """Update the configuration file on disk with the current contents of self.contents. Previous contents are overwritten. """ try: with open(self.path, "w") as f: f.writelines(self.contents) except IOError as e: raise Interna...
python
{ "resource": "" }
q238675
WebSocketDeviceServer.probe_message
train
async def probe_message(self, _message, context): """Handle a probe message. See :meth:`AbstractDeviceAdapter.probe`. """ client_id = context.user_data await self.probe(client_id)
python
{ "resource": "" }
q238676
WebSocketDeviceServer.connect_message
train
async def connect_message(self, message, context): """Handle a connect message. See :meth:`AbstractDeviceAdapter.connect`. """ conn_string = message.get('connection_string') client_id = context.user_data await self.connect(client_id, conn_string)
python
{ "resource": "" }
q238677
WebSocketDeviceServer.disconnect_message
train
async def disconnect_message(self, message, context): """Handle a disconnect message. See :meth:`AbstractDeviceAdapter.disconnect`. """ conn_string = message.get('connection_string') client_id = context.user_data await self.disconnect(client_id, conn_string)
python
{ "resource": "" }
q238678
WebSocketDeviceServer.open_interface_message
train
async def open_interface_message(self, message, context): """Handle an open_interface message. See :meth:`AbstractDeviceAdapter.open_interface`. """ conn_string = message.get('connection_string') interface = message.get('interface') client_id = context.user_data ...
python
{ "resource": "" }
q238679
WebSocketDeviceServer.close_interface_message
train
async def close_interface_message(self, message, context): """Handle a close_interface message. See :meth:`AbstractDeviceAdapter.close_interface`. """ conn_string = message.get('connection_string') interface = message.get('interface') client_id = context.user_data ...
python
{ "resource": "" }
q238680
WebSocketDeviceServer.send_rpc_message
train
async def send_rpc_message(self, message, context): """Handle a send_rpc message. See :meth:`AbstractDeviceAdapter.send_rpc`. """ conn_string = message.get('connection_string') rpc_id = message.get('rpc_id') address = message.get('address') timeout = message.get...
python
{ "resource": "" }
q238681
WebSocketDeviceServer.send_script_message
train
async def send_script_message(self, message, context): """Handle a send_script message. See :meth:`AbstractDeviceAdapter.send_script`. """ script = message.get('script') conn_string = message.get('connection_string') client_id = context.user_data if message.get...
python
{ "resource": "" }
q238682
WebSocketDeviceServer.debug_command_message
train
async def debug_command_message(self, message, context): """Handle a debug message. See :meth:`AbstractDeviceAdapter.debug`. """ conn_string = message.get('connection_string') command = message.get('command') args = message.get('args') client_id = context.user_d...
python
{ "resource": "" }
q238683
WebSocketDeviceServer.client_event_handler
train
async def client_event_handler(self, client_id, event_tuple, user_data): """Forward an event on behalf of a client. This method is called by StandardDeviceServer when it has an event that should be sent to a client. Args: client_id (str): The client that we should send this...
python
{ "resource": "" }
q238684
generate
train
def generate(env): """Add Builders and construction variables for sun f90 compiler to an Environment.""" add_all_to_env(env) fcomp = env.Detect(compilers) or 'f90' env['FORTRAN'] = fcomp env['F90'] = fcomp env['SHFORTRAN'] = '$FORTRAN' env['SHF90'] = '$F90' env['SHFORT...
python
{ "resource": "" }
q238685
Builder
train
def Builder(**kw): """A factory for builder objects.""" composite = None if 'generator' in kw: if 'action' in kw: raise UserError("You must not specify both an action and a generator.") kw['action'] = SCons.Action.CommandGeneratorAction(kw['generator'], {}) del kw['genera...
python
{ "resource": "" }
q238686
_node_errors
train
def _node_errors(builder, env, tlist, slist): """Validate that the lists of target and source nodes are legal for this builder and environment. Raise errors or issue warnings as appropriate. """ # First, figure out if there are any errors in the way the targets # were specified. for t in t...
python
{ "resource": "" }
q238687
is_a_Builder
train
def is_a_Builder(obj): """"Returns True if the specified obj is one of our Builder classes. The test is complicated a bit by the fact that CompositeBuilder is a proxy, not a subclass of BuilderBase. """ return (isinstance(obj, BuilderBase) or isinstance(obj, CompositeBuilder) ...
python
{ "resource": "" }
q238688
BuilderBase.get_name
train
def get_name(self, env): """Attempts to get the name of the Builder. Look at the BUILDERS variable of env, expecting it to be a dictionary containing this Builder, and return the key of the dictionary. If there's no key, then return a directly-configured name (if there is one) ...
python
{ "resource": "" }
q238689
BuilderBase._create_nodes
train
def _create_nodes(self, env, target = None, source = None): """Create and return lists of target and source nodes. """ src_suf = self.get_src_suffix(env) target_factory = env.get_factory(self.target_factory) source_factory = env.get_factory(self.source_factory) source =...
python
{ "resource": "" }
q238690
BuilderBase._get_sdict
train
def _get_sdict(self, env): """ Returns a dictionary mapping all of the source suffixes of all src_builders of this Builder to the underlying Builder that should be called first. This dictionary is used for each target specified, so we save a lot of extra computation by m...
python
{ "resource": "" }
q238691
BuilderBase.get_src_builders
train
def get_src_builders(self, env): """ Returns the list of source Builders for this Builder. This exists mainly to look up Builders referenced as strings in the 'BUILDER' variable of the construction environment and cache the result. """ memo_key = id(env) ...
python
{ "resource": "" }
q238692
BuilderBase.subst_src_suffixes
train
def subst_src_suffixes(self, env): """ The suffix list may contain construction variable expansions, so we have to evaluate the individual strings. To avoid doing this over and over, we memoize the results for each construction environment. """ memo_key = id(env)...
python
{ "resource": "" }
q238693
BuilderBase.src_suffixes
train
def src_suffixes(self, env): """ Returns the list of source suffixes for all src_builders of this Builder. This is essentially a recursive descent of the src_builder "tree." (This value isn't cached because there may be changes in a src_builder many levels deep that we c...
python
{ "resource": "" }
q238694
generate
train
def generate(env): """ Add Builders and construction variables for Visual Age linker to an Environment. """ link.generate(env) env['SMARTLINKFLAGS'] = smart_linkflags env['LINKFLAGS'] = SCons.Util.CLVar('$SMARTLINKFLAGS') env['SHLINKFLAGS'] = SCons.Util.CLVar('$LINKFLAGS -qmkshr...
python
{ "resource": "" }
q238695
_parse_target
train
def _parse_target(target): """Parse a binary targeting information structure. This function only supports extracting the slot number or controller from the target and will raise an ArgumentError if more complicated targeting is desired. Args: target (bytes): The binary targeting data blob....
python
{ "resource": "" }
q238696
RPCQueue.put_task
train
def put_task(self, func, args, response): """Place a task onto the RPC queue. This temporary functionality will go away but it lets you run a task synchronously with RPC dispatch by placing it onto the RCP queue. Args: func (callable): The function to execute ...
python
{ "resource": "" }
q238697
RPCQueue.put_rpc
train
def put_rpc(self, address, rpc_id, arg_payload, response): """Place an RPC onto the RPC queue. The rpc will be dispatched asynchronously by the background dispatch task. This method must be called from the event loop. This method does not block. Args: address (int...
python
{ "resource": "" }
q238698
RPCQueue.stop
train
async def stop(self): """Stop the rpc queue from inside the event loop.""" if self._rpc_task is not None: self._rpc_task.cancel() try: await self._rpc_task except asyncio.CancelledError: pass self._rpc_task = None
python
{ "resource": "" }
q238699
SparseMemory.add_segment
train
def add_segment(self, address, data, overwrite=False): """Add a contiguous segment of data to this memory map If the segment overlaps with a segment already added , an ArgumentError is raised unless the overwrite flag is True. Params: address (int): The starting address for...
python
{ "resource": "" }