Code
stringlengths
103
85.9k
Summary
listlengths
0
94
Please provide a description of the function:def set_result(self, result): if self.is_finished(): raise InternalError("set_result called on finished AsynchronousResponse", result=self._result, exception=self._exception) self._result = result ...
[ "Finish this response and set the result." ]
Please provide a description of the function:def set_exception(self, exc_class, exc_info, exc_stack): if self.is_finished(): raise InternalError("set_exception called on finished AsynchronousResponse", result=self._result, exception=self._exception) ...
[ "Set an exception as the result of this operation.\n\n Args:\n exc_class (object): The exception type " ]
Please provide a description of the function:def wait(self, timeout=None): flag = self._finished.wait(timeout=timeout) if flag is False: raise TimeoutExpiredError("Timeout waiting for response to event loop operation") if self._exception is not None: self._rais...
[ "Wait for this operation to finish.\n\n You can specify an optional timeout that defaults to no timeout if\n None is passed. The result of the operation is returned from this\n method. If the operation raised an exception, it is reraised from this\n method.\n\n Args:\n ...
Please provide a description of the function:async def wait(self, timeout=None): await asyncio.wait_for(self._future, timeout) if self._exception is not None: self._raise_exception() return self._result
[ "Wait for this operation to finish.\n\n You can specify an optional timeout that defaults to no timeout if\n None is passed. The result of the operation is returned from this\n method. If the operation raised an exception, it is reraised from this\n method.\n\n Args:\n ...
Please provide a description of the function:def get_released_versions(component): releases = get_tags() releases = sorted([(x[0], [int(y) for y in x[1].split('.')]) for x in releases], key=lambda x: x[1])[::-1] return [(x[0], ".".join(map(str, x[1]))) for x in releases if x[0] == component]
[ "Get all released versions of the given component ordered newest to oldest\n " ]
Please provide a description of the function:def do_releases(self, subcmd, opts, component): releases = get_released_versions(component) for x in releases: print("{} - {}".format(*x))
[ "${cmd_name}: print all releases for the given component\n\n ${cmd_usage}\n ${cmd_option_list}\n " ]
Please provide a description of the function:def do_dirty(self, subcmd, opts): for comp_name, comp in components.comp_names.items(): releases = get_released_versions(comp_name) if len(releases) == 0: print(comp_name + ' - ' + 'No tagged releases') el...
[ "${cmd_name}: check if any components have unreleased changes\n\n ${cmd_usage}\n ${cmd_option_list}\n " ]
Please provide a description of the function:def do_changed(self, subcmd, opts, component): releases = get_released_versions(component) latest = releases[0] filter_dir = components.comp_names[component].path latest_tag = '-'.join(latest) data = get_changed_since_tag(l...
[ "${cmd_name}: print all files changes in component since the latest release\n\n ${cmd_usage}\n ${cmd_option_list}\n " ]
Please provide a description of the function:def load_dependencies(orig_tile, build_env): if 'DEPENDENCIES' not in build_env: build_env['DEPENDENCIES'] = [] dep_targets = [] chip = build_env['ARCH'] raw_arch_deps = chip.property('depends') # Properly separate out the version informat...
[ "Load all tile dependencies and filter only the products from each that we use\n\n build_env must define the architecture that we are targeting so that we get the\n correct dependency list and products per dependency since that may change\n when building for different architectures\n " ]
Please provide a description of the function:def find_dependency_wheels(tile): return [os.path.join(x.folder, 'python', x.support_wheel) for x in _iter_dependencies(tile) if x.has_wheel]
[ "Return a list of all python wheel objects created by dependencies of this tile\n\n Args:\n tile (IOTile): Tile that we should scan for dependencies\n\n Returns:\n list: A list of paths to dependency wheels\n " ]
Please provide a description of the function:def _check_ver_range(self, version, ver_range): lower, upper, lower_inc, upper_inc = ver_range #If the range extends over everything, we automatically match if lower is None and upper is None: return True if lower is no...
[ "Check if version is included in ver_range\n " ]
Please provide a description of the function:def _check_insersection(self, version, ranges): for ver_range in ranges: if not self._check_ver_range(version, ver_range): return False return True
[ "Check that a version is inside all of a list of ranges" ]
Please provide a description of the function:def check(self, version): for disjunct in self._disjuncts: if self._check_insersection(version, disjunct): return True return False
[ "Check that a version is inside this SemanticVersionRange\n\n Args:\n version (SemanticVersion): The version to check\n\n Returns:\n bool: True if the version is included in the range, False if not\n " ]
Please provide a description of the function:def filter(self, versions, key=lambda x: x): return [x for x in versions if self.check(key(x))]
[ "Filter all of the versions in an iterable that match this version range\n\n Args:\n versions (iterable): An iterable of SemanticVersion objects\n\n Returns:\n list: A list of the SemanticVersion objects that matched this range\n " ]
Please provide a description of the function:def FromString(cls, range_string): disjuncts = None range_string = range_string.strip() if len(range_string) == 0: raise ArgumentError("You must pass a finite string to SemanticVersionRange.FromString", ...
[ "Parse a version range string into a SemanticVersionRange\n\n Currently, the only possible range strings are:\n\n ^X.Y.Z - matches all versions with the same leading nonzero digit\n greater than or equal the given range.\n * - matches everything\n =X.Y.Z - matches only the exa...
Please provide a description of the function:def _call_rpc(self, address, rpc_id, payload): # FIXME: Set a timeout of 1.1 seconds to make sure we fail if the device hangs but # this should be long enough to accommodate any actual RPCs we need to send. status, response = self.hw...
[ "Call an RPC with the given information and return its response.\n\n Must raise a hardware error of the appropriate kind if the RPC\n can not be executed correctly. Otherwise it should return the binary\n response payload received from the RPC.\n\n Args:\n address (int): The ...
Please provide a description of the function:def FromReadings(cls, uuid, readings): if len(readings) != 1: raise ArgumentError("IndividualReading reports must be created with exactly one reading", num_readings=len(readings)) reading = readings[0] ...
[ "Generate an instance of the report format from a list of readings and a uuid\n " ]
Please provide a description of the function:def decode(self): fmt, _, stream, uuid, sent_timestamp, reading_timestamp, reading_value = unpack("<BBHLLLL", self.raw_report) assert fmt == 0 # Estimate the UTC time when this device was turned on time_base = self.received_time - d...
[ "Decode this report into a single reading\n " ]
Please provide a description of the function:def encode(self): reading = self.visible_readings[0] data = struct.pack("<BBHLLLL", 0, 0, reading.stream, self.origin, self.sent_timestamp, reading.raw_time, reading.value) return bytearray(data)
[ "Turn this report into a serialized bytearray that could be decoded with a call to decode" ]
Please provide a description of the function:def InternalLaTeXAuxAction(XXXLaTeXAction, target = None, source= None, env=None): global must_rerun_latex # This routine is called with two actions. In this file for DVI builds # with LaTeXAction and from the pdflatex.py with PDFLaTeXAction # set this...
[ "A builder for LaTeX files that checks the output in the aux file\n and decides how many times to use LaTeXAction, and BibTeXAction." ]
Please provide a description of the function:def is_LaTeX(flist,env,abspath): # We need to scan files that are included in case the # \documentclass command is in them. # get path list from both env['TEXINPUTS'] and env['ENV']['TEXINPUTS'] savedpath = modify_env_var(env, 'TEXINPUTS', abspath) ...
[ "Scan a file list to decide if it's TeX- or LaTeX-flavored." ]
Please provide a description of the function:def TeXLaTeXFunction(target = None, source= None, env=None): # find these paths for use in is_LaTeX to search for included files basedir = os.path.split(str(source[0]))[0] abspath = os.path.abspath(basedir) if is_LaTeX(source,env,abspath): resu...
[ "A builder for TeX and LaTeX that scans the source file to\n decide the \"flavor\" of the source and then executes the appropriate\n program." ]
Please provide a description of the function:def TeXLaTeXStrFunction(target = None, source= None, env=None): if env.GetOption("no_exec"): # find these paths for use in is_LaTeX to search for included files basedir = os.path.split(str(source[0]))[0] abspath = os.path.abspath(basedir) ...
[ "A strfunction for TeX and LaTeX that scans the source file to\n decide the \"flavor\" of the source and then returns the appropriate\n command string." ]
Please provide a description of the function:def tex_eps_emitter(target, source, env): (target, source) = tex_emitter_core(target, source, env, TexGraphics) return (target, source)
[ "An emitter for TeX and LaTeX sources when\n executing tex or latex. It will accept .ps and .eps\n graphics files\n " ]
Please provide a description of the function:def tex_pdf_emitter(target, source, env): (target, source) = tex_emitter_core(target, source, env, LatexGraphics) return (target, source)
[ "An emitter for TeX and LaTeX sources when\n executing pdftex or pdflatex. It will accept graphics\n files of types .pdf, .jpg, .png, .gif, and .tif\n " ]
Please provide a description of the function:def ScanFiles(theFile, target, paths, file_tests, file_tests_search, env, graphics_extensions, targetdir, aux_files): content = theFile.get_text_contents() if Verbose: print(" scanning ",str(theFile)) for i in range(len(file_tests_search)): ...
[ " For theFile (a Node) update any file_tests and search for graphics files\n then find all included files and call ScanFiles recursively for each of them" ]
Please provide a description of the function:def tex_emitter_core(target, source, env, graphics_extensions): basename = SCons.Util.splitext(str(source[0]))[0] basefile = os.path.split(str(basename))[1] targetdir = os.path.split(str(target[0]))[0] targetbase = os.path.join(targetdir, basefile) ...
[ "An emitter for TeX and LaTeX sources.\n For LaTeX sources we try and find the common created files that\n are needed on subsequent runs of latex to finish tables of contents,\n bibliographies, indices, lists of figures, and hyperlink references.\n " ]
Please provide a description of the function:def generate(env): global TeXLaTeXAction if TeXLaTeXAction is None: TeXLaTeXAction = SCons.Action.Action(TeXLaTeXFunction, strfunction=TeXLaTeXStrFunction) env.AppendUnique(LATEXSUFFIXES=SCons.Tool.LaTeXSuffixes) ...
[ "Add Builders and construction variables for TeX to an Environment." ]
Please provide a description of the function:def generate_common(env): # Add OSX system paths so TeX tools can be found # when a list of tools is given the exists() method is not called generate_darwin(env) # A generic tex file Action, sufficient for all tex files. global TeXAction if TeX...
[ "Add internal Builders and construction variables for LaTeX to an Environment." ]
Please provide a description of the function:def is_win64(): # Unfortunately, python does not provide a useful way to determine # if the underlying Windows OS is 32-bit or 64-bit. Worse, whether # the Python itself is 32-bit or 64-bit affects what it returns, # so nothing in sys.* or os.* help. ...
[ "Return true if running on windows 64 bits.\n\n Works whether python itself runs in 64 bits or 32 bits." ]
Please provide a description of the function:def has_reg(value): try: SCons.Util.RegOpenKeyEx(SCons.Util.HKEY_LOCAL_MACHINE, value) ret = True except SCons.Util.WinError: ret = False return ret
[ "Return True if the given key exists in HKEY_LOCAL_MACHINE, False\n otherwise." ]
Please provide a description of the function:def normalize_env(env, keys, force=False): normenv = {} if env: for k in list(env.keys()): normenv[k] = copy.deepcopy(env[k]) for k in keys: if k in os.environ and (force or not k in normenv): normenv[k] =...
[ "Given a dictionary representing a shell environment, add the variables\n from os.environ needed for the processing of .bat files; the keys are\n controlled by the keys argument.\n\n It also makes sure the environment values are correctly encoded.\n\n If force=True, then all of the key values that exist...
Please provide a description of the function:def get_output(vcbat, args = None, env = None): if env is None: # Create a blank environment, for use in launching the tools env = SCons.Environment.Environment(tools=[]) # TODO: This is a hard-coded list of the variables that (may) need #...
[ "Parse the output of given bat file, with given args." ]
Please provide a description of the function:def parse_output(output, keep=("INCLUDE", "LIB", "LIBPATH", "PATH")): # dkeep is a dict associating key: path_list, where key is one item from # keep, and pat_list the associated list of paths dkeep = dict([(i, []) for i in keep]) # rdk will keep the ...
[ "\n Parse output from running visual c++/studios vcvarsall.bat and running set\n To capture the values listed in keep\n " ]
Please provide a description of the function:def generate(env): for t in SCons.Tool.tool_list(env['PLATFORM'], env): SCons.Tool.Tool(t)(env)
[ "Add default tools." ]
Please provide a description of the function:def verify(self, obj): if not isinstance(obj, int): raise ValidationError("Object is not a int", reason='object is not a int', object=obj, type=type(obj), int_type=int) return obj
[ "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 node_conv(obj): try: get = obj.get except AttributeError: if isinstance(obj, SCons.Node.Node) or SCons.Util.is_Sequence( obj ): result = obj else: result = str(obj) else: result = get() return r...
[ "\n This is the \"string conversion\" routine that we have our substitutions\n use to return Nodes, not strings. This relies on the fact that an\n EntryProxy object has a get() method that returns the underlying\n Node that it wraps, which is a bit of architectural dependence\n that we might need to...
Please provide a description of the function:def subst_path(self, env, target, source): result = [] for type, value in self.pathlist: if type == TYPE_STRING_SUBST: value = env.subst(value, target=target, source=source, conv=node_conv...
[ "\n Performs construction variable substitution on a pre-digested\n PathList for a specific target and source.\n " ]
Please provide a description of the function:def _PathList_key(self, pathlist): if SCons.Util.is_Sequence(pathlist): pathlist = tuple(SCons.Util.flatten(pathlist)) return pathlist
[ "\n Returns the key for memoization of PathLists.\n\n Note that we want this to be pretty quick, so we don't completely\n canonicalize all forms of the same list. For example,\n 'dir1:$ROOT/dir2' and ['$ROOT/dir1', 'dir'] may logically\n represent the same list if you're executin...
Please provide a description of the function:def PathList(self, pathlist): pathlist = self._PathList_key(pathlist) try: memo_dict = self._memo['PathList'] except KeyError: memo_dict = {} self._memo['PathList'] = memo_dict else: try...
[ "\n Returns the cached _PathList object for the specified pathlist,\n creating and caching a new object as necessary.\n " ]
Please provide a description of the function:def DefaultEnvironment(*args, **kw): global _default_env if not _default_env: import SCons.Util _default_env = SCons.Environment.Environment(*args, **kw) if SCons.Util.md5: _default_env.Decider('MD5') else: ...
[ "\n Initial public entry point for creating the default construction\n Environment.\n\n After creating the environment, we overwrite our name\n (DefaultEnvironment) with the _fetch_DefaultEnvironment() function,\n which more efficiently returns the initialized default construction\n environment wi...
Please provide a description of the function:def copy_func(dest, src, symlinks=True): dest = str(dest) src = str(src) SCons.Node.FS.invalidate_node_memos(dest) if SCons.Util.is_List(src) and os.path.isdir(dest): for file in src: shutil.copy2(file, dest) return 0 el...
[ "\n If symlinks (is true), then a symbolic link will be\n shallow copied and recreated as a symbolic link; otherwise, copying\n a symbolic link will be equivalent to copying the symbolic link's\n final target regardless of symbolic link depth.\n " ]
Please provide a description of the function:def _concat(prefix, list, suffix, env, f=lambda x: x, target=None, source=None): if not list: return list l = f(SCons.PathList.PathList(list).subst_path(env, target, source)) if l is not None: list = l return _concat_ixes(prefix, list, ...
[ "\n Creates a new list from 'list' by first interpolating each element\n in the list using the 'env' dictionary and then calling f on the\n list, and finally calling _concat_ixes to concatenate 'prefix' and\n 'suffix' onto each element of the list.\n " ]
Please provide a description of the function:def _concat_ixes(prefix, list, suffix, env): result = [] # ensure that prefix and suffix are strings prefix = str(env.subst(prefix, SCons.Subst.SUBST_RAW)) suffix = str(env.subst(suffix, SCons.Subst.SUBST_RAW)) for x in list: if isinstance...
[ "\n Creates a new list from 'list' by concatenating the 'prefix' and\n 'suffix' arguments onto each element of the list. A trailing space\n on 'prefix' or leading space on 'suffix' will cause them to be put\n into separate list elements rather than being concatenated.\n " ]
Please provide a description of the function:def _stripixes(prefix, itms, suffix, stripprefixes, stripsuffixes, env, c=None): if not itms: return itms if not callable(c): env_c = env['_concat'] if env_c != _concat and callable(env_c): # There's a custom _concat() metho...
[ "\n This is a wrapper around _concat()/_concat_ixes() that checks for\n the existence of prefixes or suffixes on list items and strips them\n where it finds them. This is used by tools (like the GNU linker)\n that need to turn something like 'libfoo.a' into '-lfoo'.\n " ]
Please provide a description of the function:def processDefines(defs): if SCons.Util.is_List(defs): l = [] for d in defs: if d is None: continue elif SCons.Util.is_List(d) or isinstance(d, tuple): if len(d) >= 2: l.appe...
[ "process defines, resolving strings, lists, dictionaries, into a list of\n strings\n " ]
Please provide a description of the function:def _defines(prefix, defs, suffix, env, c=_concat_ixes): return c(prefix, env.subst_path(processDefines(defs)), suffix, env)
[ "A wrapper around _concat_ixes that turns a list or string\n into a list of C preprocessor command-line definitions.\n " ]
Please provide a description of the function:def run(self, sensor_graph, model): # We can only eliminate a node if the following checks are true # 1. It has no other nodes connected to it # 2. Its stream is not an output of the entire sensor graph # 3. Its stream is autogenerat...
[ "Run this optimization pass on the sensor graph\n\n If necessary, information on the device model being targeted\n can be found in the associated model argument.\n\n Args:\n sensor_graph (SensorGraph): The sensor graph to optimize\n model (DeviceModel): The device model we...
Please provide a description of the function:def Scanner(function, *args, **kw): if SCons.Util.is_Dict(function): return Selector(function, *args, **kw) else: return Base(function, *args, **kw)
[ "\n Public interface factory function for creating different types\n of Scanners based on the different types of \"functions\" that may\n be supplied.\n\n TODO: Deprecate this some day. We've moved the functionality\n inside the Base class and really don't need this factory function\n any more. ...
Please provide a description of the function:def ReportLength(cls, header): parsed_header = cls._parse_header(header) auth_size = cls._AUTH_BLOCK_LENGTHS.get(parsed_header.auth_type) if auth_size is None: raise DataError("Unknown auth block size in BroadcastReport") ...
[ "Given a header of HeaderLength bytes, calculate the size of this report.\n\n Returns:\n int: The total length of the report including the header that we are passed.\n " ]
Please provide a description of the function:def FromReadings(cls, uuid, readings, sent_timestamp=0): header = struct.pack("<BBHLLL", cls.ReportType, 0, len(readings)*16, uuid, sent_timestamp, 0) packed_readings = bytearray() for reading in readings: packed_reading = stru...
[ "Generate a broadcast report from a list of readings and a uuid." ]
Please provide a description of the function:def decode(self): parsed_header = self._parse_header(self.raw_report[:self._HEADER_LENGTH]) auth_size = self._AUTH_BLOCK_LENGTHS.get(parsed_header.auth_type) assert auth_size is not None assert parsed_header.reading_length % 16 == 0...
[ "Decode this report into a list of visible readings." ]
Please provide a description of the function:def _initialize_system_sync(self): connected_devices = self.bable.list_connected_devices() for device in connected_devices: self.disconnect_sync(device.connection_handle) self.stop_scan() self.set_advertising(False) ...
[ "Initialize the device adapter by removing all active connections and resetting scan and advertising to have\n a clean starting state." ]
Please provide a description of the function:def start(self, device): super(NativeBLEVirtualInterface, self).start(device) self.set_advertising(True)
[ "Start serving access to this VirtualIOTileDevice\n\n Args:\n device (VirtualIOTileDevice): The device we will be providing access to\n " ]
Please provide a description of the function:def register_gatt_table(self): services = [BLEService, TileBusService] characteristics = [ NameChar, AppearanceChar, ReceiveHeaderChar, ReceivePayloadChar, SendHeaderChar, SendP...
[ "Register the GATT table into baBLE." ]
Please provide a description of the function:def set_advertising(self, enabled): if enabled: self.bable.set_advertising( enabled=True, uuids=[TileBusService.uuid], name="V_IOTile ", company_id=ArchManuID, advert...
[ "Toggle advertising." ]
Please provide a description of the function:def _advertisement(self): # Flags are # bit 0: whether we have pending data # bit 1: whether we are in a low voltage state # bit 2: whether another user is connected # bit 3: whether we support robust reports # bit 4: ...
[ "Create advertisement data." ]
Please provide a description of the function:def _scan_response(self): voltage = struct.pack("<H", int(self.voltage*256)) reading = struct.pack("<HLLL", 0xFFFF, 0, 0, 0) response = voltage + reading return response
[ "Create scan response data." ]
Please provide a description of the function:def stop_sync(self): # Disconnect connected device if self.connected: self.disconnect_sync(self._connection_handle) # Disable advertising self.set_advertising(False) # Stop the baBLE interface self.bable....
[ "Safely stop this BLED112 instance without leaving it in a weird state." ]
Please provide a description of the function:def disconnect_sync(self, connection_handle): self.bable.disconnect(connection_handle=connection_handle, sync=True)
[ "Synchronously disconnect from whoever has connected to us\n\n Args:\n connection_handle (int): The handle of the connection we wish to disconnect.\n " ]
Please provide a description of the function:def _on_connected(self, device): self._logger.debug("Device connected event: {}".format(device)) self.connected = True self._connection_handle = device['connection_handle'] self.device.connected = True self._audit('ClientConn...
[ "Callback function called when a connected event has been received.\n It is executed in the baBLE working thread: should not be blocking.\n\n Args:\n device (dict): Information about the newly connected device\n " ]
Please provide a description of the function:def _on_disconnected(self, device): self._logger.debug("Device disconnected event: {}".format(device)) if self.streaming: self.device.close_streaming_interface() self.streaming = False if self.tracing: s...
[ "Callback function called when a disconnected event has been received.\n This resets any open interfaces on the virtual device and clears any\n in progress traces and streams.\n It is executed in the baBLE working thread: should not be blocking.\n\n Args:\n device (dict): Info...
Please provide a description of the function:def _on_write_request(self, request): if request['connection_handle'] != self._connection_handle: return False attribute_handle = request['attribute_handle'] # If write to configure notification config_handles = [ ...
[ "Callback function called when a write request has been received.\n It is executed in the baBLE working thread: should not be blocking.\n\n Args:\n request (dict): Information about the request\n - connection_handle (int): The connection handle that sent the request\n ...
Please provide a description of the function:def _call_rpc(self, header): length, _, cmd, feature, address = struct.unpack("<BBBBB", bytes(header)) rpc_id = (feature << 8) | cmd payload = self.rpc_payload[:length] status = (1 << 6) try: response = self.dev...
[ "Call an RPC given a header and possibly a previously sent payload\n It is executed in the baBLE working thread: should not be blocking.\n\n Args:\n header (bytearray): The RPC header we should call\n " ]
Please provide a description of the function:def _send_notification(self, handle, payload): self.bable.notify( connection_handle=self._connection_handle, attribute_handle=handle, value=payload )
[ "Send a notification over BLE\n It is executed in the baBLE working thread: should not be blocking.\n\n Args:\n handle (int): The handle to notify on\n payload (bytearray): The value to notify\n " ]
Please provide a description of the function:def _send_rpc_response(self, *packets): if len(packets) == 0: return handle, payload = packets[0] try: self._send_notification(handle, payload) except bable_interface.BaBLEException as err: if er...
[ "Send an RPC response.\n It is executed in the baBLE working thread: should not be blocking.\n\n The RPC response is notified in one or two packets depending on whether or not\n response data is included. If there is a temporary error sending one of the packets\n it is retried automatica...
Please provide a description of the function:def _stream_data(self, chunk=None): # If we failed to transmit a chunk, we will be requeued with an argument self._stream_sm_running = True if chunk is None: chunk = self._next_streaming_chunk(20) if chunk is None or le...
[ "Stream reports to the ble client in 20 byte chunks\n\n Args:\n chunk (bytearray): A chunk that should be sent instead of requesting a\n new chunk from the pending reports.\n " ]
Please provide a description of the function:def _send_trace(self, chunk=None): self._trace_sm_running = True # If we failed to transmit a chunk, we will be requeued with an argument if chunk is None: chunk = self._next_tracing_chunk(20) if chunk is None or len(chu...
[ "Stream tracing data to the ble client in 20 byte chunks\n\n Args:\n chunk (bytearray): A chunk that should be sent instead of requesting a\n new chunk from the pending reports.\n " ]
Please provide a description of the function:def process(self): super(NativeBLEVirtualInterface, self).process() if (not self._stream_sm_running) and (not self.reports.empty()): self._stream_data() if (not self._trace_sm_running) and (not self.traces.empty()): ...
[ "Periodic nonblocking processes" ]
Please provide a description of the function:async def _populate_name_map(self): services = await self.sync_services() with self._state_lock: self.services = services for i, name in enumerate(self.services.keys()): self._name_map[i] = name
[ "Populate the name map of services as reported by the supervisor" ]
Please provide a description of the function:def local_service(self, name_or_id): if not self._loop.inside_loop(): self._state_lock.acquire() try: if isinstance(name_or_id, int): if name_or_id not in self._name_map: raise ArgumentErr...
[ "Get the locally synced information for a service.\n\n This method is safe to call outside of the background event loop\n without any race condition. Internally it uses a thread-safe mutex to\n protect the local copies of supervisor data and ensure that it cannot\n change while this met...
Please provide a description of the function:def local_services(self): if not self._loop.inside_loop(): self._state_lock.acquire() try: return sorted([(index, name) for index, name in self._name_map.items()], key=lambda element: element[0]) finally: ...
[ "Get a list of id, name pairs for all of the known synced services.\n\n This method is safe to call outside of the background event loop\n without any race condition. Internally it uses a thread-safe mutex to\n protect the local copies of supervisor data and ensure that it cannot\n chan...
Please provide a description of the function:async def sync_services(self): services = {} servs = await self.list_services() for i, serv in enumerate(servs): info = await self.service_info(serv) status = await self.service_status(serv) messages = aw...
[ "Poll the current state of all services.\n\n Returns:\n dict: A dictionary mapping service name to service status\n " ]
Please provide a description of the function:async def get_messages(self, name): resp = await self.send_command(OPERATIONS.CMD_QUERY_MESSAGES, {'name': name}, MESSAGES.QueryMessagesResponse, timeout=5.0) return [states.ServiceMessage.FromDictionary(x) fo...
[ "Get stored messages for a service.\n\n Args:\n name (string): The name of the service to get messages from.\n\n Returns:\n list(ServiceMessage): A list of the messages stored for this service\n " ]
Please provide a description of the function:async def get_headline(self, name): resp = await self.send_command(OPERATIONS.CMD_QUERY_HEADLINE, {'name': name}, MESSAGES.QueryHeadlineResponse, timeout=5.0) if resp is not None: resp = states.Ser...
[ "Get stored messages for a service.\n\n Args:\n name (string): The name of the service to get messages from.\n\n Returns:\n ServiceMessage: the headline or None if no headline has been set\n " ]
Please provide a description of the function:async def service_info(self, name): return await self.send_command(OPERATIONS.CMD_QUERY_INFO, {'name': name}, MESSAGES.QueryInfoResponse, timeout=5.0)
[ "Pull descriptive info of a service by name.\n\n Information returned includes the service's user friendly\n name and whether it was preregistered or added dynamically.\n\n Returns:\n dict: A dictionary of service information with the following keys\n set:\n ...
Please provide a description of the function:async def send_heartbeat(self, name): await self.send_command(OPERATIONS.CMD_HEARTBEAT, {'name': name}, MESSAGES.HeartbeatResponse, timeout=5.0)
[ "Send a heartbeat for a service.\n\n Args:\n name (string): The name of the service to send a heartbeat for\n " ]
Please provide a description of the function:async def update_state(self, name, state): await self.send_command(OPERATIONS.CMD_UPDATE_STATE, {'name': name, 'new_status': state}, MESSAGES.UpdateStateResponse, timeout=5.0)
[ "Update the state for a service.\n\n Args:\n name (string): The name of the service\n state (int): The new state of the service\n " ]
Please provide a description of the function:def post_headline(self, name, level, message): self.post_command(OPERATIONS.CMD_SET_HEADLINE, {'name': name, 'level': level, 'message': message})
[ "Asynchronously update the sticky headline for a service.\n\n Args:\n name (string): The name of the service\n level (int): A message level in states.*_LEVEL\n message (string): The user facing error message that will be stored\n for the service and can be quer...
Please provide a description of the function:def post_state(self, name, state): self.post_command(OPERATIONS.CMD_UPDATE_STATE, {'name': name, 'new_status': state})
[ "Asynchronously try to update the state for a service.\n\n If the update fails, nothing is reported because we don't wait for a\n response from the server. This function will return immmediately and\n not block.\n\n Args:\n name (string): The name of the service\n ...
Please provide a description of the function:def post_error(self, name, message): self.post_command(OPERATIONS.CMD_POST_MESSAGE, _create_message(name, states.ERROR_LEVEL, message))
[ "Asynchronously post a user facing error message about a service.\n\n Args:\n name (string): The name of the service\n message (string): The user facing error message that will be stored\n for the service and can be queried later.\n " ]
Please provide a description of the function:def post_warning(self, name, message): self.post_command(OPERATIONS.CMD_POST_MESSAGE, _create_message(name, states.WARNING_LEVEL, message))
[ "Asynchronously post a user facing warning message about a service.\n\n Args:\n name (string): The name of the service\n message (string): The user facing warning message that will be stored\n for the service and can be queried later.\n " ]
Please provide a description of the function:def post_info(self, name, message): self.post_command(OPERATIONS.CMD_POST_MESSAGE, _create_message(name, states.INFO_LEVEL, message))
[ "Asynchronously post a user facing info message about a service.\n\n Args:\n name (string): The name of the service\n message (string): The user facing info message that will be stored\n for the service and can be queried later.\n " ]
Please provide a description of the function:async def service_status(self, name): return await self.send_command(OPERATIONS.CMD_QUERY_STATUS, {'name': name}, MESSAGES.QueryStatusResponse, timeout=5.0)
[ "Pull the current status of a service by name.\n\n Returns:\n dict: A dictionary of service status\n " ]
Please provide a description of the function:async def send_rpc(self, name, rpc_id, payload, timeout=1.0): msg = dict(name=name, rpc_id=rpc_id, payload=payload, timeout=timeout) try: resp = await self.send_command(OPERATIONS.CMD_SEND_RPC, msg, ...
[ "Send an RPC to a service and synchronously wait for the response.\n\n Args:\n name (str): The short name of the service to send the RPC to\n rpc_id (int): The id of the RPC we want to call\n payload (bytes): Any binary arguments that we want to send\n timeout (flo...
Please provide a description of the function:async def register_service(self, short_name, long_name, allow_duplicate=True): try: await self.send_command(OPERATIONS.CMD_REGISTER_SERVICE, dict(name=short_name, long_name=long_name), MESSAGES.RegisterService...
[ "Register a new service with the service manager.\n\n Args:\n short_name (string): A unique short name for this service that functions\n as an id\n long_name (string): A user facing name for this service\n allow_duplicate (boolean): Don't throw an error if this...
Please provide a description of the function:async def register_agent(self, short_name): await self.send_command(OPERATIONS.CMD_SET_AGENT, {'name': short_name}, MESSAGES.SetAgentResponse)
[ "Register to act as the RPC agent for this service.\n\n After this call succeeds, all requests to send RPCs to this service\n will be routed through this agent.\n\n Args:\n short_name (str): A unique short name for this service that functions\n as an id\n " ]
Please provide a description of the function:async def _on_status_change(self, update): info = update['payload'] new_number = info['new_status'] name = update['service'] if name not in self.services: return with self._state_lock: is_changed = s...
[ "Update a service that has its status updated." ]
Please provide a description of the function:async def _on_service_added(self, update): info = update['payload'] name = info['short_name'] if name in self.services: return with self._state_lock: new_id = len(self.services) serv = states.Ser...
[ "Add a new service." ]
Please provide a description of the function:async def _on_heartbeat(self, update): name = update['service'] if name not in self.services: return with self._state_lock: self.services[name].heartbeat()
[ "Receive a new heartbeat for a service." ]
Please provide a description of the function:async def _on_message(self, update): name = update['service'] message_obj = update['payload'] if name not in self.services: return with self._state_lock: self.services[name].post_message(message_obj['level']...
[ "Receive a message from a service." ]
Please provide a description of the function:async def _on_headline(self, update): name = update['service'] message_obj = update['payload'] new_headline = False if name not in self.services: return with self._state_lock: self.services[name].set...
[ "Receive a headline from a service." ]
Please provide a description of the function:async def _on_rpc_command(self, event): payload = event['payload'] rpc_id = payload['rpc_id'] tag = payload['response_uuid'] args = payload['payload'] result = 'success' response = b'' if self._rpc_dispatche...
[ "Received an RPC command that we should execute." ]
Please provide a description of the function:def get_messages(self, name): return self._loop.run_coroutine(self._client.get_messages(name))
[ "Get stored messages for a service.\n\n Args:\n name (string): The name of the service to get messages from.\n\n Returns:\n list(ServiceMessage): A list of the messages stored for this service\n " ]
Please provide a description of the function:def get_headline(self, name): return self._loop.run_coroutine(self._client.get_headline(name))
[ "Get stored messages for a service.\n\n Args:\n name (string): The name of the service to get messages from.\n\n Returns:\n ServiceMessage: the headline or None if no headline has been set\n " ]
Please provide a description of the function:def send_heartbeat(self, name): return self._loop.run_coroutine(self._client.send_heartbeat(name))
[ "Send a heartbeat for a service.\n\n Args:\n name (string): The name of the service to send a heartbeat for\n " ]
Please provide a description of the function:def service_info(self, name): return self._loop.run_coroutine(self._client.service_info(name))
[ "Pull descriptive info of a service by name.\n\n Information returned includes the service's user friendly\n name and whether it was preregistered or added dynamically.\n\n Returns:\n dict: A dictionary of service information with the following keys\n set:\n ...
Please provide a description of the function:def update_state(self, name, state): self._loop.run_coroutine(self._client.update_state(name, state))
[ "Update the state for a service.\n\n Args:\n name (string): The name of the service\n state (int): The new state of the service\n " ]
Please provide a description of the function:def post_headline(self, name, level, message): self._client.post_headline(name, level, message)
[ "Asynchronously update the sticky headline for a service.\n\n Args:\n name (string): The name of the service\n level (int): A message level in states.*_LEVEL\n message (string): The user facing error message that will be stored\n for the service and can be quer...
Please provide a description of the function:def service_status(self, name): return self._loop.run_coroutine(self._client.service_status(name))
[ "Pull the current status of a service by name.\n\n Returns:\n dict: A dictionary of service status\n " ]