id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
226,900
google/openhtf
openhtf/util/multicast.py
send
def send(query, address=DEFAULT_ADDRESS, port=DEFAULT_PORT, ttl=DEFAULT_TTL, local_only=False, timeout_s=2): """Sends a query to the given multicast socket and returns responses. Args: query: The string query to send. address: Multicast IP address component of t...
python
def send(query, address=DEFAULT_ADDRESS, port=DEFAULT_PORT, ttl=DEFAULT_TTL, local_only=False, timeout_s=2): """Sends a query to the given multicast socket and returns responses. Args: query: The string query to send. address: Multicast IP address component of t...
[ "def", "send", "(", "query", ",", "address", "=", "DEFAULT_ADDRESS", ",", "port", "=", "DEFAULT_PORT", ",", "ttl", "=", "DEFAULT_TTL", ",", "local_only", "=", "False", ",", "timeout_s", "=", "2", ")", ":", "# Set up the socket as a UDP Multicast socket with the gi...
Sends a query to the given multicast socket and returns responses. Args: query: The string query to send. address: Multicast IP address component of the socket to send to. port: Multicast UDP port component of the socket to send to. ttl: TTL for multicast messages. 1 to keep traffic in-network. t...
[ "Sends", "a", "query", "to", "the", "given", "multicast", "socket", "and", "returns", "responses", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/util/multicast.py#L135-L188
226,901
google/openhtf
openhtf/util/multicast.py
MulticastListener.run
def run(self): """Listen for pings until stopped.""" self._live = True self._sock.settimeout(self.LISTEN_TIMEOUT_S) # Passing in INADDR_ANY means the kernel will choose the default interface. # The localhost address is used to receive messages sent in "local_only" # mode and the default address...
python
def run(self): """Listen for pings until stopped.""" self._live = True self._sock.settimeout(self.LISTEN_TIMEOUT_S) # Passing in INADDR_ANY means the kernel will choose the default interface. # The localhost address is used to receive messages sent in "local_only" # mode and the default address...
[ "def", "run", "(", "self", ")", ":", "self", ".", "_live", "=", "True", "self", ".", "_sock", ".", "settimeout", "(", "self", ".", "LISTEN_TIMEOUT_S", ")", "# Passing in INADDR_ANY means the kernel will choose the default interface.", "# The localhost address is used to r...
Listen for pings until stopped.
[ "Listen", "for", "pings", "until", "stopped", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/util/multicast.py#L87-L132
226,902
google/openhtf
openhtf/plugs/usb/fastboot_protocol.py
FastbootProtocol._handle_progress
def _handle_progress(self, total, progress_callback): # pylint: disable=no-self-use """Calls the callback with the current progress and total .""" current = 0 while True: current += yield try: progress_callback(current, total) except Exception: # pylint: disable=broad-except ...
python
def _handle_progress(self, total, progress_callback): # pylint: disable=no-self-use """Calls the callback with the current progress and total .""" current = 0 while True: current += yield try: progress_callback(current, total) except Exception: # pylint: disable=broad-except ...
[ "def", "_handle_progress", "(", "self", ",", "total", ",", "progress_callback", ")", ":", "# pylint: disable=no-self-use", "current", "=", "0", "while", "True", ":", "current", "+=", "yield", "try", ":", "progress_callback", "(", "current", ",", "total", ")", ...
Calls the callback with the current progress and total .
[ "Calls", "the", "callback", "with", "the", "current", "progress", "and", "total", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/plugs/usb/fastboot_protocol.py#L162-L172
226,903
google/openhtf
openhtf/plugs/usb/fastboot_protocol.py
FastbootCommands._simple_command
def _simple_command(self, command, arg=None, **kwargs): """Send a simple command.""" self._protocol.send_command(command, arg) return self._protocol.handle_simple_responses(**kwargs)
python
def _simple_command(self, command, arg=None, **kwargs): """Send a simple command.""" self._protocol.send_command(command, arg) return self._protocol.handle_simple_responses(**kwargs)
[ "def", "_simple_command", "(", "self", ",", "command", ",", "arg", "=", "None", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_protocol", ".", "send_command", "(", "command", ",", "arg", ")", "return", "self", ".", "_protocol", ".", "handle_simple_res...
Send a simple command.
[ "Send", "a", "simple", "command", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/plugs/usb/fastboot_protocol.py#L210-L213
226,904
google/openhtf
openhtf/output/servers/dashboard_server.py
_discover
def _discover(**kwargs): """Yields info about station servers announcing themselves via multicast.""" query = station_server.MULTICAST_QUERY for host, response in multicast.send(query, **kwargs): try: result = json.loads(response) except ValueError: _LOG.warn('Received bad JSON over multicast ...
python
def _discover(**kwargs): """Yields info about station servers announcing themselves via multicast.""" query = station_server.MULTICAST_QUERY for host, response in multicast.send(query, **kwargs): try: result = json.loads(response) except ValueError: _LOG.warn('Received bad JSON over multicast ...
[ "def", "_discover", "(", "*", "*", "kwargs", ")", ":", "query", "=", "station_server", ".", "MULTICAST_QUERY", "for", "host", ",", "response", "in", "multicast", ".", "send", "(", "query", ",", "*", "*", "kwargs", ")", ":", "try", ":", "result", "=", ...
Yields info about station servers announcing themselves via multicast.
[ "Yields", "info", "about", "station", "servers", "announcing", "themselves", "via", "multicast", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/output/servers/dashboard_server.py#L35-L52
226,905
google/openhtf
openhtf/output/servers/dashboard_server.py
DashboardPubSub.update_stations
def update_stations(cls, station_info_list): """Called by the station discovery loop to update the station map.""" with cls.station_map_lock: # By default, assume old stations are unreachable. for host_port, station_info in six.iteritems(cls.station_map): cls.station_map[host_port] = statio...
python
def update_stations(cls, station_info_list): """Called by the station discovery loop to update the station map.""" with cls.station_map_lock: # By default, assume old stations are unreachable. for host_port, station_info in six.iteritems(cls.station_map): cls.station_map[host_port] = statio...
[ "def", "update_stations", "(", "cls", ",", "station_info_list", ")", ":", "with", "cls", ".", "station_map_lock", ":", "# By default, assume old stations are unreachable.", "for", "host_port", ",", "station_info", "in", "six", ".", "iteritems", "(", "cls", ".", "sta...
Called by the station discovery loop to update the station map.
[ "Called", "by", "the", "station", "discovery", "loop", "to", "update", "the", "station", "map", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/output/servers/dashboard_server.py#L79-L89
226,906
google/openhtf
openhtf/output/servers/dashboard_server.py
DashboardPubSub.publish_if_new
def publish_if_new(cls): """If the station map has changed, publish the new information.""" message = cls.make_message() if message != cls.last_message: super(DashboardPubSub, cls).publish(message) cls.last_message = message
python
def publish_if_new(cls): """If the station map has changed, publish the new information.""" message = cls.make_message() if message != cls.last_message: super(DashboardPubSub, cls).publish(message) cls.last_message = message
[ "def", "publish_if_new", "(", "cls", ")", ":", "message", "=", "cls", ".", "make_message", "(", ")", "if", "message", "!=", "cls", ".", "last_message", ":", "super", "(", "DashboardPubSub", ",", "cls", ")", ".", "publish", "(", "message", ")", "cls", "...
If the station map has changed, publish the new information.
[ "If", "the", "station", "map", "has", "changed", "publish", "the", "new", "information", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/output/servers/dashboard_server.py#L92-L97
226,907
google/openhtf
examples/phase_groups.py
run_basic_group
def run_basic_group(): """Run the basic phase group example. In this example, there are no terminal phases; all phases are run. """ test = htf.Test(htf.PhaseGroup( setup=[setup_phase], main=[main_phase], teardown=[teardown_phase], )) test.execute()
python
def run_basic_group(): """Run the basic phase group example. In this example, there are no terminal phases; all phases are run. """ test = htf.Test(htf.PhaseGroup( setup=[setup_phase], main=[main_phase], teardown=[teardown_phase], )) test.execute()
[ "def", "run_basic_group", "(", ")", ":", "test", "=", "htf", ".", "Test", "(", "htf", ".", "PhaseGroup", "(", "setup", "=", "[", "setup_phase", "]", ",", "main", "=", "[", "main_phase", "]", ",", "teardown", "=", "[", "teardown_phase", "]", ",", ")",...
Run the basic phase group example. In this example, there are no terminal phases; all phases are run.
[ "Run", "the", "basic", "phase", "group", "example", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/examples/phase_groups.py#L54-L64
226,908
google/openhtf
examples/phase_groups.py
run_setup_error_group
def run_setup_error_group(): """Run the phase group example where an error occurs in a setup phase. The terminal setup phase shortcuts the test. The main phases are skipped. The PhaseGroup is not entered, so the teardown phases are also skipped. """ test = htf.Test(htf.PhaseGroup( setup=[error_setu...
python
def run_setup_error_group(): """Run the phase group example where an error occurs in a setup phase. The terminal setup phase shortcuts the test. The main phases are skipped. The PhaseGroup is not entered, so the teardown phases are also skipped. """ test = htf.Test(htf.PhaseGroup( setup=[error_setu...
[ "def", "run_setup_error_group", "(", ")", ":", "test", "=", "htf", ".", "Test", "(", "htf", ".", "PhaseGroup", "(", "setup", "=", "[", "error_setup_phase", "]", ",", "main", "=", "[", "main_phase", "]", ",", "teardown", "=", "[", "teardown_phase", "]", ...
Run the phase group example where an error occurs in a setup phase. The terminal setup phase shortcuts the test. The main phases are skipped. The PhaseGroup is not entered, so the teardown phases are also skipped.
[ "Run", "the", "phase", "group", "example", "where", "an", "error", "occurs", "in", "a", "setup", "phase", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/examples/phase_groups.py#L67-L79
226,909
google/openhtf
examples/phase_groups.py
run_main_error_group
def run_main_error_group(): """Run the phase group example where an error occurs in a main phase. The main phase in this example is terminal. The PhaseGroup was entered because the setup phases ran without error, so the teardown phases are run. The other main phase is skipped. """ test = htf.Test(htf.Phas...
python
def run_main_error_group(): """Run the phase group example where an error occurs in a main phase. The main phase in this example is terminal. The PhaseGroup was entered because the setup phases ran without error, so the teardown phases are run. The other main phase is skipped. """ test = htf.Test(htf.Phas...
[ "def", "run_main_error_group", "(", ")", ":", "test", "=", "htf", ".", "Test", "(", "htf", ".", "PhaseGroup", "(", "setup", "=", "[", "setup_phase", "]", ",", "main", "=", "[", "error_main_phase", ",", "main_phase", "]", ",", "teardown", "=", "[", "tea...
Run the phase group example where an error occurs in a main phase. The main phase in this example is terminal. The PhaseGroup was entered because the setup phases ran without error, so the teardown phases are run. The other main phase is skipped.
[ "Run", "the", "phase", "group", "example", "where", "an", "error", "occurs", "in", "a", "main", "phase", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/examples/phase_groups.py#L82-L94
226,910
google/openhtf
examples/phase_groups.py
run_nested_groups
def run_nested_groups(): """Run the nested groups example. This example shows a PhaseGroup in a PhaseGroup. No phase is terminal, so all are run in the order; main_phase inner_main_phase inner_teardown_phase teardown_phase """ test = htf.Test( htf.PhaseGroup( main=[ ...
python
def run_nested_groups(): """Run the nested groups example. This example shows a PhaseGroup in a PhaseGroup. No phase is terminal, so all are run in the order; main_phase inner_main_phase inner_teardown_phase teardown_phase """ test = htf.Test( htf.PhaseGroup( main=[ ...
[ "def", "run_nested_groups", "(", ")", ":", "test", "=", "htf", ".", "Test", "(", "htf", ".", "PhaseGroup", "(", "main", "=", "[", "main_phase", ",", "htf", ".", "PhaseGroup", ".", "with_teardown", "(", "inner_teardown_phase", ")", "(", "inner_main_phase", ...
Run the nested groups example. This example shows a PhaseGroup in a PhaseGroup. No phase is terminal, so all are run in the order; main_phase inner_main_phase inner_teardown_phase teardown_phase
[ "Run", "the", "nested", "groups", "example", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/examples/phase_groups.py#L97-L117
226,911
google/openhtf
examples/phase_groups.py
run_nested_error_groups
def run_nested_error_groups(): """Run nested groups example where an error occurs in nested main phase. In this example, the first main phase in the nested PhaseGroup errors out. The other inner main phase is skipped, as is the outer main phase. Both PhaseGroups were entered, so both teardown phases are run. ...
python
def run_nested_error_groups(): """Run nested groups example where an error occurs in nested main phase. In this example, the first main phase in the nested PhaseGroup errors out. The other inner main phase is skipped, as is the outer main phase. Both PhaseGroups were entered, so both teardown phases are run. ...
[ "def", "run_nested_error_groups", "(", ")", ":", "test", "=", "htf", ".", "Test", "(", "htf", ".", "PhaseGroup", "(", "main", "=", "[", "htf", ".", "PhaseGroup", ".", "with_teardown", "(", "inner_teardown_phase", ")", "(", "error_main_phase", ",", "main_phas...
Run nested groups example where an error occurs in nested main phase. In this example, the first main phase in the nested PhaseGroup errors out. The other inner main phase is skipped, as is the outer main phase. Both PhaseGroups were entered, so both teardown phases are run.
[ "Run", "nested", "groups", "example", "where", "an", "error", "occurs", "in", "nested", "main", "phase", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/examples/phase_groups.py#L120-L137
226,912
google/openhtf
bin/units_from_xls.py
main
def main(): """Main entry point for UNECE code .xls parsing.""" parser = argparse.ArgumentParser( description='Reads in a .xls file and generates a units module for ' 'OpenHTF.', prog='python units_from_xls.py') parser.add_argument('xlsfile', type=str, help='the...
python
def main(): """Main entry point for UNECE code .xls parsing.""" parser = argparse.ArgumentParser( description='Reads in a .xls file and generates a units module for ' 'OpenHTF.', prog='python units_from_xls.py') parser.add_argument('xlsfile', type=str, help='the...
[ "def", "main", "(", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "'Reads in a .xls file and generates a units module for '", "'OpenHTF.'", ",", "prog", "=", "'python units_from_xls.py'", ")", "parser", ".", "add_argument", "(", ...
Main entry point for UNECE code .xls parsing.
[ "Main", "entry", "point", "for", "UNECE", "code", ".", "xls", "parsing", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/bin/units_from_xls.py#L169-L203
226,913
google/openhtf
bin/units_from_xls.py
unit_defs_from_sheet
def unit_defs_from_sheet(sheet, column_names): """A generator that parses a worksheet containing UNECE code definitions. Args: sheet: An xldr.sheet object representing a UNECE code worksheet. column_names: A list/tuple with the expected column names corresponding to the unit name, code an...
python
def unit_defs_from_sheet(sheet, column_names): """A generator that parses a worksheet containing UNECE code definitions. Args: sheet: An xldr.sheet object representing a UNECE code worksheet. column_names: A list/tuple with the expected column names corresponding to the unit name, code an...
[ "def", "unit_defs_from_sheet", "(", "sheet", ",", "column_names", ")", ":", "seen", "=", "set", "(", ")", "try", ":", "col_indices", "=", "{", "}", "rows", "=", "sheet", ".", "get_rows", "(", ")", "# Find the indices for the columns we care about.", "for", "id...
A generator that parses a worksheet containing UNECE code definitions. Args: sheet: An xldr.sheet object representing a UNECE code worksheet. column_names: A list/tuple with the expected column names corresponding to the unit name, code and suffix in that order. Yields: Lines of Python so...
[ "A", "generator", "that", "parses", "a", "worksheet", "containing", "UNECE", "code", "definitions", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/bin/units_from_xls.py#L206-L242
226,914
google/openhtf
bin/units_from_xls.py
unit_key_from_name
def unit_key_from_name(name): """Return a legal python name for the given name for use as a unit key.""" result = name for old, new in six.iteritems(UNIT_KEY_REPLACEMENTS): result = result.replace(old, new) # Collapse redundant underscores and convert to uppercase. result = re.sub(r'_+', '_', result.upp...
python
def unit_key_from_name(name): """Return a legal python name for the given name for use as a unit key.""" result = name for old, new in six.iteritems(UNIT_KEY_REPLACEMENTS): result = result.replace(old, new) # Collapse redundant underscores and convert to uppercase. result = re.sub(r'_+', '_', result.upp...
[ "def", "unit_key_from_name", "(", "name", ")", ":", "result", "=", "name", "for", "old", ",", "new", "in", "six", ".", "iteritems", "(", "UNIT_KEY_REPLACEMENTS", ")", ":", "result", "=", "result", ".", "replace", "(", "old", ",", "new", ")", "# Collapse ...
Return a legal python name for the given name for use as a unit key.
[ "Return", "a", "legal", "python", "name", "for", "the", "given", "name", "for", "use", "as", "a", "unit", "key", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/bin/units_from_xls.py#L245-L255
226,915
google/openhtf
openhtf/plugs/usb/adb_message.py
make_wire_commands
def make_wire_commands(*ids): """Assemble the commands.""" cmd_to_wire = { cmd: sum(ord(c) << (i * 8) for i, c in enumerate(cmd)) for cmd in ids } wire_to_cmd = {wire: cmd for cmd, wire in six.iteritems(cmd_to_wire)} return cmd_to_wire, wire_to_cmd
python
def make_wire_commands(*ids): """Assemble the commands.""" cmd_to_wire = { cmd: sum(ord(c) << (i * 8) for i, c in enumerate(cmd)) for cmd in ids } wire_to_cmd = {wire: cmd for cmd, wire in six.iteritems(cmd_to_wire)} return cmd_to_wire, wire_to_cmd
[ "def", "make_wire_commands", "(", "*", "ids", ")", ":", "cmd_to_wire", "=", "{", "cmd", ":", "sum", "(", "ord", "(", "c", ")", "<<", "(", "i", "*", "8", ")", "for", "i", ",", "c", "in", "enumerate", "(", "cmd", ")", ")", "for", "cmd", "in", "...
Assemble the commands.
[ "Assemble", "the", "commands", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/plugs/usb/adb_message.py#L55-L61
226,916
google/openhtf
openhtf/plugs/usb/adb_message.py
RawAdbMessage.to_adb_message
def to_adb_message(self, data): """Turn the data into an ADB message.""" message = AdbMessage(AdbMessage.WIRE_TO_CMD.get(self.cmd), self.arg0, self.arg1, data) if (len(data) != self.data_length or message.data_crc32 != self.data_checksum): raise usb_exceptions.AdbDataI...
python
def to_adb_message(self, data): """Turn the data into an ADB message.""" message = AdbMessage(AdbMessage.WIRE_TO_CMD.get(self.cmd), self.arg0, self.arg1, data) if (len(data) != self.data_length or message.data_crc32 != self.data_checksum): raise usb_exceptions.AdbDataI...
[ "def", "to_adb_message", "(", "self", ",", "data", ")", ":", "message", "=", "AdbMessage", "(", "AdbMessage", ".", "WIRE_TO_CMD", ".", "get", "(", "self", ".", "cmd", ")", ",", "self", ".", "arg0", ",", "self", ".", "arg1", ",", "data", ")", "if", ...
Turn the data into an ADB message.
[ "Turn", "the", "data", "into", "an", "ADB", "message", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/plugs/usb/adb_message.py#L70-L78
226,917
google/openhtf
openhtf/plugs/usb/adb_message.py
AdbTransportAdapter.write_message
def write_message(self, message, timeout): """Send the given message over this transport. Args: message: The AdbMessage to send. timeout: Use this timeout for the entire write operation, it should be an instance of timeouts.PolledTimeout. """ with self._writer_lock: self._tran...
python
def write_message(self, message, timeout): """Send the given message over this transport. Args: message: The AdbMessage to send. timeout: Use this timeout for the entire write operation, it should be an instance of timeouts.PolledTimeout. """ with self._writer_lock: self._tran...
[ "def", "write_message", "(", "self", ",", "message", ",", "timeout", ")", ":", "with", "self", ".", "_writer_lock", ":", "self", ".", "_transport", ".", "write", "(", "message", ".", "header", ",", "timeout", ".", "remaining_ms", ")", "# Use any remaining ti...
Send the given message over this transport. Args: message: The AdbMessage to send. timeout: Use this timeout for the entire write operation, it should be an instance of timeouts.PolledTimeout.
[ "Send", "the", "given", "message", "over", "this", "transport", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/plugs/usb/adb_message.py#L109-L128
226,918
google/openhtf
openhtf/plugs/usb/adb_message.py
AdbTransportAdapter.read_message
def read_message(self, timeout): """Read an AdbMessage from this transport. Args: timeout: Timeout for the entire read operation, in the form of a timeouts.PolledTimeout instance. Note that for packets with a data payload, two USB reads are performed. Returns: The ADB message ...
python
def read_message(self, timeout): """Read an AdbMessage from this transport. Args: timeout: Timeout for the entire read operation, in the form of a timeouts.PolledTimeout instance. Note that for packets with a data payload, two USB reads are performed. Returns: The ADB message ...
[ "def", "read_message", "(", "self", ",", "timeout", ")", ":", "with", "self", ".", "_reader_lock", ":", "raw_header", "=", "self", ".", "_transport", ".", "read", "(", "struct", ".", "calcsize", "(", "AdbMessage", ".", "HEADER_STRUCT_FORMAT", ")", ",", "ti...
Read an AdbMessage from this transport. Args: timeout: Timeout for the entire read operation, in the form of a timeouts.PolledTimeout instance. Note that for packets with a data payload, two USB reads are performed. Returns: The ADB message read from the device. Raises: ...
[ "Read", "an", "AdbMessage", "from", "this", "transport", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/plugs/usb/adb_message.py#L130-L172
226,919
google/openhtf
openhtf/plugs/usb/adb_message.py
AdbTransportAdapter.read_until
def read_until(self, expected_commands, timeout): """Read AdbMessages from this transport until we get an expected command. The ADB protocol specifies that before a successful CNXN handshake, any other packets must be ignored, so this method provides the ability to ignore unwanted commands. It's prima...
python
def read_until(self, expected_commands, timeout): """Read AdbMessages from this transport until we get an expected command. The ADB protocol specifies that before a successful CNXN handshake, any other packets must be ignored, so this method provides the ability to ignore unwanted commands. It's prima...
[ "def", "read_until", "(", "self", ",", "expected_commands", ",", "timeout", ")", ":", "msg", "=", "timeouts", ".", "loop_until_timeout_or_valid", "(", "timeout", ",", "lambda", ":", "self", ".", "read_message", "(", "timeout", ")", ",", "lambda", "m", ":", ...
Read AdbMessages from this transport until we get an expected command. The ADB protocol specifies that before a successful CNXN handshake, any other packets must be ignored, so this method provides the ability to ignore unwanted commands. It's primarily used during the initial connection to the device...
[ "Read", "AdbMessages", "from", "this", "transport", "until", "we", "get", "an", "expected", "command", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/plugs/usb/adb_message.py#L174-L202
226,920
google/openhtf
openhtf/plugs/usb/adb_message.py
AdbMessage.header
def header(self): """The message header.""" return struct.pack( self.HEADER_STRUCT_FORMAT, self._command, self.arg0, self.arg1, len(self.data), self.data_crc32, self.magic)
python
def header(self): """The message header.""" return struct.pack( self.HEADER_STRUCT_FORMAT, self._command, self.arg0, self.arg1, len(self.data), self.data_crc32, self.magic)
[ "def", "header", "(", "self", ")", ":", "return", "struct", ".", "pack", "(", "self", ".", "HEADER_STRUCT_FORMAT", ",", "self", ".", "_command", ",", "self", ".", "arg0", ",", "self", ".", "arg1", ",", "len", "(", "self", ".", "data", ")", ",", "se...
The message header.
[ "The", "message", "header", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/plugs/usb/adb_message.py#L276-L280
226,921
google/openhtf
openhtf/plugs/usb/filesync_service.py
_make_message_type
def _make_message_type(name, attributes, has_data=True): """Make a message type for the AdbTransport subclasses.""" def assert_command_is(self, command): # pylint: disable=invalid-name """Assert that a message's command matches the given command.""" if self.command != command: raise usb_exceptions.A...
python
def _make_message_type(name, attributes, has_data=True): """Make a message type for the AdbTransport subclasses.""" def assert_command_is(self, command): # pylint: disable=invalid-name """Assert that a message's command matches the given command.""" if self.command != command: raise usb_exceptions.A...
[ "def", "_make_message_type", "(", "name", ",", "attributes", ",", "has_data", "=", "True", ")", ":", "def", "assert_command_is", "(", "self", ",", "command", ")", ":", "# pylint: disable=invalid-name", "\"\"\"Assert that a message's command matches the given command.\"\"\""...
Make a message type for the AdbTransport subclasses.
[ "Make", "a", "message", "type", "for", "the", "AdbTransport", "subclasses", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/plugs/usb/filesync_service.py#L130-L145
226,922
google/openhtf
openhtf/plugs/usb/filesync_service.py
FilesyncService.stat
def stat(self, filename, timeout=None): """Return device file stat.""" transport = StatFilesyncTransport(self.stream) transport.write_data('STAT', filename, timeout) stat_msg = transport.read_message(timeout) stat_msg.assert_command_is('STAT') return DeviceFileStat(filename, stat_msg.mode, stat_...
python
def stat(self, filename, timeout=None): """Return device file stat.""" transport = StatFilesyncTransport(self.stream) transport.write_data('STAT', filename, timeout) stat_msg = transport.read_message(timeout) stat_msg.assert_command_is('STAT') return DeviceFileStat(filename, stat_msg.mode, stat_...
[ "def", "stat", "(", "self", ",", "filename", ",", "timeout", "=", "None", ")", ":", "transport", "=", "StatFilesyncTransport", "(", "self", ".", "stream", ")", "transport", ".", "write_data", "(", "'STAT'", ",", "filename", ",", "timeout", ")", "stat_msg",...
Return device file stat.
[ "Return", "device", "file", "stat", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/plugs/usb/filesync_service.py#L173-L179
226,923
google/openhtf
openhtf/plugs/usb/filesync_service.py
FilesyncService.list
def list(self, path, timeout=None): """List directory contents on the device. Args: path: List the contents of this directory. timeout: Timeout to use for this operation. Returns: Generator yielding DeviceFileStat tuples representing the contents of the requested path. """ tr...
python
def list(self, path, timeout=None): """List directory contents on the device. Args: path: List the contents of this directory. timeout: Timeout to use for this operation. Returns: Generator yielding DeviceFileStat tuples representing the contents of the requested path. """ tr...
[ "def", "list", "(", "self", ",", "path", ",", "timeout", "=", "None", ")", ":", "transport", "=", "DentFilesyncTransport", "(", "self", ".", "stream", ")", "transport", ".", "write_data", "(", "'LIST'", ",", "path", ",", "timeout", ")", "return", "(", ...
List directory contents on the device. Args: path: List the contents of this directory. timeout: Timeout to use for this operation. Returns: Generator yielding DeviceFileStat tuples representing the contents of the requested path.
[ "List", "directory", "contents", "on", "the", "device", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/plugs/usb/filesync_service.py#L181-L196
226,924
google/openhtf
openhtf/plugs/usb/filesync_service.py
FilesyncService.recv
def recv(self, filename, dest_file, timeout=None): """Retrieve a file from the device into the file-like dest_file.""" transport = DataFilesyncTransport(self.stream) transport.write_data('RECV', filename, timeout) for data_msg in transport.read_until_done('DATA', timeout): dest_file.write(data_msg...
python
def recv(self, filename, dest_file, timeout=None): """Retrieve a file from the device into the file-like dest_file.""" transport = DataFilesyncTransport(self.stream) transport.write_data('RECV', filename, timeout) for data_msg in transport.read_until_done('DATA', timeout): dest_file.write(data_msg...
[ "def", "recv", "(", "self", ",", "filename", ",", "dest_file", ",", "timeout", "=", "None", ")", ":", "transport", "=", "DataFilesyncTransport", "(", "self", ".", "stream", ")", "transport", ".", "write_data", "(", "'RECV'", ",", "filename", ",", "timeout"...
Retrieve a file from the device into the file-like dest_file.
[ "Retrieve", "a", "file", "from", "the", "device", "into", "the", "file", "-", "like", "dest_file", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/plugs/usb/filesync_service.py#L198-L203
226,925
google/openhtf
openhtf/plugs/usb/filesync_service.py
FilesyncService._check_for_fail_message
def _check_for_fail_message(self, transport, exc_info, timeout): # pylint: disable=no-self-use """Check for a 'FAIL' message from transport. This method always raises, if 'FAIL' was read, it will raise an AdbRemoteError with the message, otherwise it will raise based on exc_info, which should be a tup...
python
def _check_for_fail_message(self, transport, exc_info, timeout): # pylint: disable=no-self-use """Check for a 'FAIL' message from transport. This method always raises, if 'FAIL' was read, it will raise an AdbRemoteError with the message, otherwise it will raise based on exc_info, which should be a tup...
[ "def", "_check_for_fail_message", "(", "self", ",", "transport", ",", "exc_info", ",", "timeout", ")", ":", "# pylint: disable=no-self-use", "try", ":", "transport", ".", "read_message", "(", "timeout", ")", "except", "usb_exceptions", ".", "CommonUsbError", ":", ...
Check for a 'FAIL' message from transport. This method always raises, if 'FAIL' was read, it will raise an AdbRemoteError with the message, otherwise it will raise based on exc_info, which should be a tuple as per sys.exc_info(). Args: transport: Transport from which to read for a 'FAIL' message...
[ "Check", "for", "a", "FAIL", "message", "from", "transport", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/plugs/usb/filesync_service.py#L205-L227
226,926
google/openhtf
openhtf/plugs/usb/filesync_service.py
AbstractFilesyncTransport.write_data
def write_data(self, command, data, timeout=None): """Shortcut for writing specifically a DataMessage.""" self.write_message(FilesyncMessageTypes.DataMessage(command, data), timeout)
python
def write_data(self, command, data, timeout=None): """Shortcut for writing specifically a DataMessage.""" self.write_message(FilesyncMessageTypes.DataMessage(command, data), timeout)
[ "def", "write_data", "(", "self", ",", "command", ",", "data", ",", "timeout", "=", "None", ")", ":", "self", ".", "write_message", "(", "FilesyncMessageTypes", ".", "DataMessage", "(", "command", ",", "data", ")", ",", "timeout", ")" ]
Shortcut for writing specifically a DataMessage.
[ "Shortcut", "for", "writing", "specifically", "a", "DataMessage", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/plugs/usb/filesync_service.py#L362-L364
226,927
google/openhtf
openhtf/plugs/usb/filesync_service.py
AbstractFilesyncTransport.read_until_done
def read_until_done(self, command, timeout=None): """Yield messages read until we receive a 'DONE' command. Read messages of the given command until we receive a 'DONE' command. If a command different than the requested one is received, an AdbProtocolError is raised. Args: command: The comm...
python
def read_until_done(self, command, timeout=None): """Yield messages read until we receive a 'DONE' command. Read messages of the given command until we receive a 'DONE' command. If a command different than the requested one is received, an AdbProtocolError is raised. Args: command: The comm...
[ "def", "read_until_done", "(", "self", ",", "command", ",", "timeout", "=", "None", ")", ":", "message", "=", "self", ".", "read_message", "(", "timeout", ")", "while", "message", ".", "command", "!=", "'DONE'", ":", "message", ".", "assert_command_is", "(...
Yield messages read until we receive a 'DONE' command. Read messages of the given command until we receive a 'DONE' command. If a command different than the requested one is received, an AdbProtocolError is raised. Args: command: The command to expect, like 'DENT' or 'DATA'. timeout: The ...
[ "Yield", "messages", "read", "until", "we", "receive", "a", "DONE", "command", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/plugs/usb/filesync_service.py#L391-L413
226,928
google/openhtf
openhtf/plugs/usb/filesync_service.py
AbstractFilesyncTransport.read_message
def read_message(self, timeout=None): """Read a message from this transport and return it. Reads a message of RECV_MSG_TYPE and returns it. Note that this method abstracts the data length and data read so that the caller simply gets the data along with the header in the returned message. Args: ...
python
def read_message(self, timeout=None): """Read a message from this transport and return it. Reads a message of RECV_MSG_TYPE and returns it. Note that this method abstracts the data length and data read so that the caller simply gets the data along with the header in the returned message. Args: ...
[ "def", "read_message", "(", "self", ",", "timeout", "=", "None", ")", ":", "raw_data", "=", "self", ".", "stream", ".", "read", "(", "struct", ".", "calcsize", "(", "self", ".", "RECV_MSG_TYPE", ".", "struct_format", ")", ",", "timeout", ")", "try", ":...
Read a message from this transport and return it. Reads a message of RECV_MSG_TYPE and returns it. Note that this method abstracts the data length and data read so that the caller simply gets the data along with the header in the returned message. Args: timeout: timeouts.PolledTimeout to use fo...
[ "Read", "a", "message", "from", "this", "transport", "and", "return", "it", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/plugs/usb/filesync_service.py#L415-L461
226,929
google/openhtf
openhtf/output/proto/mfg_event_converter.py
_lazy_load_units_by_code
def _lazy_load_units_by_code(): """Populate dict of units by code iff UNITS_BY_CODE is empty.""" if UNITS_BY_CODE: # already populated return for unit in units.UNITS_BY_NAME.values(): UNITS_BY_CODE[unit.code] = unit
python
def _lazy_load_units_by_code(): """Populate dict of units by code iff UNITS_BY_CODE is empty.""" if UNITS_BY_CODE: # already populated return for unit in units.UNITS_BY_NAME.values(): UNITS_BY_CODE[unit.code] = unit
[ "def", "_lazy_load_units_by_code", "(", ")", ":", "if", "UNITS_BY_CODE", ":", "# already populated", "return", "for", "unit", "in", "units", ".", "UNITS_BY_NAME", ".", "values", "(", ")", ":", "UNITS_BY_CODE", "[", "unit", ".", "code", "]", "=", "unit" ]
Populate dict of units by code iff UNITS_BY_CODE is empty.
[ "Populate", "dict", "of", "units", "by", "code", "iff", "UNITS_BY_CODE", "is", "empty", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/output/proto/mfg_event_converter.py#L52-L59
226,930
google/openhtf
openhtf/output/proto/mfg_event_converter.py
_populate_basic_data
def _populate_basic_data(mfg_event, record): """Copies data from the OpenHTF TestRecord to the MfgEvent proto.""" # TODO: # * Missing in proto: set run name from metadata. # * `part_tags` field on proto is unused # * `timings` field on proto is unused. # * Handle arbitrary units as uom_code/uom_suff...
python
def _populate_basic_data(mfg_event, record): """Copies data from the OpenHTF TestRecord to the MfgEvent proto.""" # TODO: # * Missing in proto: set run name from metadata. # * `part_tags` field on proto is unused # * `timings` field on proto is unused. # * Handle arbitrary units as uom_code/uom_suff...
[ "def", "_populate_basic_data", "(", "mfg_event", ",", "record", ")", ":", "# TODO:", "# * Missing in proto: set run name from metadata.", "# * `part_tags` field on proto is unused", "# * `timings` field on proto is unused.", "# * Handle arbitrary units as uom_code/uom_suffix.", "# ...
Copies data from the OpenHTF TestRecord to the MfgEvent proto.
[ "Copies", "data", "from", "the", "OpenHTF", "TestRecord", "to", "the", "MfgEvent", "proto", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/output/proto/mfg_event_converter.py#L105-L159
226,931
google/openhtf
openhtf/output/proto/mfg_event_converter.py
_attach_record_as_json
def _attach_record_as_json(mfg_event, record): """Attach a copy of the record as JSON so we have an un-mangled copy.""" attachment = mfg_event.attachment.add() attachment.name = TEST_RECORD_ATTACHMENT_NAME test_record_dict = htf_data.convert_to_base_types(record) attachment.value_binary = _convert_object_to_j...
python
def _attach_record_as_json(mfg_event, record): """Attach a copy of the record as JSON so we have an un-mangled copy.""" attachment = mfg_event.attachment.add() attachment.name = TEST_RECORD_ATTACHMENT_NAME test_record_dict = htf_data.convert_to_base_types(record) attachment.value_binary = _convert_object_to_j...
[ "def", "_attach_record_as_json", "(", "mfg_event", ",", "record", ")", ":", "attachment", "=", "mfg_event", ".", "attachment", ".", "add", "(", ")", "attachment", ".", "name", "=", "TEST_RECORD_ATTACHMENT_NAME", "test_record_dict", "=", "htf_data", ".", "convert_t...
Attach a copy of the record as JSON so we have an un-mangled copy.
[ "Attach", "a", "copy", "of", "the", "record", "as", "JSON", "so", "we", "have", "an", "un", "-", "mangled", "copy", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/output/proto/mfg_event_converter.py#L162-L168
226,932
google/openhtf
openhtf/output/proto/mfg_event_converter.py
_attach_config
def _attach_config(mfg_event, record): """Attaches the OpenHTF config file as JSON.""" if 'config' not in record.metadata: return attachment = mfg_event.attachment.add() attachment.name = 'config' attachment.value_binary = _convert_object_to_json(record.metadata['config']) attachment.type = test_runs_pb...
python
def _attach_config(mfg_event, record): """Attaches the OpenHTF config file as JSON.""" if 'config' not in record.metadata: return attachment = mfg_event.attachment.add() attachment.name = 'config' attachment.value_binary = _convert_object_to_json(record.metadata['config']) attachment.type = test_runs_pb...
[ "def", "_attach_config", "(", "mfg_event", ",", "record", ")", ":", "if", "'config'", "not", "in", "record", ".", "metadata", ":", "return", "attachment", "=", "mfg_event", ".", "attachment", ".", "add", "(", ")", "attachment", ".", "name", "=", "'config'"...
Attaches the OpenHTF config file as JSON.
[ "Attaches", "the", "OpenHTF", "config", "file", "as", "JSON", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/output/proto/mfg_event_converter.py#L186-L193
226,933
google/openhtf
openhtf/output/proto/mfg_event_converter.py
phase_uniquizer
def phase_uniquizer(all_phases): """Makes the names of phase measurement and attachments unique. This function will make the names of measurements and attachments unique. It modifies the input all_phases. Args: all_phases: the phases to make unique Returns: the phases now modified. """ measurem...
python
def phase_uniquizer(all_phases): """Makes the names of phase measurement and attachments unique. This function will make the names of measurements and attachments unique. It modifies the input all_phases. Args: all_phases: the phases to make unique Returns: the phases now modified. """ measurem...
[ "def", "phase_uniquizer", "(", "all_phases", ")", ":", "measurement_name_maker", "=", "UniqueNameMaker", "(", "itertools", ".", "chain", ".", "from_iterable", "(", "phase", ".", "measurements", ".", "keys", "(", ")", "for", "phase", "in", "all_phases", "if", "...
Makes the names of phase measurement and attachments unique. This function will make the names of measurements and attachments unique. It modifies the input all_phases. Args: all_phases: the phases to make unique Returns: the phases now modified.
[ "Makes", "the", "names", "of", "phase", "measurement", "and", "attachments", "unique", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/output/proto/mfg_event_converter.py#L224-L261
226,934
google/openhtf
openhtf/output/proto/mfg_event_converter.py
multidim_measurement_to_attachment
def multidim_measurement_to_attachment(name, measurement): """Convert a multi-dim measurement to an `openhtf.test_record.Attachment`.""" dimensions = list(measurement.dimensions) if measurement.units: dimensions.append( measurements.Dimension.from_unit_descriptor(measurement.units)) dims = [] fo...
python
def multidim_measurement_to_attachment(name, measurement): """Convert a multi-dim measurement to an `openhtf.test_record.Attachment`.""" dimensions = list(measurement.dimensions) if measurement.units: dimensions.append( measurements.Dimension.from_unit_descriptor(measurement.units)) dims = [] fo...
[ "def", "multidim_measurement_to_attachment", "(", "name", ",", "measurement", ")", ":", "dimensions", "=", "list", "(", "measurement", ".", "dimensions", ")", "if", "measurement", ".", "units", ":", "dimensions", ".", "append", "(", "measurements", ".", "Dimensi...
Convert a multi-dim measurement to an `openhtf.test_record.Attachment`.
[ "Convert", "a", "multi", "-", "dim", "measurement", "to", "an", "openhtf", ".", "test_record", ".", "Attachment", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/output/proto/mfg_event_converter.py#L264-L300
226,935
google/openhtf
openhtf/output/proto/mfg_event_converter.py
convert_multidim_measurements
def convert_multidim_measurements(all_phases): """Converts each multidim measurements into attachments for all phases..""" # Combine actual attachments with attachments we make from multi-dim # measurements. attachment_names = list(itertools.chain.from_iterable( phase.attachments.keys() for phase in all_p...
python
def convert_multidim_measurements(all_phases): """Converts each multidim measurements into attachments for all phases..""" # Combine actual attachments with attachments we make from multi-dim # measurements. attachment_names = list(itertools.chain.from_iterable( phase.attachments.keys() for phase in all_p...
[ "def", "convert_multidim_measurements", "(", "all_phases", ")", ":", "# Combine actual attachments with attachments we make from multi-dim", "# measurements.", "attachment_names", "=", "list", "(", "itertools", ".", "chain", ".", "from_iterable", "(", "phase", ".", "attachmen...
Converts each multidim measurements into attachments for all phases..
[ "Converts", "each", "multidim", "measurements", "into", "attachments", "for", "all", "phases", ".." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/output/proto/mfg_event_converter.py#L303-L324
226,936
google/openhtf
openhtf/output/proto/mfg_event_converter.py
attachment_to_multidim_measurement
def attachment_to_multidim_measurement(attachment, name=None): """Convert an OpenHTF test record attachment to a multi-dim measurement. This is a best effort attempt to reverse, as some data is lost in converting from a multidim to an attachment. Args: attachment: an `openhtf.test_record.Attachment` from ...
python
def attachment_to_multidim_measurement(attachment, name=None): """Convert an OpenHTF test record attachment to a multi-dim measurement. This is a best effort attempt to reverse, as some data is lost in converting from a multidim to an attachment. Args: attachment: an `openhtf.test_record.Attachment` from ...
[ "def", "attachment_to_multidim_measurement", "(", "attachment", ",", "name", "=", "None", ")", ":", "data", "=", "json", ".", "loads", "(", "attachment", ".", "data", ")", "name", "=", "name", "or", "data", ".", "get", "(", "'name'", ")", "# attachment_dim...
Convert an OpenHTF test record attachment to a multi-dim measurement. This is a best effort attempt to reverse, as some data is lost in converting from a multidim to an attachment. Args: attachment: an `openhtf.test_record.Attachment` from a multi-dim. name: an optional name for the measurement. If not...
[ "Convert", "an", "OpenHTF", "test", "record", "attachment", "to", "a", "multi", "-", "dim", "measurement", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/output/proto/mfg_event_converter.py#L427-L497
226,937
google/openhtf
openhtf/output/proto/mfg_event_converter.py
PhaseCopier._copy_unidimensional_measurement
def _copy_unidimensional_measurement( self, phase, name, measurement, mfg_event): """Copy uni-dimensional measurements to the MfgEvent.""" mfg_measurement = mfg_event.measurement.add() # Copy basic measurement fields. mfg_measurement.name = name if measurement.docstring: mfg_measurement...
python
def _copy_unidimensional_measurement( self, phase, name, measurement, mfg_event): """Copy uni-dimensional measurements to the MfgEvent.""" mfg_measurement = mfg_event.measurement.add() # Copy basic measurement fields. mfg_measurement.name = name if measurement.docstring: mfg_measurement...
[ "def", "_copy_unidimensional_measurement", "(", "self", ",", "phase", ",", "name", ",", "measurement", ",", "mfg_event", ")", ":", "mfg_measurement", "=", "mfg_event", ".", "measurement", ".", "add", "(", ")", "# Copy basic measurement fields.", "mfg_measurement", "...
Copy uni-dimensional measurements to the MfgEvent.
[ "Copy", "uni", "-", "dimensional", "measurements", "to", "the", "MfgEvent", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/output/proto/mfg_event_converter.py#L341-L396
226,938
google/openhtf
openhtf/output/proto/mfg_event_converter.py
PhaseCopier._copy_attachment
def _copy_attachment(self, name, data, mimetype, mfg_event): """Copies an attachment to mfg_event.""" attachment = mfg_event.attachment.add() attachment.name = name if isinstance(data, unicode): data = data.encode('utf8') attachment.value_binary = data if mimetype in test_runs_converter.MI...
python
def _copy_attachment(self, name, data, mimetype, mfg_event): """Copies an attachment to mfg_event.""" attachment = mfg_event.attachment.add() attachment.name = name if isinstance(data, unicode): data = data.encode('utf8') attachment.value_binary = data if mimetype in test_runs_converter.MI...
[ "def", "_copy_attachment", "(", "self", ",", "name", ",", "data", ",", "mimetype", ",", "mfg_event", ")", ":", "attachment", "=", "mfg_event", ".", "attachment", ".", "add", "(", ")", "attachment", ".", "name", "=", "name", "if", "isinstance", "(", "data...
Copies an attachment to mfg_event.
[ "Copies", "an", "attachment", "to", "mfg_event", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/output/proto/mfg_event_converter.py#L403-L415
226,939
google/openhtf
openhtf/plugs/usb/adb_protocol.py
AdbStream.write
def write(self, data, timeout_ms=None): """Write data to this stream. Args: data: Data to write. timeout_ms: Timeout to use for the write/Ack transaction, in milliseconds (or as a PolledTimeout object). Raises: AdbProtocolError: If an ACK is not received. AdbStreamClosedErr...
python
def write(self, data, timeout_ms=None): """Write data to this stream. Args: data: Data to write. timeout_ms: Timeout to use for the write/Ack transaction, in milliseconds (or as a PolledTimeout object). Raises: AdbProtocolError: If an ACK is not received. AdbStreamClosedErr...
[ "def", "write", "(", "self", ",", "data", ",", "timeout_ms", "=", "None", ")", ":", "timeout", "=", "timeouts", ".", "PolledTimeout", ".", "from_millis", "(", "timeout_ms", ")", "# Break the data up into our transport's maxdata sized WRTE messages.", "while", "data", ...
Write data to this stream. Args: data: Data to write. timeout_ms: Timeout to use for the write/Ack transaction, in milliseconds (or as a PolledTimeout object). Raises: AdbProtocolError: If an ACK is not received. AdbStreamClosedError: If the stream is already closed, or gets cl...
[ "Write", "data", "to", "this", "stream", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/plugs/usb/adb_protocol.py#L167-L185
226,940
google/openhtf
openhtf/plugs/usb/adb_protocol.py
AdbStream.read
def read(self, length=0, timeout_ms=None): """Reads data from the remote end of this stream. Internally, this data will have been contained in AdbMessages, but users of streams shouldn't need to care about the transport mechanism. Args: length: If provided, the number of bytes to read, otherwise...
python
def read(self, length=0, timeout_ms=None): """Reads data from the remote end of this stream. Internally, this data will have been contained in AdbMessages, but users of streams shouldn't need to care about the transport mechanism. Args: length: If provided, the number of bytes to read, otherwise...
[ "def", "read", "(", "self", ",", "length", "=", "0", ",", "timeout_ms", "=", "None", ")", ":", "return", "self", ".", "_transport", ".", "read", "(", "length", ",", "timeouts", ".", "PolledTimeout", ".", "from_millis", "(", "timeout_ms", ")", ")" ]
Reads data from the remote end of this stream. Internally, this data will have been contained in AdbMessages, but users of streams shouldn't need to care about the transport mechanism. Args: length: If provided, the number of bytes to read, otherwise all available data will be returned (at l...
[ "Reads", "data", "from", "the", "remote", "end", "of", "this", "stream", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/plugs/usb/adb_protocol.py#L187-L209
226,941
google/openhtf
openhtf/plugs/usb/adb_protocol.py
AdbStream.read_until_close
def read_until_close(self, timeout_ms=None): """Yield data until this stream is closed. Args: timeout_ms: Timeout in milliseconds to keep reading (or a PolledTimeout object). Yields: Data read from a single call to self.read(), until the stream is closed or timeout is reached. ...
python
def read_until_close(self, timeout_ms=None): """Yield data until this stream is closed. Args: timeout_ms: Timeout in milliseconds to keep reading (or a PolledTimeout object). Yields: Data read from a single call to self.read(), until the stream is closed or timeout is reached. ...
[ "def", "read_until_close", "(", "self", ",", "timeout_ms", "=", "None", ")", ":", "while", "True", ":", "try", ":", "yield", "self", ".", "read", "(", "timeout_ms", "=", "timeout_ms", ")", "except", "usb_exceptions", ".", "AdbStreamClosedError", ":", "break"...
Yield data until this stream is closed. Args: timeout_ms: Timeout in milliseconds to keep reading (or a PolledTimeout object). Yields: Data read from a single call to self.read(), until the stream is closed or timeout is reached. Raises: AdbTimeoutError: On timeout.
[ "Yield", "data", "until", "this", "stream", "is", "closed", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/plugs/usb/adb_protocol.py#L211-L229
226,942
google/openhtf
openhtf/plugs/usb/adb_protocol.py
AdbStreamTransport._set_or_check_remote_id
def _set_or_check_remote_id(self, remote_id): """Set or check the remote id.""" if not self.remote_id: assert self.closed_state == self.ClosedState.PENDING, 'Bad ClosedState!' self.remote_id = remote_id self.closed_state = self.ClosedState.OPEN elif self.remote_id != remote_id: raise...
python
def _set_or_check_remote_id(self, remote_id): """Set or check the remote id.""" if not self.remote_id: assert self.closed_state == self.ClosedState.PENDING, 'Bad ClosedState!' self.remote_id = remote_id self.closed_state = self.ClosedState.OPEN elif self.remote_id != remote_id: raise...
[ "def", "_set_or_check_remote_id", "(", "self", ",", "remote_id", ")", ":", "if", "not", "self", ".", "remote_id", ":", "assert", "self", ".", "closed_state", "==", "self", ".", "ClosedState", ".", "PENDING", ",", "'Bad ClosedState!'", "self", ".", "remote_id",...
Set or check the remote id.
[ "Set", "or", "check", "the", "remote", "id", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/plugs/usb/adb_protocol.py#L277-L285
226,943
google/openhtf
openhtf/plugs/usb/adb_protocol.py
AdbStreamTransport._handle_message
def _handle_message(self, message, handle_wrte=True): """Handle a message that was read for this stream. For each message type, this means: OKAY: Check id's and make sure we are expecting an OKAY. Clear the self._expecting_okay flag so any pending write()'s know. CLSE: Set our internal sta...
python
def _handle_message(self, message, handle_wrte=True): """Handle a message that was read for this stream. For each message type, this means: OKAY: Check id's and make sure we are expecting an OKAY. Clear the self._expecting_okay flag so any pending write()'s know. CLSE: Set our internal sta...
[ "def", "_handle_message", "(", "self", ",", "message", ",", "handle_wrte", "=", "True", ")", ":", "if", "message", ".", "command", "==", "'OKAY'", ":", "self", ".", "_set_or_check_remote_id", "(", "message", ".", "arg0", ")", "if", "not", "self", ".", "_...
Handle a message that was read for this stream. For each message type, this means: OKAY: Check id's and make sure we are expecting an OKAY. Clear the self._expecting_okay flag so any pending write()'s know. CLSE: Set our internal state to closed. WRTE: Add the data read to our internal r...
[ "Handle", "a", "message", "that", "was", "read", "for", "this", "stream", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/plugs/usb/adb_protocol.py#L314-L345
226,944
google/openhtf
openhtf/plugs/usb/adb_protocol.py
AdbStreamTransport._read_messages_until_true
def _read_messages_until_true(self, predicate, timeout): """Read a message from this stream and handle it. This method tries to read a message from this stream, blocking until a message is read. Once read, it will handle it accordingly by calling self._handle_message(). This is repeated as long a...
python
def _read_messages_until_true(self, predicate, timeout): """Read a message from this stream and handle it. This method tries to read a message from this stream, blocking until a message is read. Once read, it will handle it accordingly by calling self._handle_message(). This is repeated as long a...
[ "def", "_read_messages_until_true", "(", "self", ",", "predicate", ",", "timeout", ")", ":", "while", "not", "predicate", "(", ")", ":", "# Hold the message_received Lock while we try to acquire the reader_lock", "# and waiting on the message_received condition, to prevent another ...
Read a message from this stream and handle it. This method tries to read a message from this stream, blocking until a message is read. Once read, it will handle it accordingly by calling self._handle_message(). This is repeated as long as predicate() returns False. There is some locking used int...
[ "Read", "a", "message", "from", "this", "stream", "and", "handle", "it", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/plugs/usb/adb_protocol.py#L347-L408
226,945
google/openhtf
openhtf/plugs/usb/adb_protocol.py
AdbStreamTransport.ensure_opened
def ensure_opened(self, timeout): """Ensure this stream transport was successfully opened. Checks to make sure we receive our initial OKAY message. This must be called after creating this AdbStreamTransport and before calling read() or write(). Args: timeout: timeouts.PolledTimeout to use f...
python
def ensure_opened(self, timeout): """Ensure this stream transport was successfully opened. Checks to make sure we receive our initial OKAY message. This must be called after creating this AdbStreamTransport and before calling read() or write(). Args: timeout: timeouts.PolledTimeout to use f...
[ "def", "ensure_opened", "(", "self", ",", "timeout", ")", ":", "self", ".", "_handle_message", "(", "self", ".", "adb_connection", ".", "read_for_stream", "(", "self", ",", "timeout", ")", ",", "handle_wrte", "=", "False", ")", "return", "self", ".", "is_o...
Ensure this stream transport was successfully opened. Checks to make sure we receive our initial OKAY message. This must be called after creating this AdbStreamTransport and before calling read() or write(). Args: timeout: timeouts.PolledTimeout to use for this operation. Returns: Tr...
[ "Ensure", "this", "stream", "transport", "was", "successfully", "opened", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/plugs/usb/adb_protocol.py#L410-L430
226,946
google/openhtf
openhtf/plugs/usb/adb_protocol.py
AdbStreamTransport.enqueue_message
def enqueue_message(self, message, timeout): """Add the given message to this transport's queue. This method also handles ACKing any WRTE messages. Args: message: The AdbMessage to enqueue. timeout: The timeout to use for the operation. Specifically, WRTE messages cause an OKAY to be ...
python
def enqueue_message(self, message, timeout): """Add the given message to this transport's queue. This method also handles ACKing any WRTE messages. Args: message: The AdbMessage to enqueue. timeout: The timeout to use for the operation. Specifically, WRTE messages cause an OKAY to be ...
[ "def", "enqueue_message", "(", "self", ",", "message", ",", "timeout", ")", ":", "# Ack WRTE messages immediately, handle our OPEN ack if it gets enqueued.", "if", "message", ".", "command", "==", "'WRTE'", ":", "self", ".", "_send_command", "(", "'OKAY'", ",", "timeo...
Add the given message to this transport's queue. This method also handles ACKing any WRTE messages. Args: message: The AdbMessage to enqueue. timeout: The timeout to use for the operation. Specifically, WRTE messages cause an OKAY to be sent; timeout is used for that send.
[ "Add", "the", "given", "message", "to", "this", "transport", "s", "queue", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/plugs/usb/adb_protocol.py#L440-L455
226,947
google/openhtf
openhtf/plugs/usb/adb_protocol.py
AdbStreamTransport.write
def write(self, data, timeout): """Write data to this stream, using the given timeouts.PolledTimeout.""" if not self.remote_id: raise usb_exceptions.AdbStreamClosedError( 'Cannot write() to half-opened %s', self) if self.closed_state != self.ClosedState.OPEN: raise usb_exceptions.AdbSt...
python
def write(self, data, timeout): """Write data to this stream, using the given timeouts.PolledTimeout.""" if not self.remote_id: raise usb_exceptions.AdbStreamClosedError( 'Cannot write() to half-opened %s', self) if self.closed_state != self.ClosedState.OPEN: raise usb_exceptions.AdbSt...
[ "def", "write", "(", "self", ",", "data", ",", "timeout", ")", ":", "if", "not", "self", ".", "remote_id", ":", "raise", "usb_exceptions", ".", "AdbStreamClosedError", "(", "'Cannot write() to half-opened %s'", ",", "self", ")", "if", "self", ".", "closed_stat...
Write data to this stream, using the given timeouts.PolledTimeout.
[ "Write", "data", "to", "this", "stream", "using", "the", "given", "timeouts", ".", "PolledTimeout", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/plugs/usb/adb_protocol.py#L457-L474
226,948
google/openhtf
openhtf/plugs/usb/adb_protocol.py
AdbStreamTransport.read
def read(self, length, timeout): """Read 'length' bytes from this stream transport. Args: length: If not 0, read this many bytes from the stream, otherwise read all available data (at least one byte). timeout: timeouts.PolledTimeout to use for this read operation. Returns: The by...
python
def read(self, length, timeout): """Read 'length' bytes from this stream transport. Args: length: If not 0, read this many bytes from the stream, otherwise read all available data (at least one byte). timeout: timeouts.PolledTimeout to use for this read operation. Returns: The by...
[ "def", "read", "(", "self", ",", "length", ",", "timeout", ")", ":", "self", ".", "_read_messages_until_true", "(", "lambda", ":", "self", ".", "_buffer_size", "and", "self", ".", "_buffer_size", ">=", "length", ",", "timeout", ")", "with", "self", ".", ...
Read 'length' bytes from this stream transport. Args: length: If not 0, read this many bytes from the stream, otherwise read all available data (at least one byte). timeout: timeouts.PolledTimeout to use for this read operation. Returns: The bytes read from this stream.
[ "Read", "length", "bytes", "from", "this", "stream", "transport", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/plugs/usb/adb_protocol.py#L476-L498
226,949
google/openhtf
openhtf/plugs/usb/adb_protocol.py
AdbConnection._make_stream_transport
def _make_stream_transport(self): """Create an AdbStreamTransport with a newly allocated local_id.""" msg_queue = queue.Queue() with self._stream_transport_map_lock: # Start one past the last id we used, and grab the first available one. # This mimics the ADB behavior of 'increment an unsigned a...
python
def _make_stream_transport(self): """Create an AdbStreamTransport with a newly allocated local_id.""" msg_queue = queue.Queue() with self._stream_transport_map_lock: # Start one past the last id we used, and grab the first available one. # This mimics the ADB behavior of 'increment an unsigned a...
[ "def", "_make_stream_transport", "(", "self", ")", ":", "msg_queue", "=", "queue", ".", "Queue", "(", ")", "with", "self", ".", "_stream_transport_map_lock", ":", "# Start one past the last id we used, and grab the first available one.", "# This mimics the ADB behavior of 'incr...
Create an AdbStreamTransport with a newly allocated local_id.
[ "Create", "an", "AdbStreamTransport", "with", "a", "newly", "allocated", "local_id", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/plugs/usb/adb_protocol.py#L568-L594
226,950
google/openhtf
openhtf/plugs/usb/adb_protocol.py
AdbConnection._handle_message_for_stream
def _handle_message_for_stream(self, stream_transport, message, timeout): """Handle an incoming message, check if it's for the given stream. If the message is not for the stream, then add it to the appropriate message queue. Args: stream_transport: AdbStreamTransport currently waiting on a messa...
python
def _handle_message_for_stream(self, stream_transport, message, timeout): """Handle an incoming message, check if it's for the given stream. If the message is not for the stream, then add it to the appropriate message queue. Args: stream_transport: AdbStreamTransport currently waiting on a messa...
[ "def", "_handle_message_for_stream", "(", "self", ",", "stream_transport", ",", "message", ",", "timeout", ")", ":", "if", "message", ".", "command", "not", "in", "(", "'OKAY'", ",", "'CLSE'", ",", "'WRTE'", ")", ":", "raise", "usb_exceptions", ".", "AdbProt...
Handle an incoming message, check if it's for the given stream. If the message is not for the stream, then add it to the appropriate message queue. Args: stream_transport: AdbStreamTransport currently waiting on a message. message: Message to check and handle. timeout: Timeout to use for...
[ "Handle", "an", "incoming", "message", "check", "if", "it", "s", "for", "the", "given", "stream", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/plugs/usb/adb_protocol.py#L596-L642
226,951
google/openhtf
openhtf/plugs/usb/adb_protocol.py
AdbConnection.open_stream
def open_stream(self, destination, timeout_ms=None): """Opens a new stream to a destination service on the device. Not the same as the posix 'open' or any other Open methods, this corresponds to the OPEN message described in the ADB protocol documentation mentioned above. It creates a stream (uniquely...
python
def open_stream(self, destination, timeout_ms=None): """Opens a new stream to a destination service on the device. Not the same as the posix 'open' or any other Open methods, this corresponds to the OPEN message described in the ADB protocol documentation mentioned above. It creates a stream (uniquely...
[ "def", "open_stream", "(", "self", ",", "destination", ",", "timeout_ms", "=", "None", ")", ":", "timeout", "=", "timeouts", ".", "PolledTimeout", ".", "from_millis", "(", "timeout_ms", ")", "stream_transport", "=", "self", ".", "_make_stream_transport", "(", ...
Opens a new stream to a destination service on the device. Not the same as the posix 'open' or any other Open methods, this corresponds to the OPEN message described in the ADB protocol documentation mentioned above. It creates a stream (uniquely identified by remote/local ids) that connects to a part...
[ "Opens", "a", "new", "stream", "to", "a", "destination", "service", "on", "the", "device", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/plugs/usb/adb_protocol.py#L648-L680
226,952
google/openhtf
openhtf/plugs/usb/adb_protocol.py
AdbConnection.close_stream_transport
def close_stream_transport(self, stream_transport, timeout): """Remove the given stream transport's id from our map of id's. If the stream id is actually removed, we send a CLSE message to let the remote end know (this happens when we are ack'ing a CLSE message we received). The ADB protocol doesn't s...
python
def close_stream_transport(self, stream_transport, timeout): """Remove the given stream transport's id from our map of id's. If the stream id is actually removed, we send a CLSE message to let the remote end know (this happens when we are ack'ing a CLSE message we received). The ADB protocol doesn't s...
[ "def", "close_stream_transport", "(", "self", ",", "stream_transport", ",", "timeout", ")", ":", "with", "self", ".", "_stream_transport_map_lock", ":", "if", "stream_transport", ".", "local_id", "in", "self", ".", "_stream_transport_map", ":", "del", "self", ".",...
Remove the given stream transport's id from our map of id's. If the stream id is actually removed, we send a CLSE message to let the remote end know (this happens when we are ack'ing a CLSE message we received). The ADB protocol doesn't say this is a requirement, but ADB does it, so we do too. Ar...
[ "Remove", "the", "given", "stream", "transport", "s", "id", "from", "our", "map", "of", "id", "s", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/plugs/usb/adb_protocol.py#L682-L707
226,953
google/openhtf
openhtf/plugs/usb/adb_protocol.py
AdbConnection.streaming_command
def streaming_command(self, service, command='', timeout_ms=None): """One complete set of packets for a single command. Helper function to call open_stream and yield the output. Sends service:command in a new connection, reading the data for the response. All the data is held in memory, large response...
python
def streaming_command(self, service, command='', timeout_ms=None): """One complete set of packets for a single command. Helper function to call open_stream and yield the output. Sends service:command in a new connection, reading the data for the response. All the data is held in memory, large response...
[ "def", "streaming_command", "(", "self", ",", "service", ",", "command", "=", "''", ",", "timeout_ms", "=", "None", ")", ":", "timeout", "=", "timeouts", ".", "PolledTimeout", ".", "from_millis", "(", "timeout_ms", ")", "stream", "=", "self", ".", "open_st...
One complete set of packets for a single command. Helper function to call open_stream and yield the output. Sends service:command in a new connection, reading the data for the response. All the data is held in memory, large responses will be slow and can fill up memory. Args: service: The s...
[ "One", "complete", "set", "of", "packets", "for", "a", "single", "command", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/plugs/usb/adb_protocol.py#L709-L732
226,954
google/openhtf
openhtf/plugs/usb/adb_protocol.py
AdbConnection.read_for_stream
def read_for_stream(self, stream_transport, timeout_ms=None): """Attempt to read a packet for the given stream transport. Will read packets from self.transport until one intended for the given AdbStream is found. If another thread is already reading packets, this will block until that thread reads a p...
python
def read_for_stream(self, stream_transport, timeout_ms=None): """Attempt to read a packet for the given stream transport. Will read packets from self.transport until one intended for the given AdbStream is found. If another thread is already reading packets, this will block until that thread reads a p...
[ "def", "read_for_stream", "(", "self", ",", "stream_transport", ",", "timeout_ms", "=", "None", ")", ":", "timeout", "=", "timeouts", ".", "PolledTimeout", ".", "from_millis", "(", "timeout_ms", ")", "# Bail when the timeout expires, or when we no longer have the given st...
Attempt to read a packet for the given stream transport. Will read packets from self.transport until one intended for the given AdbStream is found. If another thread is already reading packets, this will block until that thread reads a packet for this stream, or timeout expires. Note that this method ...
[ "Attempt", "to", "read", "a", "packet", "for", "the", "given", "stream", "transport", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/plugs/usb/adb_protocol.py#L734-L823
226,955
google/openhtf
openhtf/plugs/usb/adb_protocol.py
AdbConnection.connect
def connect(cls, transport, rsa_keys=None, timeout_ms=1000, auth_timeout_ms=100): """Establish a new connection to a device, connected via transport. Args: transport: A transport to use for reads/writes from/to the device, usually an instance of UsbHandle, but really it can be anyth...
python
def connect(cls, transport, rsa_keys=None, timeout_ms=1000, auth_timeout_ms=100): """Establish a new connection to a device, connected via transport. Args: transport: A transport to use for reads/writes from/to the device, usually an instance of UsbHandle, but really it can be anyth...
[ "def", "connect", "(", "cls", ",", "transport", ",", "rsa_keys", "=", "None", ",", "timeout_ms", "=", "1000", ",", "auth_timeout_ms", "=", "100", ")", ":", "timeout", "=", "timeouts", ".", "PolledTimeout", ".", "from_millis", "(", "timeout_ms", ")", "if", ...
Establish a new connection to a device, connected via transport. Args: transport: A transport to use for reads/writes from/to the device, usually an instance of UsbHandle, but really it can be anything with read() and write() methods. rsa_keys: List of AuthSigner subclass instances to b...
[ "Establish", "a", "new", "connection", "to", "a", "device", "connected", "via", "transport", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/plugs/usb/adb_protocol.py#L826-L912
226,956
google/openhtf
examples/example_plugs.py
ExamplePlug.increment
def increment(self): """Increment our value, return the previous value.""" self.value += self.increment_size return self.value - self.increment_size
python
def increment(self): """Increment our value, return the previous value.""" self.value += self.increment_size return self.value - self.increment_size
[ "def", "increment", "(", "self", ")", ":", "self", ".", "value", "+=", "self", ".", "increment_size", "return", "self", ".", "value", "-", "self", ".", "increment_size" ]
Increment our value, return the previous value.
[ "Increment", "our", "value", "return", "the", "previous", "value", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/examples/example_plugs.py#L76-L79
226,957
google/openhtf
openhtf/plugs/__init__.py
plug
def plug(update_kwargs=True, **plugs_map): """Creates a decorator that passes in plugs when invoked. This function returns a decorator for a function that will replace positional arguments to that function with the plugs specified. See the module docstring for details and examples. Note this decorator does...
python
def plug(update_kwargs=True, **plugs_map): """Creates a decorator that passes in plugs when invoked. This function returns a decorator for a function that will replace positional arguments to that function with the plugs specified. See the module docstring for details and examples. Note this decorator does...
[ "def", "plug", "(", "update_kwargs", "=", "True", ",", "*", "*", "plugs_map", ")", ":", "for", "a_plug", "in", "plugs_map", ".", "values", "(", ")", ":", "if", "not", "(", "isinstance", "(", "a_plug", ",", "PlugPlaceholder", ")", "or", "issubclass", "(...
Creates a decorator that passes in plugs when invoked. This function returns a decorator for a function that will replace positional arguments to that function with the plugs specified. See the module docstring for details and examples. Note this decorator does not work with class or bound methods, but does ...
[ "Creates", "a", "decorator", "that", "passes", "in", "plugs", "when", "invoked", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/plugs/__init__.py#L217-L269
226,958
google/openhtf
openhtf/plugs/__init__.py
BasePlug.uses_base_tear_down
def uses_base_tear_down(cls): """Checks whether the tearDown method is the BasePlug implementation.""" this_tear_down = getattr(cls, 'tearDown') base_tear_down = getattr(BasePlug, 'tearDown') return this_tear_down.__code__ is base_tear_down.__code__
python
def uses_base_tear_down(cls): """Checks whether the tearDown method is the BasePlug implementation.""" this_tear_down = getattr(cls, 'tearDown') base_tear_down = getattr(BasePlug, 'tearDown') return this_tear_down.__code__ is base_tear_down.__code__
[ "def", "uses_base_tear_down", "(", "cls", ")", ":", "this_tear_down", "=", "getattr", "(", "cls", ",", "'tearDown'", ")", "base_tear_down", "=", "getattr", "(", "BasePlug", ",", "'tearDown'", ")", "return", "this_tear_down", ".", "__code__", "is", "base_tear_dow...
Checks whether the tearDown method is the BasePlug implementation.
[ "Checks", "whether", "the", "tearDown", "method", "is", "the", "BasePlug", "implementation", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/plugs/__init__.py#L196-L200
226,959
google/openhtf
openhtf/plugs/__init__.py
PlugManager.get_plug_mro
def get_plug_mro(self, plug_type): """Returns a list of names identifying the plug classes in the plug's MRO. For example: ['openhtf.plugs.user_input.UserInput'] Or: ['openhtf.plugs.user_input.UserInput', 'my_module.advanced_user_input.AdvancedUserInput'] """ ignored_classe...
python
def get_plug_mro(self, plug_type): """Returns a list of names identifying the plug classes in the plug's MRO. For example: ['openhtf.plugs.user_input.UserInput'] Or: ['openhtf.plugs.user_input.UserInput', 'my_module.advanced_user_input.AdvancedUserInput'] """ ignored_classe...
[ "def", "get_plug_mro", "(", "self", ",", "plug_type", ")", ":", "ignored_classes", "=", "(", "BasePlug", ",", "FrontendAwareBasePlug", ")", "return", "[", "self", ".", "get_plug_name", "(", "base_class", ")", "for", "base_class", "in", "plug_type", ".", "mro",...
Returns a list of names identifying the plug classes in the plug's MRO. For example: ['openhtf.plugs.user_input.UserInput'] Or: ['openhtf.plugs.user_input.UserInput', 'my_module.advanced_user_input.AdvancedUserInput']
[ "Returns", "a", "list", "of", "names", "identifying", "the", "plug", "classes", "in", "the", "plug", "s", "MRO", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/plugs/__init__.py#L338-L352
226,960
google/openhtf
openhtf/plugs/__init__.py
PlugManager.initialize_plugs
def initialize_plugs(self, plug_types=None): """Instantiate required plugs. Instantiates plug types and saves the instances in self._plugs_by_type for use in provide_plugs(). Args: plug_types: Plug types may be specified here rather than passed into the constructor (this is use...
python
def initialize_plugs(self, plug_types=None): """Instantiate required plugs. Instantiates plug types and saves the instances in self._plugs_by_type for use in provide_plugs(). Args: plug_types: Plug types may be specified here rather than passed into the constructor (this is use...
[ "def", "initialize_plugs", "(", "self", ",", "plug_types", "=", "None", ")", ":", "types", "=", "plug_types", "if", "plug_types", "is", "not", "None", "else", "self", ".", "_plug_types", "for", "plug_type", "in", "types", ":", "# Create a logger for this plug. A...
Instantiate required plugs. Instantiates plug types and saves the instances in self._plugs_by_type for use in provide_plugs(). Args: plug_types: Plug types may be specified here rather than passed into the constructor (this is used primarily for unit testing phase...
[ "Instantiate", "required", "plugs", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/plugs/__init__.py#L362-L409
226,961
google/openhtf
openhtf/plugs/__init__.py
PlugManager.update_plug
def update_plug(self, plug_type, plug_value): """Update internal data stores with the given plug value for plug type. Safely tears down the old instance if one was already created, but that's generally not the case outside unittests. Also, we explicitly pass the plug_type rather than detecting it from...
python
def update_plug(self, plug_type, plug_value): """Update internal data stores with the given plug value for plug type. Safely tears down the old instance if one was already created, but that's generally not the case outside unittests. Also, we explicitly pass the plug_type rather than detecting it from...
[ "def", "update_plug", "(", "self", ",", "plug_type", ",", "plug_value", ")", ":", "self", ".", "_plug_types", ".", "add", "(", "plug_type", ")", "if", "plug_type", "in", "self", ".", "_plugs_by_type", ":", "self", ".", "_plugs_by_type", "[", "plug_type", "...
Update internal data stores with the given plug value for plug type. Safely tears down the old instance if one was already created, but that's generally not the case outside unittests. Also, we explicitly pass the plug_type rather than detecting it from plug_value to allow unittests to override plugs ...
[ "Update", "internal", "data", "stores", "with", "the", "given", "plug", "value", "for", "plug", "type", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/plugs/__init__.py#L425-L442
226,962
google/openhtf
openhtf/plugs/__init__.py
PlugManager.wait_for_plug_update
def wait_for_plug_update(self, plug_name, remote_state, timeout_s): """Wait for a change in the state of a frontend-aware plug. Args: plug_name: Plug name, e.g. 'openhtf.plugs.user_input.UserInput'. remote_state: The last observed state. timeout_s: Number of seconds to wait for an update. ...
python
def wait_for_plug_update(self, plug_name, remote_state, timeout_s): """Wait for a change in the state of a frontend-aware plug. Args: plug_name: Plug name, e.g. 'openhtf.plugs.user_input.UserInput'. remote_state: The last observed state. timeout_s: Number of seconds to wait for an update. ...
[ "def", "wait_for_plug_update", "(", "self", ",", "plug_name", ",", "remote_state", ",", "timeout_s", ")", ":", "plug", "=", "self", ".", "_plugs_by_name", ".", "get", "(", "plug_name", ")", "if", "plug", "is", "None", ":", "raise", "InvalidPlugError", "(", ...
Wait for a change in the state of a frontend-aware plug. Args: plug_name: Plug name, e.g. 'openhtf.plugs.user_input.UserInput'. remote_state: The last observed state. timeout_s: Number of seconds to wait for an update. Returns: An updated state, or None if the timeout runs out. Ra...
[ "Wait", "for", "a", "change", "in", "the", "state", "of", "a", "frontend", "-", "aware", "plug", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/plugs/__init__.py#L477-L506
226,963
google/openhtf
openhtf/plugs/__init__.py
PlugManager.get_frontend_aware_plug_names
def get_frontend_aware_plug_names(self): """Returns the names of frontend-aware plugs.""" return [name for name, plug in six.iteritems(self._plugs_by_name) if isinstance(plug, FrontendAwareBasePlug)]
python
def get_frontend_aware_plug_names(self): """Returns the names of frontend-aware plugs.""" return [name for name, plug in six.iteritems(self._plugs_by_name) if isinstance(plug, FrontendAwareBasePlug)]
[ "def", "get_frontend_aware_plug_names", "(", "self", ")", ":", "return", "[", "name", "for", "name", ",", "plug", "in", "six", ".", "iteritems", "(", "self", ".", "_plugs_by_name", ")", "if", "isinstance", "(", "plug", ",", "FrontendAwareBasePlug", ")", "]" ...
Returns the names of frontend-aware plugs.
[ "Returns", "the", "names", "of", "frontend", "-", "aware", "plugs", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/plugs/__init__.py#L508-L511
226,964
google/openhtf
openhtf/output/servers/station_server.py
_wait_for_any_event
def _wait_for_any_event(events, timeout_s): """Wait for any in a list of threading.Event's to be set. Args: events: List of threading.Event's. timeout_s: Max duration in seconds to wait before returning. Returns: True if at least one event was set before the timeout expired, else False. """ de...
python
def _wait_for_any_event(events, timeout_s): """Wait for any in a list of threading.Event's to be set. Args: events: List of threading.Event's. timeout_s: Max duration in seconds to wait before returning. Returns: True if at least one event was set before the timeout expired, else False. """ de...
[ "def", "_wait_for_any_event", "(", "events", ",", "timeout_s", ")", ":", "def", "any_event_set", "(", ")", ":", "return", "any", "(", "event", ".", "is_set", "(", ")", "for", "event", "in", "events", ")", "result", "=", "timeouts", ".", "loop_until_timeout...
Wait for any in a list of threading.Event's to be set. Args: events: List of threading.Event's. timeout_s: Max duration in seconds to wait before returning. Returns: True if at least one event was set before the timeout expired, else False.
[ "Wait", "for", "any", "in", "a", "list", "of", "threading", ".", "Event", "s", "to", "be", "set", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/output/servers/station_server.py#L119-L135
226,965
google/openhtf
openhtf/output/servers/station_server.py
StationWatcher._poll_for_update
def _poll_for_update(self): """Call the callback with the current test state, then wait for a change.""" test, test_state = _get_executing_test() if test is None: time.sleep(_WAIT_FOR_EXECUTING_TEST_POLL_S) return state_dict, event = self._to_dict_with_event(test_state) self._update_ca...
python
def _poll_for_update(self): """Call the callback with the current test state, then wait for a change.""" test, test_state = _get_executing_test() if test is None: time.sleep(_WAIT_FOR_EXECUTING_TEST_POLL_S) return state_dict, event = self._to_dict_with_event(test_state) self._update_ca...
[ "def", "_poll_for_update", "(", "self", ")", ":", "test", ",", "test_state", "=", "_get_executing_test", "(", ")", "if", "test", "is", "None", ":", "time", ".", "sleep", "(", "_WAIT_FOR_EXECUTING_TEST_POLL_S", ")", "return", "state_dict", ",", "event", "=", ...
Call the callback with the current test state, then wait for a change.
[ "Call", "the", "callback", "with", "the", "current", "test", "state", "then", "wait", "for", "a", "change", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/output/servers/station_server.py#L176-L199
226,966
google/openhtf
openhtf/output/servers/station_server.py
StationWatcher._to_dict_with_event
def _to_dict_with_event(cls, test_state): """Process a test state into the format we want to send to the frontend.""" original_dict, event = test_state.asdict_with_event() # This line may produce a 'dictionary changed size during iteration' error. test_state_dict = data.convert_to_base_types(original_d...
python
def _to_dict_with_event(cls, test_state): """Process a test state into the format we want to send to the frontend.""" original_dict, event = test_state.asdict_with_event() # This line may produce a 'dictionary changed size during iteration' error. test_state_dict = data.convert_to_base_types(original_d...
[ "def", "_to_dict_with_event", "(", "cls", ",", "test_state", ")", ":", "original_dict", ",", "event", "=", "test_state", ".", "asdict_with_event", "(", ")", "# This line may produce a 'dictionary changed size during iteration' error.", "test_state_dict", "=", "data", ".", ...
Process a test state into the format we want to send to the frontend.
[ "Process", "a", "test", "state", "into", "the", "format", "we", "want", "to", "send", "to", "the", "frontend", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/output/servers/station_server.py#L202-L210
226,967
google/openhtf
openhtf/util/threads.py
_safe_lock_release_py2
def _safe_lock_release_py2(rlock): """Ensure that a threading.RLock is fully released for Python 2. The RLock release code is: https://github.com/python/cpython/blob/2.7/Lib/threading.py#L187 The RLock object's release method does not release all of its state if an exception is raised in the middle of its...
python
def _safe_lock_release_py2(rlock): """Ensure that a threading.RLock is fully released for Python 2. The RLock release code is: https://github.com/python/cpython/blob/2.7/Lib/threading.py#L187 The RLock object's release method does not release all of its state if an exception is raised in the middle of its...
[ "def", "_safe_lock_release_py2", "(", "rlock", ")", ":", "assert", "isinstance", "(", "rlock", ",", "threading", ".", "_RLock", ")", "ident", "=", "_thread", ".", "get_ident", "(", ")", "expected_count", "=", "0", "if", "rlock", ".", "_RLock__owner", "==", ...
Ensure that a threading.RLock is fully released for Python 2. The RLock release code is: https://github.com/python/cpython/blob/2.7/Lib/threading.py#L187 The RLock object's release method does not release all of its state if an exception is raised in the middle of its operation. There are three pieces of ...
[ "Ensure", "that", "a", "threading", ".", "RLock", "is", "fully", "released", "for", "Python", "2", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/util/threads.py#L54-L97
226,968
google/openhtf
openhtf/util/threads.py
loop
def loop(_=None, force=False): # pylint: disable=invalid-name """Causes a function to loop indefinitely.""" if not force: raise AttributeError( 'threads.loop() is DEPRECATED. If you really like this and want to ' 'keep it, file an issue at https://github.com/google/openhtf/issues ' 'a...
python
def loop(_=None, force=False): # pylint: disable=invalid-name """Causes a function to loop indefinitely.""" if not force: raise AttributeError( 'threads.loop() is DEPRECATED. If you really like this and want to ' 'keep it, file an issue at https://github.com/google/openhtf/issues ' 'a...
[ "def", "loop", "(", "_", "=", "None", ",", "force", "=", "False", ")", ":", "# pylint: disable=invalid-name", "if", "not", "force", ":", "raise", "AttributeError", "(", "'threads.loop() is DEPRECATED. If you really like this and want to '", "'keep it, file an issue at http...
Causes a function to loop indefinitely.
[ "Causes", "a", "function", "to", "loop", "indefinitely", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/util/threads.py#L101-L118
226,969
google/openhtf
openhtf/util/threads.py
synchronized
def synchronized(func): # pylint: disable=invalid-name """Hold self._lock while executing func.""" @functools.wraps(func) def synchronized_method(self, *args, **kwargs): """Wrapper to return.""" if not hasattr(self, '_lock'): if func.__name__ in type(self).__dict__: hint = '' else: ...
python
def synchronized(func): # pylint: disable=invalid-name """Hold self._lock while executing func.""" @functools.wraps(func) def synchronized_method(self, *args, **kwargs): """Wrapper to return.""" if not hasattr(self, '_lock'): if func.__name__ in type(self).__dict__: hint = '' else: ...
[ "def", "synchronized", "(", "func", ")", ":", "# pylint: disable=invalid-name", "@", "functools", ".", "wraps", "(", "func", ")", "def", "synchronized_method", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "\"\"\"Wrapper to return.\"\"\"", ...
Hold self._lock while executing func.
[ "Hold", "self", ".", "_lock", "while", "executing", "func", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/util/threads.py#L241-L257
226,970
google/openhtf
openhtf/util/threads.py
KillableThread.kill
def kill(self): """Terminates the current thread by raising an error.""" self._killed.set() if not self.is_alive(): logging.debug('Cannot kill thread that is no longer running.') return if not self._is_thread_proc_running(): logging.debug("Thread's _thread_proc function is no longer ru...
python
def kill(self): """Terminates the current thread by raising an error.""" self._killed.set() if not self.is_alive(): logging.debug('Cannot kill thread that is no longer running.') return if not self._is_thread_proc_running(): logging.debug("Thread's _thread_proc function is no longer ru...
[ "def", "kill", "(", "self", ")", ":", "self", ".", "_killed", ".", "set", "(", ")", "if", "not", "self", ".", "is_alive", "(", ")", ":", "logging", ".", "debug", "(", "'Cannot kill thread that is no longer running.'", ")", "return", "if", "not", "self", ...
Terminates the current thread by raising an error.
[ "Terminates", "the", "current", "thread", "by", "raising", "an", "error", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/util/threads.py#L193-L203
226,971
google/openhtf
openhtf/util/threads.py
KillableThread.async_raise
def async_raise(self, exc_type): """Raise the exception.""" # Should only be called on a started thread, so raise otherwise. assert self.ident is not None, 'Only started threads have thread identifier' # If the thread has died we don't want to raise an exception so log. if not self.is_alive(): ...
python
def async_raise(self, exc_type): """Raise the exception.""" # Should only be called on a started thread, so raise otherwise. assert self.ident is not None, 'Only started threads have thread identifier' # If the thread has died we don't want to raise an exception so log. if not self.is_alive(): ...
[ "def", "async_raise", "(", "self", ",", "exc_type", ")", ":", "# Should only be called on a started thread, so raise otherwise.", "assert", "self", ".", "ident", "is", "not", "None", ",", "'Only started threads have thread identifier'", "# If the thread has died we don't want to ...
Raise the exception.
[ "Raise", "the", "exception", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/util/threads.py#L205-L225
226,972
google/openhtf
openhtf/util/logs.py
get_record_logger_for
def get_record_logger_for(test_uid): """Return the child logger associated with the specified test UID.""" htf_logger = logging.getLogger(RECORD_LOGGER_PREFIX) record_logger = HtfTestLogger('.'.join(((RECORD_LOGGER_PREFIX, test_uid)))) record_logger.parent = htf_logger return record_logger
python
def get_record_logger_for(test_uid): """Return the child logger associated with the specified test UID.""" htf_logger = logging.getLogger(RECORD_LOGGER_PREFIX) record_logger = HtfTestLogger('.'.join(((RECORD_LOGGER_PREFIX, test_uid)))) record_logger.parent = htf_logger return record_logger
[ "def", "get_record_logger_for", "(", "test_uid", ")", ":", "htf_logger", "=", "logging", ".", "getLogger", "(", "RECORD_LOGGER_PREFIX", ")", "record_logger", "=", "HtfTestLogger", "(", "'.'", ".", "join", "(", "(", "(", "RECORD_LOGGER_PREFIX", ",", "test_uid", "...
Return the child logger associated with the specified test UID.
[ "Return", "the", "child", "logger", "associated", "with", "the", "specified", "test", "UID", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/util/logs.py#L161-L166
226,973
google/openhtf
openhtf/util/logs.py
initialize_record_handler
def initialize_record_handler(test_uid, test_record, notify_update): """Initialize the record handler for a test. For each running test, we attach a record handler to the top-level OpenHTF logger. The handler will append OpenHTF logs to the test record, while filtering out logs that are specific to any other t...
python
def initialize_record_handler(test_uid, test_record, notify_update): """Initialize the record handler for a test. For each running test, we attach a record handler to the top-level OpenHTF logger. The handler will append OpenHTF logs to the test record, while filtering out logs that are specific to any other t...
[ "def", "initialize_record_handler", "(", "test_uid", ",", "test_record", ",", "notify_update", ")", ":", "htf_logger", "=", "logging", ".", "getLogger", "(", "LOGGER_PREFIX", ")", "htf_logger", ".", "addHandler", "(", "RecordHandler", "(", "test_uid", ",", "test_r...
Initialize the record handler for a test. For each running test, we attach a record handler to the top-level OpenHTF logger. The handler will append OpenHTF logs to the test record, while filtering out logs that are specific to any other test run.
[ "Initialize", "the", "record", "handler", "for", "a", "test", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/util/logs.py#L169-L177
226,974
google/openhtf
openhtf/util/logs.py
log_once
def log_once(log_func, msg, *args, **kwargs): """"Logs a message only once.""" if msg not in _LOG_ONCE_SEEN: log_func(msg, *args, **kwargs) # Key on the message, ignoring args. This should fit most use cases. _LOG_ONCE_SEEN.add(msg)
python
def log_once(log_func, msg, *args, **kwargs): """"Logs a message only once.""" if msg not in _LOG_ONCE_SEEN: log_func(msg, *args, **kwargs) # Key on the message, ignoring args. This should fit most use cases. _LOG_ONCE_SEEN.add(msg)
[ "def", "log_once", "(", "log_func", ",", "msg", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "msg", "not", "in", "_LOG_ONCE_SEEN", ":", "log_func", "(", "msg", ",", "*", "args", ",", "*", "*", "kwargs", ")", "# Key on the message, ignorin...
Logs a message only once.
[ "Logs", "a", "message", "only", "once", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/util/logs.py#L188-L193
226,975
google/openhtf
openhtf/util/logs.py
configure_logging
def configure_logging(): """One-time initialization of loggers. See module docstring for more info.""" # Define the top-level logger. htf_logger = logging.getLogger(LOGGER_PREFIX) htf_logger.propagate = False htf_logger.setLevel(logging.DEBUG) # By default, don't print any logs to the CLI. if CLI_LOGGIN...
python
def configure_logging(): """One-time initialization of loggers. See module docstring for more info.""" # Define the top-level logger. htf_logger = logging.getLogger(LOGGER_PREFIX) htf_logger.propagate = False htf_logger.setLevel(logging.DEBUG) # By default, don't print any logs to the CLI. if CLI_LOGGIN...
[ "def", "configure_logging", "(", ")", ":", "# Define the top-level logger.", "htf_logger", "=", "logging", ".", "getLogger", "(", "LOGGER_PREFIX", ")", "htf_logger", ".", "propagate", "=", "False", "htf_logger", ".", "setLevel", "(", "logging", ".", "DEBUG", ")", ...
One-time initialization of loggers. See module docstring for more info.
[ "One", "-", "time", "initialization", "of", "loggers", ".", "See", "module", "docstring", "for", "more", "info", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/util/logs.py#L319-L346
226,976
google/openhtf
openhtf/util/logs.py
RecordHandler.emit
def emit(self, record): """Save a logging.LogRecord to our test record. Logs carry useful metadata such as the logger name and level information. We capture this in a structured format in the test record to enable filtering by client applications. Args: record: A logging.LogRecord to record....
python
def emit(self, record): """Save a logging.LogRecord to our test record. Logs carry useful metadata such as the logger name and level information. We capture this in a structured format in the test record to enable filtering by client applications. Args: record: A logging.LogRecord to record....
[ "def", "emit", "(", "self", ",", "record", ")", ":", "try", ":", "message", "=", "self", ".", "format", "(", "record", ")", "log_record", "=", "LogRecord", "(", "record", ".", "levelno", ",", "record", ".", "name", ",", "os", ".", "path", ".", "bas...
Save a logging.LogRecord to our test record. Logs carry useful metadata such as the logger name and level information. We capture this in a structured format in the test record to enable filtering by client applications. Args: record: A logging.LogRecord to record.
[ "Save", "a", "logging", ".", "LogRecord", "to", "our", "test", "record", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/util/logs.py#L269-L288
226,977
google/openhtf
openhtf/util/logs.py
CliFormatter.format
def format(self, record): """Format the record as tersely as possible but preserve info.""" super(CliFormatter, self).format(record) localized_time = datetime.datetime.fromtimestamp(record.created) terse_time = localized_time.strftime(u'%H:%M:%S') terse_level = record.levelname[0] terse_name = r...
python
def format(self, record): """Format the record as tersely as possible but preserve info.""" super(CliFormatter, self).format(record) localized_time = datetime.datetime.fromtimestamp(record.created) terse_time = localized_time.strftime(u'%H:%M:%S') terse_level = record.levelname[0] terse_name = r...
[ "def", "format", "(", "self", ",", "record", ")", ":", "super", "(", "CliFormatter", ",", "self", ")", ".", "format", "(", "record", ")", "localized_time", "=", "datetime", ".", "datetime", ".", "fromtimestamp", "(", "record", ".", "created", ")", "terse...
Format the record as tersely as possible but preserve info.
[ "Format", "the", "record", "as", "tersely", "as", "possible", "but", "preserve", "info", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/util/logs.py#L294-L315
226,978
google/openhtf
openhtf/output/callbacks/mfg_inspector.py
_send_mfg_inspector_request
def _send_mfg_inspector_request(envelope_data, credentials, destination_url): """Send upload http request. Intended to be run in retry loop.""" logging.info('Uploading result...') http = httplib2.Http() if credentials.access_token_expired: credentials.refresh(http) credentials.authorize(http) resp, c...
python
def _send_mfg_inspector_request(envelope_data, credentials, destination_url): """Send upload http request. Intended to be run in retry loop.""" logging.info('Uploading result...') http = httplib2.Http() if credentials.access_token_expired: credentials.refresh(http) credentials.authorize(http) resp, c...
[ "def", "_send_mfg_inspector_request", "(", "envelope_data", ",", "credentials", ",", "destination_url", ")", ":", "logging", ".", "info", "(", "'Uploading result...'", ")", "http", "=", "httplib2", ".", "Http", "(", ")", "if", "credentials", ".", "access_token_exp...
Send upload http request. Intended to be run in retry loop.
[ "Send", "upload", "http", "request", ".", "Intended", "to", "be", "run", "in", "retry", "loop", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/output/callbacks/mfg_inspector.py#L27-L48
226,979
google/openhtf
openhtf/output/callbacks/mfg_inspector.py
send_mfg_inspector_data
def send_mfg_inspector_data(inspector_proto, credentials, destination_url): """Upload MfgEvent to steam_engine.""" envelope = guzzle_pb2.TestRunEnvelope() envelope.payload = zlib.compress(inspector_proto.SerializeToString()) envelope.payload_type = guzzle_pb2.COMPRESSED_MFG_EVENT envelope_data = envelope.Seri...
python
def send_mfg_inspector_data(inspector_proto, credentials, destination_url): """Upload MfgEvent to steam_engine.""" envelope = guzzle_pb2.TestRunEnvelope() envelope.payload = zlib.compress(inspector_proto.SerializeToString()) envelope.payload_type = guzzle_pb2.COMPRESSED_MFG_EVENT envelope_data = envelope.Seri...
[ "def", "send_mfg_inspector_data", "(", "inspector_proto", ",", "credentials", ",", "destination_url", ")", ":", "envelope", "=", "guzzle_pb2", ".", "TestRunEnvelope", "(", ")", "envelope", ".", "payload", "=", "zlib", ".", "compress", "(", "inspector_proto", ".", ...
Upload MfgEvent to steam_engine.
[ "Upload", "MfgEvent", "to", "steam_engine", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/output/callbacks/mfg_inspector.py#L51-L69
226,980
google/openhtf
openhtf/output/callbacks/mfg_inspector.py
MfgInspector._convert
def _convert(self, test_record_obj): """Convert and cache a test record to a mfg-inspector proto.""" if self._cached_proto is None: self._cached_proto = self._converter(test_record_obj) return self._cached_proto
python
def _convert(self, test_record_obj): """Convert and cache a test record to a mfg-inspector proto.""" if self._cached_proto is None: self._cached_proto = self._converter(test_record_obj) return self._cached_proto
[ "def", "_convert", "(", "self", ",", "test_record_obj", ")", ":", "if", "self", ".", "_cached_proto", "is", "None", ":", "self", ".", "_cached_proto", "=", "self", ".", "_converter", "(", "test_record_obj", ")", "return", "self", ".", "_cached_proto" ]
Convert and cache a test record to a mfg-inspector proto.
[ "Convert", "and", "cache", "a", "test", "record", "to", "a", "mfg", "-", "inspector", "proto", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/output/callbacks/mfg_inspector.py#L174-L180
226,981
google/openhtf
openhtf/output/callbacks/mfg_inspector.py
MfgInspector.save_to_disk
def save_to_disk(self, filename_pattern=None): """Returns a callback to convert test record to proto and save to disk.""" if not self._converter: raise RuntimeError( 'Must set _converter on subclass or via set_converter before calling ' 'save_to_disk.') pattern = filename_pattern ...
python
def save_to_disk(self, filename_pattern=None): """Returns a callback to convert test record to proto and save to disk.""" if not self._converter: raise RuntimeError( 'Must set _converter on subclass or via set_converter before calling ' 'save_to_disk.') pattern = filename_pattern ...
[ "def", "save_to_disk", "(", "self", ",", "filename_pattern", "=", "None", ")", ":", "if", "not", "self", ".", "_converter", ":", "raise", "RuntimeError", "(", "'Must set _converter on subclass or via set_converter before calling '", "'save_to_disk.'", ")", "pattern", "=...
Returns a callback to convert test record to proto and save to disk.
[ "Returns", "a", "callback", "to", "convert", "test", "record", "to", "proto", "and", "save", "to", "disk", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/output/callbacks/mfg_inspector.py#L182-L202
226,982
google/openhtf
openhtf/output/callbacks/mfg_inspector.py
MfgInspector.upload
def upload(self): """Returns a callback to convert a test record to a proto and upload.""" if not self._converter: raise RuntimeError( 'Must set _converter on subclass or via set_converter before calling ' 'upload.') if not self.credentials: raise RuntimeError('Must provide ...
python
def upload(self): """Returns a callback to convert a test record to a proto and upload.""" if not self._converter: raise RuntimeError( 'Must set _converter on subclass or via set_converter before calling ' 'upload.') if not self.credentials: raise RuntimeError('Must provide ...
[ "def", "upload", "(", "self", ")", ":", "if", "not", "self", ".", "_converter", ":", "raise", "RuntimeError", "(", "'Must set _converter on subclass or via set_converter before calling '", "'upload.'", ")", "if", "not", "self", ".", "credentials", ":", "raise", "Run...
Returns a callback to convert a test record to a proto and upload.
[ "Returns", "a", "callback", "to", "convert", "a", "test", "record", "to", "a", "proto", "and", "upload", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/output/callbacks/mfg_inspector.py#L204-L219
226,983
google/openhtf
openhtf/plugs/usb/shell_service.py
AsyncCommandHandle._writer_thread_proc
def _writer_thread_proc(self, is_raw): """Write as long as the stream is not closed.""" # If we're not in raw mode, do line-buffered reads to play nicer with # potential interactive uses, max of MAX_ADB_DATA, since anything we write # to the stream will get packetized to that size anyway. # # Lo...
python
def _writer_thread_proc(self, is_raw): """Write as long as the stream is not closed.""" # If we're not in raw mode, do line-buffered reads to play nicer with # potential interactive uses, max of MAX_ADB_DATA, since anything we write # to the stream will get packetized to that size anyway. # # Lo...
[ "def", "_writer_thread_proc", "(", "self", ",", "is_raw", ")", ":", "# If we're not in raw mode, do line-buffered reads to play nicer with", "# potential interactive uses, max of MAX_ADB_DATA, since anything we write", "# to the stream will get packetized to that size anyway.", "#", "# Loop ...
Write as long as the stream is not closed.
[ "Write", "as", "long", "as", "the", "stream", "is", "not", "closed", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/plugs/usb/shell_service.py#L132-L143
226,984
google/openhtf
openhtf/plugs/usb/shell_service.py
AsyncCommandHandle._reader_thread_proc
def _reader_thread_proc(self, timeout): """Read until the stream is closed.""" for data in self.stream.read_until_close(timeout_ms=timeout): if self.stdout is not None: self.stdout.write(data)
python
def _reader_thread_proc(self, timeout): """Read until the stream is closed.""" for data in self.stream.read_until_close(timeout_ms=timeout): if self.stdout is not None: self.stdout.write(data)
[ "def", "_reader_thread_proc", "(", "self", ",", "timeout", ")", ":", "for", "data", "in", "self", ".", "stream", ".", "read_until_close", "(", "timeout_ms", "=", "timeout", ")", ":", "if", "self", ".", "stdout", "is", "not", "None", ":", "self", ".", "...
Read until the stream is closed.
[ "Read", "until", "the", "stream", "is", "closed", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/plugs/usb/shell_service.py#L145-L149
226,985
google/openhtf
openhtf/plugs/usb/shell_service.py
AsyncCommandHandle.wait
def wait(self, timeout_ms=None): """Block until this command has completed. Args: timeout_ms: Timeout, in milliseconds, to wait. Returns: Output of the command if it complete and self.stdout is a StringIO object or was passed in as None. Returns True if the command completed but stdou...
python
def wait(self, timeout_ms=None): """Block until this command has completed. Args: timeout_ms: Timeout, in milliseconds, to wait. Returns: Output of the command if it complete and self.stdout is a StringIO object or was passed in as None. Returns True if the command completed but stdou...
[ "def", "wait", "(", "self", ",", "timeout_ms", "=", "None", ")", ":", "closed", "=", "timeouts", ".", "loop_until_timeout_or_true", "(", "timeouts", ".", "PolledTimeout", ".", "from_millis", "(", "timeout_ms", ")", ",", "self", ".", "stream", ".", "is_closed...
Block until this command has completed. Args: timeout_ms: Timeout, in milliseconds, to wait. Returns: Output of the command if it complete and self.stdout is a StringIO object or was passed in as None. Returns True if the command completed but stdout was provided (and was not a StringIO o...
[ "Block", "until", "this", "command", "has", "completed", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/plugs/usb/shell_service.py#L169-L189
226,986
google/openhtf
openhtf/plugs/usb/shell_service.py
ShellService.command
def command(self, command, raw=False, timeout_ms=None): """Run the given command and return the output.""" return ''.join(self.streaming_command(command, raw, timeout_ms))
python
def command(self, command, raw=False, timeout_ms=None): """Run the given command and return the output.""" return ''.join(self.streaming_command(command, raw, timeout_ms))
[ "def", "command", "(", "self", ",", "command", ",", "raw", "=", "False", ",", "timeout_ms", "=", "None", ")", ":", "return", "''", ".", "join", "(", "self", ".", "streaming_command", "(", "command", ",", "raw", ",", "timeout_ms", ")", ")" ]
Run the given command and return the output.
[ "Run", "the", "given", "command", "and", "return", "the", "output", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/plugs/usb/shell_service.py#L223-L225
226,987
google/openhtf
openhtf/plugs/usb/shell_service.py
ShellService.streaming_command
def streaming_command(self, command, raw=False, timeout_ms=None): """Run the given command and yield the output as we receive it.""" if raw: command = self._to_raw_command(command) return self.adb_connection.streaming_command('shell', command, timeout_ms)
python
def streaming_command(self, command, raw=False, timeout_ms=None): """Run the given command and yield the output as we receive it.""" if raw: command = self._to_raw_command(command) return self.adb_connection.streaming_command('shell', command, timeout_ms)
[ "def", "streaming_command", "(", "self", ",", "command", ",", "raw", "=", "False", ",", "timeout_ms", "=", "None", ")", ":", "if", "raw", ":", "command", "=", "self", ".", "_to_raw_command", "(", "command", ")", "return", "self", ".", "adb_connection", "...
Run the given command and yield the output as we receive it.
[ "Run", "the", "given", "command", "and", "yield", "the", "output", "as", "we", "receive", "it", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/plugs/usb/shell_service.py#L227-L231
226,988
google/openhtf
openhtf/plugs/usb/shell_service.py
ShellService.async_command
def async_command(self, command, stdin=None, stdout=None, raw=False, timeout_ms=None): """Run the given command on the device asynchronously. Input will be read from stdin, output written to stdout. ADB doesn't distinguish between stdout and stdin on the device, so they get interleaved...
python
def async_command(self, command, stdin=None, stdout=None, raw=False, timeout_ms=None): """Run the given command on the device asynchronously. Input will be read from stdin, output written to stdout. ADB doesn't distinguish between stdout and stdin on the device, so they get interleaved...
[ "def", "async_command", "(", "self", ",", "command", ",", "stdin", "=", "None", ",", "stdout", "=", "None", ",", "raw", "=", "False", ",", "timeout_ms", "=", "None", ")", ":", "timeout", "=", "timeouts", ".", "PolledTimeout", ".", "from_millis", "(", "...
Run the given command on the device asynchronously. Input will be read from stdin, output written to stdout. ADB doesn't distinguish between stdout and stdin on the device, so they get interleaved into stdout here. stdin and stdout should be file-like objects, so you could use sys.stdin and sys.stdou...
[ "Run", "the", "given", "command", "on", "the", "device", "asynchronously", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/plugs/usb/shell_service.py#L234-L273
226,989
google/openhtf
openhtf/util/conf.py
Configuration.load_flag_values
def load_flag_values(self, flags=None): """Load flag values given from command line flags. Args: flags: An argparse Namespace containing the command line flags. """ if flags is None: flags = self._flags for keyval in flags.config_value: k, v = keyval.split('=', 1) v = self._...
python
def load_flag_values(self, flags=None): """Load flag values given from command line flags. Args: flags: An argparse Namespace containing the command line flags. """ if flags is None: flags = self._flags for keyval in flags.config_value: k, v = keyval.split('=', 1) v = self._...
[ "def", "load_flag_values", "(", "self", ",", "flags", "=", "None", ")", ":", "if", "flags", "is", "None", ":", "flags", "=", "self", ".", "_flags", "for", "keyval", "in", "flags", ".", "config_value", ":", "k", ",", "v", "=", "keyval", ".", "split", ...
Load flag values given from command line flags. Args: flags: An argparse Namespace containing the command line flags.
[ "Load", "flag", "values", "given", "from", "command", "line", "flags", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/util/conf.py#L255-L271
226,990
google/openhtf
openhtf/util/conf.py
Configuration.declare
def declare(self, name, description=None, **kwargs): """Declare a configuration key with the given name. Args: name: Configuration key to declare, must not have been already declared. description: If provided, use this as the description for this key. **kwargs: Other kwargs to pass to the Dec...
python
def declare(self, name, description=None, **kwargs): """Declare a configuration key with the given name. Args: name: Configuration key to declare, must not have been already declared. description: If provided, use this as the description for this key. **kwargs: Other kwargs to pass to the Dec...
[ "def", "declare", "(", "self", ",", "name", ",", "description", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "not", "self", ".", "_is_valid_key", "(", "name", ")", ":", "raise", "self", ".", "InvalidKeyError", "(", "'Invalid key name, must begin w...
Declare a configuration key with the given name. Args: name: Configuration key to declare, must not have been already declared. description: If provided, use this as the description for this key. **kwargs: Other kwargs to pass to the Declaration, only default_value is currently supporte...
[ "Declare", "a", "configuration", "key", "with", "the", "given", "name", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/util/conf.py#L337-L353
226,991
google/openhtf
openhtf/util/conf.py
Configuration.reset
def reset(self): """Reset the loaded state of the configuration to what it was at import. Note that this does *not* reset values set by commandline flags or loaded from --config-file (in fact, any values loaded from --config-file that have been overridden are reset to their value from --config-file). ...
python
def reset(self): """Reset the loaded state of the configuration to what it was at import. Note that this does *not* reset values set by commandline flags or loaded from --config-file (in fact, any values loaded from --config-file that have been overridden are reset to their value from --config-file). ...
[ "def", "reset", "(", "self", ")", ":", "# Populate loaded_values with values from --config-file, if it was given.", "self", ".", "_loaded_values", "=", "{", "}", "if", "self", ".", "_flags", ".", "config_file", "is", "not", "None", ":", "self", ".", "load_from_file"...
Reset the loaded state of the configuration to what it was at import. Note that this does *not* reset values set by commandline flags or loaded from --config-file (in fact, any values loaded from --config-file that have been overridden are reset to their value from --config-file).
[ "Reset", "the", "loaded", "state", "of", "the", "configuration", "to", "what", "it", "was", "at", "import", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/util/conf.py#L356-L366
226,992
google/openhtf
openhtf/util/conf.py
Configuration.load_from_file
def load_from_file(self, yamlfile, _override=True, _allow_undeclared=False): """Loads the configuration from a file. Parsed contents must be a single dict mapping config key to value. Args: yamlfile: The opened file object to load configuration from. See load_from_dict() for other args' descri...
python
def load_from_file(self, yamlfile, _override=True, _allow_undeclared=False): """Loads the configuration from a file. Parsed contents must be a single dict mapping config key to value. Args: yamlfile: The opened file object to load configuration from. See load_from_dict() for other args' descri...
[ "def", "load_from_file", "(", "self", ",", "yamlfile", ",", "_override", "=", "True", ",", "_allow_undeclared", "=", "False", ")", ":", "self", ".", "_logger", ".", "info", "(", "'Loading configuration from file: %s'", ",", "yamlfile", ")", "try", ":", "parsed...
Loads the configuration from a file. Parsed contents must be a single dict mapping config key to value. Args: yamlfile: The opened file object to load configuration from. See load_from_dict() for other args' descriptions. Raises: ConfigurationInvalidError: If configuration file can't be...
[ "Loads", "the", "configuration", "from", "a", "file", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/util/conf.py#L368-L397
226,993
google/openhtf
openhtf/util/conf.py
Configuration.load_from_dict
def load_from_dict(self, dictionary, _override=True, _allow_undeclared=False): """Loads the config with values from a dictionary instead of a file. This is meant for testing and bin purposes and shouldn't be used in most applications. Args: dictionary: The dictionary containing config keys/value...
python
def load_from_dict(self, dictionary, _override=True, _allow_undeclared=False): """Loads the config with values from a dictionary instead of a file. This is meant for testing and bin purposes and shouldn't be used in most applications. Args: dictionary: The dictionary containing config keys/value...
[ "def", "load_from_dict", "(", "self", ",", "dictionary", ",", "_override", "=", "True", ",", "_allow_undeclared", "=", "False", ")", ":", "undeclared_keys", "=", "[", "]", "for", "key", ",", "value", "in", "self", ".", "_modules", "[", "'six'", "]", ".",...
Loads the config with values from a dictionary instead of a file. This is meant for testing and bin purposes and shouldn't be used in most applications. Args: dictionary: The dictionary containing config keys/values to update. _override: If True, new values will override previous values. ...
[ "Loads", "the", "config", "with", "values", "from", "a", "dictionary", "instead", "of", "a", "file", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/util/conf.py#L405-L445
226,994
google/openhtf
openhtf/util/conf.py
Configuration._asdict
def _asdict(self): """Create a dictionary snapshot of the current config values.""" # Start with any default values we have, and override with loaded values, # and then override with flag values. retval = {key: self._declarations[key].default_value for key in self._declarations if self._de...
python
def _asdict(self): """Create a dictionary snapshot of the current config values.""" # Start with any default values we have, and override with loaded values, # and then override with flag values. retval = {key: self._declarations[key].default_value for key in self._declarations if self._de...
[ "def", "_asdict", "(", "self", ")", ":", "# Start with any default values we have, and override with loaded values,", "# and then override with flag values.", "retval", "=", "{", "key", ":", "self", ".", "_declarations", "[", "key", "]", ".", "default_value", "for", "key"...
Create a dictionary snapshot of the current config values.
[ "Create", "a", "dictionary", "snapshot", "of", "the", "current", "config", "values", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/util/conf.py#L448-L460
226,995
google/openhtf
openhtf/util/conf.py
Configuration.help_text
def help_text(self): """Return a string with all config keys and their descriptions.""" result = [] for name in sorted(self._declarations.keys()): result.append(name) result.append('-' * len(name)) decl = self._declarations[name] if decl.description: result.append(decl.descri...
python
def help_text(self): """Return a string with all config keys and their descriptions.""" result = [] for name in sorted(self._declarations.keys()): result.append(name) result.append('-' * len(name)) decl = self._declarations[name] if decl.description: result.append(decl.descri...
[ "def", "help_text", "(", "self", ")", ":", "result", "=", "[", "]", "for", "name", "in", "sorted", "(", "self", ".", "_declarations", ".", "keys", "(", ")", ")", ":", "result", ".", "append", "(", "name", ")", "result", ".", "append", "(", "'-'", ...
Return a string with all config keys and their descriptions.
[ "Return", "a", "string", "with", "all", "config", "keys", "and", "their", "descriptions", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/util/conf.py#L463-L481
226,996
google/openhtf
openhtf/util/conf.py
Configuration.save_and_restore
def save_and_restore(self, _func=None, **config_values): """Decorator for saving conf state and restoring it after a function. This decorator is primarily for use in tests, where conf keys may be updated for individual test cases, but those values need to be reverted after the test case is done. E...
python
def save_and_restore(self, _func=None, **config_values): """Decorator for saving conf state and restoring it after a function. This decorator is primarily for use in tests, where conf keys may be updated for individual test cases, but those values need to be reverted after the test case is done. E...
[ "def", "save_and_restore", "(", "self", ",", "_func", "=", "None", ",", "*", "*", "config_values", ")", ":", "functools", "=", "self", ".", "_modules", "[", "'functools'", "]", "# pylint: disable=redefined-outer-name", "if", "not", "_func", ":", "return", "fun...
Decorator for saving conf state and restoring it after a function. This decorator is primarily for use in tests, where conf keys may be updated for individual test cases, but those values need to be reverted after the test case is done. Examples: conf.declare('my_conf_key') @conf.save_an...
[ "Decorator", "for", "saving", "conf", "state", "and", "restoring", "it", "after", "a", "function", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/util/conf.py#L483-L542
226,997
google/openhtf
openhtf/util/conf.py
Configuration.inject_positional_args
def inject_positional_args(self, method): """Decorator for injecting positional arguments from the configuration. This decorator wraps the given method, so that any positional arguments are passed with corresponding values from the configuration. The name of the positional argument must match the conf...
python
def inject_positional_args(self, method): """Decorator for injecting positional arguments from the configuration. This decorator wraps the given method, so that any positional arguments are passed with corresponding values from the configuration. The name of the positional argument must match the conf...
[ "def", "inject_positional_args", "(", "self", ",", "method", ")", ":", "inspect", "=", "self", ".", "_modules", "[", "'inspect'", "]", "argspec", "=", "inspect", ".", "getargspec", "(", "method", ")", "# Index in argspec.args of the first keyword argument. This index...
Decorator for injecting positional arguments from the configuration. This decorator wraps the given method, so that any positional arguments are passed with corresponding values from the configuration. The name of the positional argument must match the configuration key. Keyword arguments are *NEVER*...
[ "Decorator", "for", "injecting", "positional", "arguments", "from", "the", "configuration", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/util/conf.py#L544-L616
226,998
google/openhtf
openhtf/util/functions.py
call_once
def call_once(func): """Decorate a function to only allow it to be called once. Note that it doesn't make sense to only call a function once if it takes arguments (use @functools.lru_cache for that sort of thing), so this only works on callables that take no args. """ argspec = inspect.getargspec(func) i...
python
def call_once(func): """Decorate a function to only allow it to be called once. Note that it doesn't make sense to only call a function once if it takes arguments (use @functools.lru_cache for that sort of thing), so this only works on callables that take no args. """ argspec = inspect.getargspec(func) i...
[ "def", "call_once", "(", "func", ")", ":", "argspec", "=", "inspect", ".", "getargspec", "(", "func", ")", "if", "argspec", ".", "args", "or", "argspec", ".", "varargs", "or", "argspec", ".", "keywords", ":", "raise", "ValueError", "(", "'Can only decorate...
Decorate a function to only allow it to be called once. Note that it doesn't make sense to only call a function once if it takes arguments (use @functools.lru_cache for that sort of thing), so this only works on callables that take no args.
[ "Decorate", "a", "function", "to", "only", "allow", "it", "to", "be", "called", "once", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/util/functions.py#L23-L45
226,999
google/openhtf
openhtf/util/functions.py
call_at_most_every
def call_at_most_every(seconds, count=1): """Call the decorated function at most count times every seconds seconds. The decorated function will sleep to ensure that at most count invocations occur within any 'seconds' second window. """ def decorator(func): try: call_history = getattr(func, '_call_...
python
def call_at_most_every(seconds, count=1): """Call the decorated function at most count times every seconds seconds. The decorated function will sleep to ensure that at most count invocations occur within any 'seconds' second window. """ def decorator(func): try: call_history = getattr(func, '_call_...
[ "def", "call_at_most_every", "(", "seconds", ",", "count", "=", "1", ")", ":", "def", "decorator", "(", "func", ")", ":", "try", ":", "call_history", "=", "getattr", "(", "func", ",", "'_call_history'", ")", "except", "AttributeError", ":", "call_history", ...
Call the decorated function at most count times every seconds seconds. The decorated function will sleep to ensure that at most count invocations occur within any 'seconds' second window.
[ "Call", "the", "decorated", "function", "at", "most", "count", "times", "every", "seconds", "seconds", "." ]
655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09
https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/util/functions.py#L47-L73