Code
stringlengths
103
85.9k
Summary
listlengths
0
94
Please provide a description of the function:def send_rpc(self, name, rpc_id, payload, timeout=1.0): return self._loop.run_coroutine(self._client.send_rpc(name, rpc_id, payload, timeout))
[ "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:def register_service(self, short_name, long_name, allow_duplicate=True): self._loop.run_coroutine(self._client.register_service(short_name, long_name, allow_duplicate))
[ "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:def register_agent(self, short_name): self._loop.run_coroutine(self._client.register_agent(short_name))
[ "Register to act as the RPC agent for this service.\n\n After this cal succeeds, all requests to send RPCs to this service will be routed\n 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:def execute_before(self, sensor_graph, scope_stack): parent = scope_stack[-1] new_scope = TriggerScope(sensor_graph, scope_stack, parent.clock(self.interval, basis=self.basis)) scope_stack.append(new_scope)
[ "Execute statement before children are executed.\n\n Args:\n sensor_graph (SensorGraph): The sensor graph that we are building or\n modifying\n scope_stack (list(Scope)): A stack of nested scopes that may influence\n how this statement allocates clocks or o...
Please provide a description of the function:def execute(self, sensor_graph, scope_stack): if self.subtract_stream.stream_type != DataStream.ConstantType: raise SensorGraphSemanticError("You can only subtract a constant value currently", stream=self.subtract_stream) parent = scope...
[ "Execute this statement on the sensor_graph given the current scope tree.\n\n This adds a single node to the sensor graph with subtract as the function\n so that the current scope's trigger stream has the subtract_stream's value\n subtracted from it.\n\n Args:\n sensor_graph (...
Please provide a description of the function:def _decode_datetime(obj): if '__datetime__' in obj: obj = datetime.datetime.strptime(obj['as_str'].decode(), "%Y%m%dT%H:%M:%S.%f") return obj
[ "Decode a msgpack'ed datetime." ]
Please provide a description of the function:def _encode_datetime(obj): if isinstance(obj, datetime.datetime): obj = {'__datetime__': True, 'as_str': obj.strftime("%Y%m%dT%H:%M:%S.%f").encode()} return obj
[ "Encode a msgpck'ed datetime." ]
Please provide a description of the function:def _versioned_lib_suffix(env, suffix, version): Verbose = False if Verbose: print("_versioned_lib_suffix: suffix= ", suffix) print("_versioned_lib_suffix: version= ", version) cygversion = re.sub('\.', '-', version) if not suffix.startsw...
[ "Generate versioned shared library suffix from a unversioned one.\n If suffix='.dll', and version='0.1.2', then it returns '-0-1-2.dll'" ]
Please provide a description of the function:def _versioned_implib_symlinks(env, libnode, version, prefix, suffix, **kw): Verbose = False if Verbose: print("_versioned_implib_symlinks: libnode=%r" % libnode.get_path()) print("_versioned_implib_symlinks: version=%r" % version) try: lib...
[ "Generate link names that should be created for a versioned shared library.\n Returns a list in the form [ (link, linktarget), ... ]\n " ]
Please provide a description of the function:def generate(env): gnulink.generate(env) env['LINKFLAGS'] = SCons.Util.CLVar('-Wl,-no-undefined') env['SHLINKCOM'] = shlib_action env['LDMODULECOM'] = ldmod_action env.Append(SHLIBEMITTER = [shlib_emitter]) env.Append(LDMODULEEMITTER = [ldmod...
[ "Add Builders and construction variables for cyglink to an Environment." ]
Please provide a description of the function:def generate(env): path, _cc, version = get_xlc(env) if path and _cc: _cc = os.path.join(path, _cc) if 'CC' not in env: env['CC'] = _cc cc.generate(env) if version: env['CCVERSION'] = version
[ "Add Builders and construction variables for xlc / Visual Age\n suite to an Environment." ]
Please provide a description of the function:def dispatch(self, message): for validator, callback in self.validators: if not validator.matches(message): continue callback(message) return raise ArgumentError("No handler was registered for me...
[ "Dispatch a message to a callback based on its schema.\n\n Args:\n message (dict): The message to dispatch\n " ]
Please provide a description of the function:def build_parser(): parser = argparse.ArgumentParser(description=DESCRIPTION, formatter_class=argparse.RawDescriptionHelpFormatter) parser.add_argument('firmware_image', nargs="?", help="The firmware image that you wish to load into the emulator") parser.a...
[ "Create command line argument parser." ]
Please provide a description of the function:def main(raw_args=None): if raw_args is None: raw_args = sys.argv[1:] parser = build_parser() args = parser.parse_args(raw_args) if args.firmware_image is None and args.gdb is None: print("You must specify either a firmware image or at...
[ "Run the iotile-emulate script.\n\n Args:\n raw_args (list): Optional list of commmand line arguments. If not\n passed these are pulled from sys.argv.\n " ]
Please provide a description of the function:def _detect(env): QTDIR = None if not QTDIR: QTDIR = env.get('QTDIR',None) if not QTDIR: QTDIR = os.environ.get('QTDIR',None) if not QTDIR: moc = env.WhereIs('moc') if moc: QTDIR = os.path.dirname(os.path.dirna...
[ "Not really safe, but fast method to detect the QT library" ]
Please provide a description of the function:def generate(env): CLVar = SCons.Util.CLVar Action = SCons.Action.Action Builder = SCons.Builder.Builder env.SetDefault(QTDIR = _detect(env), QT_BINPATH = os.path.join('$QTDIR', 'bin'), QT_CPPPATH = os.path.join('$...
[ "Add Builders and construction variables for qt to an Environment." ]
Please provide a description of the function:def CPP_to_Python(s): s = CPP_to_Python_Ops_Expression.sub(CPP_to_Python_Ops_Sub, s) for expr, repl in CPP_to_Python_Eval_List: s = expr.sub(repl, s) return s
[ "\n Converts a C pre-processor expression into an equivalent\n Python expression that can be evaluated.\n " ]
Please provide a description of the function:def tupleize(self, contents): global CPP_Expression, Table contents = line_continuations.sub('', contents) cpp_tuples = CPP_Expression.findall(contents) return [(m[0],) + Table[m[0]].match(m[1]).groups() for m in cpp_tuples]
[ "\n Turns the contents of a file into a list of easily-processed\n tuples describing the CPP lines in the file.\n\n The first element of each tuple is the line's preprocessor\n directive (#if, #include, #define, etc., minus the initial '#').\n The remaining elements are specific t...
Please provide a description of the function:def process_contents(self, contents, fname=None): self.stack = [] self.dispatch_table = self.default_table.copy() self.current_file = fname self.tuples = self.tupleize(contents) self.initialize_result(fname) while sel...
[ "\n Pre-processes a file contents.\n\n This is the main internal entry point.\n " ]
Please provide a description of the function:def save(self): self.stack.append(self.dispatch_table) self.dispatch_table = self.default_table.copy()
[ "\n Pushes the current dispatch table on the stack and re-initializes\n the current dispatch table to the default.\n " ]
Please provide a description of the function:def eval_expression(self, t): t = CPP_to_Python(' '.join(t[1:])) try: return eval(t, self.cpp_namespace) except (NameError, TypeError): return 0
[ "\n Evaluates a C preprocessor expression.\n\n This is done by converting it to a Python equivalent and\n eval()ing it in the C preprocessor namespace we use to\n track #define values.\n " ]
Please provide a description of the function:def find_include_file(self, t): fname = t[2] for d in self.searchpath[t[1]]: if d == os.curdir: f = fname else: f = os.path.join(d, fname) if os.path.isfile(f): retur...
[ "\n Finds the #include file for a given preprocessor tuple.\n " ]
Please provide a description of the function:def start_handling_includes(self, t=None): d = self.dispatch_table p = self.stack[-1] if self.stack else self.default_table for k in ('import', 'include', 'include_next'): d[k] = p[k]
[ "\n Causes the PreProcessor object to start processing #import,\n #include and #include_next lines.\n\n This method will be called when a #if, #ifdef, #ifndef or #elif\n evaluates True, or when we reach the #else in a #if, #ifdef,\n #ifndef or #elif block where a condition already...
Please provide a description of the function:def stop_handling_includes(self, t=None): d = self.dispatch_table d['import'] = self.do_nothing d['include'] = self.do_nothing d['include_next'] = self.do_nothing
[ "\n Causes the PreProcessor object to stop processing #import,\n #include and #include_next lines.\n\n This method will be called when a #if, #ifdef, #ifndef or #elif\n evaluates False, or when we reach the #else in a #if, #ifdef,\n #ifndef or #elif block where a condition already...
Please provide a description of the function:def _do_if_else_condition(self, condition): self.save() d = self.dispatch_table if condition: self.start_handling_includes() d['elif'] = self.stop_handling_includes d['else'] = self.stop_handling_includes ...
[ "\n Common logic for evaluating the conditions on #if, #ifdef and\n #ifndef lines.\n " ]
Please provide a description of the function:def do_elif(self, t): d = self.dispatch_table if self.eval_expression(t): self.start_handling_includes() d['elif'] = self.stop_handling_includes d['else'] = self.stop_handling_includes
[ "\n Default handling of a #elif line.\n " ]
Please provide a description of the function:def do_define(self, t): _, name, args, expansion = t try: expansion = int(expansion) except (TypeError, ValueError): pass if args: evaluator = FunctionEvaluator(name, args[1:-1], expansion) ...
[ "\n Default handling of a #define line.\n " ]
Please provide a description of the function:def do_include(self, t): t = self.resolve_include(t) include_file = self.find_include_file(t) if include_file: #print("include_file =", include_file) self.result.append(include_file) contents = self.read_fi...
[ "\n Default handling of a #include line.\n " ]
Please provide a description of the function:def resolve_include(self, t): s = t[1] while not s[0] in '<"': #print("s =", s) try: s = self.cpp_namespace[s] except KeyError: m = function_name.search(s) s = self....
[ "Resolve a tuple-ized #include line.\n\n This handles recursive expansion of values without \"\" or <>\n surrounding the name until an initial \" or < is found, to handle\n\n #include FILE\n\n where FILE is a #define somewhere else." ]
Please provide a description of the function:def emit_rmic_classes(target, source, env): class_suffix = env.get('JAVACLASSSUFFIX', '.class') classdir = env.get('JAVACLASSDIR') if not classdir: try: s = source[0] except IndexError: classdir = '.' else: ...
[ "Create and return lists of Java RMI stub and skeleton\n class files to be created from a set of class files.\n " ]
Please provide a description of the function:def generate(env): env['BUILDERS']['RMIC'] = RMICBuilder env['RMIC'] = 'rmic' env['RMICFLAGS'] = SCons.Util.CLVar('') env['RMICCOM'] = '$RMIC $RMICFLAGS -d ${TARGET.attributes.java_lookupdir} -classpath ${SOURCE.attributes.java_...
[ "Add Builders and construction variables for rmic to an Environment." ]
Please provide a description of the function:def _set_scan_parameters(self, interval=2100, window=2100, active=False): active_num = 0 if bool(active): active_num = 1 interval_num = int(interval*1000/625) window_num = int(window*1000/625) payload = struct.p...
[ "\n Set the scan interval and window in units of ms and set whether active scanning is performed\n " ]
Please provide a description of the function:def _query_systemstate(self): def status_filter_func(event): if event.command_class == 3 and event.command == 0: return True return False try: response = self._send_command(0, 6, []) ...
[ "Query the maximum number of connections supported by this adapter\n " ]
Please provide a description of the function:def _start_scan(self, active): success, retval = self._set_scan_parameters(active=active) if not success: return success, retval try: response = self._send_command(6, 2, [2]) if response.payload[0] != 0: ...
[ "Begin scanning forever\n " ]
Please provide a description of the function:def _stop_scan(self): try: response = self._send_command(6, 4, []) if response.payload[0] != 0: # Error code 129 means we just were not currently scanning if response.payload[0] != 129: ...
[ "Stop scanning for BLE devices\n " ]
Please provide a description of the function:def _probe_services(self, handle): code = 0x2800 def event_filter_func(event): if (event.command_class == 4 and event.command == 2): event_handle, = unpack("B", event.payload[0:1]) return event_handle == ...
[ "Probe for all primary services and characteristics in those services\n\n Args:\n handle (int): the connection handle to probe\n " ]
Please provide a description of the function:def _probe_characteristics(self, conn, services, timeout=5.0): for service in services.values(): success, result = self._enumerate_handles(conn, service['start_handle'], service['end_handle']...
[ "Probe gatt services for all associated characteristics in a BLE device\n\n Args:\n conn (int): the connection handle to probe\n services (dict): a dictionary of services produced by probe_services()\n timeout (float): the maximum number of seconds to spend in any single task...
Please provide a description of the function:def _enable_rpcs(self, conn, services, timeout=1.0): #FIXME: Check for characteristic existence in a try/catch and return failure if not found success, result = self._set_notification(conn, services[TileBusService]['characteristics'][TileBusReceive...
[ "Prepare this device to receive RPCs\n " ]
Please provide a description of the function:def _disable_rpcs(self, conn, services, timeout=1.0): success, result = self._set_notification(conn, services[TileBusService]['characteristics'][TileBusReceiveHeaderCharacteristic], False, timeout) if not success: return success, result ...
[ "Prevent this device from receiving more RPCs\n " ]
Please provide a description of the function:def _write_handle(self, conn, handle, ack, value, timeout=1.0): conn_handle = conn char_handle = handle def write_handle_acked(event): if event.command_class == 4 and event.command == 1: conn, _, char = unpack("<...
[ "Write to a BLE device characteristic by its handle\n\n Args:\n conn (int): The connection handle for the device we should read from\n handle (int): The characteristics handle we should read\n ack (bool): Should this be an acknowledges write or unacknowledged\n tim...
Please provide a description of the function:def _set_advertising_data(self, packet_type, data): payload = struct.pack("<BB%ss" % (len(data)), packet_type, len(data), bytes(data)) response = self._send_command(6, 9, payload) result, = unpack("<H", response.payload) if result !...
[ "Set the advertising data for advertisements sent out by this bled112\n\n Args:\n packet_type (int): 0 for advertisement, 1 for scan response\n data (bytearray): the data to set\n " ]
Please provide a description of the function:def _set_mode(self, discover_mode, connect_mode): payload = struct.pack("<BB", discover_mode, connect_mode) response = self._send_command(6, 1, payload) result, = unpack("<H", response.payload) if result != 0: return Fal...
[ "Set the mode of the BLED112, used to enable and disable advertising\n\n To enable advertising, use 4, 2.\n To disable advertising use 0, 0.\n\n Args:\n discover_mode (int): The discoverability mode, 0 for off, 4 for on (user data)\n connect_mode (int): The connectability ...
Please provide a description of the function:def _send_notification(self, handle, value): value_len = len(value) value = bytes(value) payload = struct.pack("<BHB%ds" % value_len, 0xFF, handle, value_len, value) response = self._send_command(2, 5, payload) result, = un...
[ "Send a notification to all connected clients on a characteristic\n\n Args:\n handle (int): The handle we wish to notify on\n value (bytearray): The value we wish to send\n " ]
Please provide a description of the function:def _set_notification(self, conn, char, enabled, timeout=1.0): if 'client_configuration' not in char: return False, {'reason': 'Cannot enable notification without a client configuration attribute for characteristic'} props = char['prope...
[ "Enable/disable notifications on a GATT characteristic\n\n Args:\n conn (int): The connection handle for the device we should interact with\n char (dict): The characteristic we should modify\n enabled (bool): Should we enable or disable notifications\n timeout (flo...
Please provide a description of the function:def _connect(self, address): latency = 0 conn_interval_min = 6 conn_interval_max = 100 timeout = 1.0 try: #Allow passing either a binary address or a hex string if isinstance(address, str) and len(add...
[ "Connect to a device given its uuid\n " ]
Please provide a description of the function:def _disconnect(self, handle): payload = struct.pack('<B', handle) response = self._send_command(3, 0, payload) conn_handle, result = unpack("<BH", response.payload) if result != 0: self._logger.info("Disconnection faile...
[ "Disconnect from a device that we have previously connected to\n " ]
Please provide a description of the function:def _send_command(self, cmd_class, command, payload, timeout=3.0): if len(payload) > 60: return ValueError("Attempting to send a BGAPI packet with length > 60 is not allowed", actual_length=len(payload), command=command, command_class=cmd_class)...
[ "\n Send a BGAPI packet to the dongle and return the response\n " ]
Please provide a description of the function:def _receive_packet(self, timeout=3.0): while True: response_data = self._stream.read_packet(timeout=timeout) response = BGAPIPacket(is_event=(response_data[0] == 0x80), command_class=response_data[2], command=response_data[3], paylo...
[ "\n Receive a response packet to a command\n " ]
Please provide a description of the function:def _wait_process_events(self, total_time, return_filter, end_filter): acc = [] delta = 0.01 start_time = time.time() end_time = start_time + total_time while time.time() < end_time: events = self._process_event...
[ "Synchronously process events until a specific event is found or we timeout\n\n Args:\n total_time (float): The aproximate maximum number of seconds we should wait for the end event\n return_filter (callable): A function that returns True for events we should return and not process\n ...
Please provide a description of the function:def async_rpc(address, rpc_id, arg_format, resp_format=None): if rpc_id < 0 or rpc_id > 0xFFFF: raise RPCInvalidIDError("Invalid RPC ID: {}".format(rpc_id)) def _rpc_wrapper(func): async def _rpc_executor(self, payload): try: ...
[ "Decorator to denote that a function implements an RPC with the given ID and address.\n\n The underlying function should be a member function that will take\n individual parameters after the RPC payload has been decoded according\n to arg_format.\n\n Arguments to the function are decoded from the 20 byt...
Please provide a description of the function:def connect(self, client_id): if self.client is not None: raise InternalError("Connect called on an alreaded connected MQTT client") client = AWSIoTPythonSDK.MQTTLib.AWSIoTMQTTClient(client_id, useWebsocket=self.websockets) if ...
[ "Connect to AWS IOT with the given client_id\n\n Args:\n client_id (string): The client ID passed to the MQTT message broker\n " ]
Please provide a description of the function:def disconnect(self): if self.client is None: return try: self.client.disconnect() except operationError as exc: raise InternalError("Could not disconnect from AWS IOT", message=exc.message)
[ "Disconnect from AWS IOT message broker\n " ]
Please provide a description of the function:def publish(self, topic, message): seq = self.sequencer.next_id(topic) packet = { 'sequence': seq, 'message': message } # Need to encode bytes types for json.dumps if 'key' in packet['message']: ...
[ "Publish a json message to a topic with a type and a sequence number\n\n The actual message will be published as a JSON object:\n {\n \"sequence\": <incrementing id>,\n \"message\": message\n }\n\n Args:\n topic (string): The MQTT topic to publish in\n ...
Please provide a description of the function:def subscribe(self, topic, callback, ordered=True): if '+' in topic or '#' in topic: regex = re.compile(topic.replace('+', '[^/]+').replace('#', '.*')) self.wildcard_queues.append((topic, regex, callback, ordered)) else: ...
[ "Subscribe to future messages in the given topic\n\n The contents of topic should be in the format created by self.publish with a\n sequence number of message type encoded as a json string.\n\n Wildcard topics containing + and # are allowed and\n\n Args:\n topic (string): The ...
Please provide a description of the function:def reset_sequence(self, topic): if topic in self.queues: self.queues[topic].reset()
[ "Reset the expected sequence number for a topic\n\n If the topic is unknown, this does nothing. This behaviour is\n useful when you have wildcard topics that only create queues\n once they receive the first message matching the topic.\n\n Args:\n topic (string): The topic to ...
Please provide a description of the function:def unsubscribe(self, topic): del self.queues[topic] try: self.client.unsubscribe(topic) except operationError as exc: raise InternalError("Could not unsubscribe from topic", topic=topic, message=exc.message)
[ "Unsubscribe from messages on a given topic\n\n Args:\n topic (string): The MQTT topic to unsubscribe from\n " ]
Please provide a description of the function:def _on_receive(self, client, userdata, message): topic = message.topic encoded = message.payload try: packet = json.loads(encoded) except ValueError: self._logger.warn("Could not decode json packet: %s", enc...
[ "Callback called whenever we receive a message on a subscribed topic\n\n Args:\n client (string): The client id of the client receiving the message\n userdata (string): Any user data set with the underlying MQTT client\n message (object): The mesage with a topic and payload.\...
Please provide a description of the function:def run(self, resources): hwman = resources['connection'] con = hwman.hwman.controller() test_interface = con.test_interface() try: test_interface.synchronize_clock() print('Time currently set at %s' % test_int...
[ "Sets the RTC timestamp to UTC.\n\n Args:\n resources (dict): A dictionary containing the required resources that\n we needed access to in order to perform this step.\n " ]
Please provide a description of the function:def add(self, command, *args): cmd = Command(command, args) self.commands.append(cmd)
[ "Add a command to this command file.\n\n Args:\n command (str): The command to add\n *args (str): The parameters to call the command with\n " ]
Please provide a description of the function:def save(self, outpath): with open(outpath, "w") as outfile: outfile.write(self.dump())
[ "Save this command file as an ascii file.\n\n Agrs:\n outpath (str): The output path to save.\n " ]
Please provide a description of the function:def dump(self): out = [] out.append(self.filetype) out.append("Format: {}".format(self.version)) out.append("Type: ASCII") out.append("") for cmd in self.commands: out.append(self.encode(cmd)) r...
[ "Dump all commands in this object to a string.\n\n Returns:\n str: An encoded list of commands separated by\n \\n characters suitable for saving to a file.\n " ]
Please provide a description of the function:def FromString(cls, indata): lines = [x.strip() for x in indata.split("\n") if not x.startswith('#') and not x.strip() == ""] if len(lines) < 3: raise DataError("Invalid CommandFile string that did not contain 3 header lines", lines=lin...
[ "Load a CommandFile from a string.\n\n The string should be produced from a previous call to\n encode.\n\n Args:\n indata (str): The encoded input data.\n\n Returns:\n CommandFile: The decoded CommandFile object.\n " ]
Please provide a description of the function:def FromFile(cls, inpath): with open(inpath, "r") as infile: indata = infile.read() return cls.FromString(indata)
[ "Load a CommandFile from a path.\n\n Args:\n inpath (str): The path to the file to load\n\n Returns:\n CommandFile: The decoded CommandFile object.\n " ]
Please provide a description of the function:def encode(cls, command): args = [] for arg in command.args: if not isinstance(arg, str): arg = str(arg) if "," in arg or arg.startswith(" ") or arg.endswith(" ") or arg.startswith("hex:"): ar...
[ "Encode a command as an unambiguous string.\n\n Args:\n command (Command): The command to encode.\n\n Returns:\n str: The encoded command\n " ]
Please provide a description of the function:def decode(cls, command_str): name, _, arg = command_str.partition(" ") args = [] if len(arg) > 0: if arg[0] != '{' or arg[-1] != '}': raise DataError("Invalid command, argument is not contained in { and }", arg...
[ "Decode a string encoded command back into a Command object.\n\n Args:\n command_str (str): The encoded command string output from a\n previous call to encode.\n\n Returns:\n Command: The decoded Command object.\n " ]
Please provide a description of the function:def receive(self, sequence, args): # If we are told to ignore sequence numbers, just pass the packet on if not self._reorder: self._callback(*args) return # If this packet is in the past, drop it if self._nex...
[ "Receive one packet\n\n If the sequence number is one we've already seen before, it is dropped.\n\n If it is not the next expected sequence number, it is put into the\n _out_of_order queue to be processed once the holes in sequence number\n are filled in.\n\n Args:\n se...
Please provide a description of the function:def set_vars(env): desired = env.get('MWCW_VERSION', '') # return right away if the variables are already set if isinstance(desired, MWVersion): return 1 elif desired is None: return 0 versions = find_versions() version = None ...
[ "Set MWCW_VERSION, MWCW_VERSIONS, and some codewarrior environment vars\n\n MWCW_VERSIONS is set to a list of objects representing installed versions\n\n MWCW_VERSION is set to the version object that will be used for building.\n MWCW_VERSION can be set to a string during Environment\n ...
Please provide a description of the function:def find_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('mwcc') if SCons.Util.can_...
[ "Return a list of MWVersion objects representing installed versions" ]
Please provide a description of the function:def generate(env): 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.CAction) shared_obj.add_actio...
[ "Add Builders and construction variables for the mwcc to an Environment." ]
Please provide a description of the function:def run(self, resources): if not resources['connection']._port.startswith('jlink'): raise ArgumentError("FlashBoardStep is currently only possible through jlink", invalid_port=args['port']) hwman = resources['connection'] debug =...
[ "Runs the flash step\n\n Args:\n resources (dict): A dictionary containing the required resources that\n we needed access to in order to perform this step.\n " ]
Please provide a description of the function:def copyto_emitter(target, source, env): n_target = [] for t in target: n_target = n_target + [t.File( str( s ) ) for s in source] return (n_target, source)
[ " changes the path of the source to be under the target (which\n are assumed to be directories.\n " ]
Please provide a description of the function:def getPharLapPath(): if not SCons.Util.can_read_reg: raise SCons.Errors.InternalError("No Windows registry module was found") try: k=SCons.Util.RegOpenKeyEx(SCons.Util.HKEY_LOCAL_MACHINE, 'SOFTWARE\\Pharlap\\ET...
[ "Reads the registry to find the installed path of the Phar Lap ETS\n development kit.\n\n Raises UserError if no installed version of Phar Lap can\n be found." ]
Please provide a description of the function:def getPharLapVersion(): include_path = os.path.join(getPharLapPath(), os.path.normpath("include/embkern.h")) if not os.path.exists(include_path): raise SCons.Errors.UserError("Cannot find embkern.h in ETS include directory.\nIs Phar Lap ETS installed p...
[ "Returns the version of the installed ETS Tool Suite as a\n decimal number. This version comes from the ETS_VER #define in\n the embkern.h header. For example, '#define ETS_VER 1010' (which\n is what Phar Lap 10.1 defines) would cause this method to return\n 1010. Phar Lap 9.1 does not have such a #de...
Please provide a description of the function:def addPharLapPaths(env): ph_path = getPharLapPath() try: env_dict = env['ENV'] except KeyError: env_dict = {} env['ENV'] = env_dict SCons.Util.AddPathIfNotExists(env_dict, 'PATH', os.path.join(p...
[ "This function adds the path to the Phar Lap binaries, includes,\n and libraries, if they are not already there." ]
Please provide a description of the function:def _update_or_init_po_files(target, source, env): import SCons.Action from SCons.Tool.GettextCommon import _init_po_files for tgt in target: if tgt.rexists(): action = SCons.Action.Action('$MSGMERGECOM', '$MSGMERGECOMSTR') else: action = _init_p...
[ " Action function for `POUpdate` builder " ]
Please provide a description of the function:def _POUpdateBuilder(env, **kw): 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')
[ " Create an object of `POUpdate` builder " ]
Please provide a description of the function:def _POUpdateBuilderWrapper(env, target=None, source=_null, **kw): if source is _null: if 'POTDOMAIN' in kw: domain = kw['POTDOMAIN'] elif 'POTDOMAIN' in env and env['POTDOMAIN']: domain = env['POTDOMAIN'] else: domain = 'messages' sour...
[ " Wrapper for `POUpdate` builder - make user's life easier " ]
Please provide a description of the function:def generate(env,**kw): 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 ...
[ " Generate the `xgettext` tool " ]
Please provide a description of the function:def _create_filter(self): self._product_filter = {} for chip in itertools.chain(iter(self._family.targets(self._tile.short_name)), iter([self._family.platform_independent_target()])): for key, prods i...
[ "Create a filter of all of the dependency products that we have selected." ]
Please provide a description of the function:def _create_product_map(self): self._product_map = {} for dep in self._tile.dependencies: try: dep_tile = IOTile(os.path.join('build', 'deps', dep['unique_id'])) except (ArgumentError, EnvironmentError): ...
[ "Create a map of all products produced by this or a dependency." ]
Please provide a description of the function:def _add_products(self, tile, show_all=False): products = tile.products unique_id = tile.unique_id base_path = tile.output_folder for prod_path, prod_type in products.items(): # We need to handle include_directories and ...
[ "Add all products from a tile into our product map." ]
Please provide a description of the function:def find_all(self, product_type, short_name, include_hidden=False): all_prods = [] # If product_type is not return products of all types if product_type is None: for prod_dict in self._product_map.values(): all_p...
[ "Find all providers of a given product by its short name.\n\n This function will return all providers of a given product. If you\n want to ensure that a product's name is unique among all dependencies,\n you should use find_unique.\n\n Args:\n product_type (str): The type of p...
Please provide a description of the function:def find_unique(self, product_type, short_name, include_hidden=False): prods = self.find_all(product_type, short_name, include_hidden) if len(prods) == 0: raise BuildError("Could not find product by name in find_unique", name=short_name...
[ "Find the unique provider of a given product by its short name.\n\n This function will ensure that the product is only provided by exactly\n one tile (either this tile or one of its dependencies and raise a\n BuildError if not.\n\n Args:\n product_type (str): The type of produ...
Please provide a description of the function:def build_parser(): parser = argparse.ArgumentParser(description=DESCRIPTION, formatter_class=argparse.RawDescriptionHelpFormatter) parser.add_argument('-o', '--output', help="The output file to save. If multiple files are generated " ...
[ "Create command line argument parser." ]
Please provide a description of the function:def main(raw_args=None): multifile_choices = frozenset(['c_files']) if raw_args is None: raw_args = sys.argv[1:] parser = build_parser() args = parser.parse_args(raw_args) if args.output is None and args.format in multifile_choices: ...
[ "Run the iotile-tbcompile script.\n\n Args:\n raw_args (list): Optional list of command line arguments. If not\n passed these are pulled from sys.argv.\n " ]
Please provide a description of the function: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 = Buil...
[]
Please provide a description of the function:def build_parser(): 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-ve...
[ "Build argument parsers." ]
Please provide a description of the function:def send_slack_message(message): if 'SLACK_WEB_HOOK' not in os.environ: raise EnvironmentError("Could not find SLACK_WEB_HOOK environment variable") webhook = os.environ['SLACK_WEB_HOOK'] r = requests.post(webhook, json={'text':message, 'username'...
[ "Send a message to the slack channel #coretools" ]
Please provide a description of the function:def get_release_component(comp): name, vers = comp.split("-") if name not in comp_names: print("Known components:") for comp in comp_names: print("- %s" % comp) raise EnvironmentError("Unknown release component name '%s'" %...
[ "Split the argument passed on the command line into a component name and expected version" ]
Please provide a description of the function:def check_compatibility(name): comp = comp_names[name] if sys.version_info.major < 3 and comp.compat == "python3": return False if sys.version_info.major >= 3 and comp.compat != "python3": return False return True
[ "Verify if we can release this component on the running interpreter.\n\n All components are released from python 2.7 by default unless they specify\n that they are python 3 only, in which case they are released from python 3.6\n " ]
Please provide a description of the function:def check_version(component, expected_version): comp = comp_names[component] compath = os.path.realpath(os.path.abspath(comp.path)) sys.path.insert(0, compath) import version if version.version != expected_version: raise EnvironmentError(...
[ "Make sure the package version in setuptools matches what we expect it to be" ]
Please provide a description of the function:def build_component(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: setuptools.sandb...
[ "Create an sdist and a wheel for the desired component" ]
Please provide a description of the function:def upload_component(component): if 'PYPI_USER' in os.environ and 'PYPI_PASS' in os.environ: pypi_user = os.environ['PYPI_USER'] pypi_pass = os.environ['PYPI_PASS'] else: pypi_user = None pypi_pass = None print("No PYPI u...
[ "Upload a given component to pypi\n\n The pypi username and password must either be specified in a ~/.pypirc\n file or in environment variables PYPI_USER and PYPI_PASS\n " ]
Please provide a description of the function:def uuid_to_slug(uuid): if not isinstance(uuid, int): raise ArgumentError("Invalid id that is not an integer", id=uuid) if uuid < 0 or uuid > 0x7fffffff: # For now, limiting support to a signed integer (which on some platforms, can be 32bits) ...
[ "\n Return IOTile Cloud compatible Device Slug\n\n :param uuid: UUID\n :return: string in the form of d--0000-0000-0000-0001\n " ]
Please provide a description of the function: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): SCons.Tool.Tool('ipkg').generate(env) # setup the Ipkg builder bld ...
[ " This function prepares the packageroot directory for packaging with the\n ipkg builder.\n " ]
Please provide a description of the function:def build_specfiles(source, target, env): # # 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 store into # a dict so they can be easily accessed. # ...
[ " Filter the targets for the needed files and use the variables in env\n to create the specfile.\n ", "\nPackage: $NAME\nVersion: $VERSION\nPriority: $X_IPK_PRIORITY\nSection: $X_IPK_SECTION\nSource: $SOURCE_URL\nArchitecture: $ARCHITECTURE\nMaintainer: $X_IPK_MAINTAINER\nDepends: $X_IPK_DEPENDS\nDescriptio...
Please provide a description of the function:def generate(env): java_javah = SCons.Tool.CreateJavaHBuilder(env) java_javah.emitter = emit_java_headers env['_JAVAHOUTFLAG'] = JavaHOutFlagGenerator env['JAVAH'] = 'javah' env['JAVAHFLAGS'] = SCons.Util.CLVar('') env['_JAVA...
[ "Add Builders and construction variables for javah to an Environment." ]
Please provide a description of the function:def dump(self): return { u'storage_data': [x.asdict() for x in self.storage_data], u'streaming_data': [x.asdict() for x in self.streaming_data] }
[ "Serialize the state of this InMemoryStorageEngine to a dict.\n\n Returns:\n dict: The serialized data.\n " ]
Please provide a description of the function:def restore(self, state): 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: raise ArgumentE...
[ "Restore the state of this InMemoryStorageEngine from a dict." ]
Please provide a description of the function:def count_matching(self, selector, offset=0): if selector.output: data = self.streaming_data elif selector.buffered: data = self.storage_data else: raise ArgumentError("You can only pass a buffered selecto...
[ "Count the number of readings matching selector.\n\n Args:\n selector (DataStreamSelector): The selector that we want to\n count matching readings for.\n offset (int): The starting offset that we should begin counting at.\n\n Returns:\n int: The number o...