wlauto.utils package

Submodules

wlauto.utils.android module

Utility functions for working with Android devices through adb.

class wlauto.utils.android.AdbDevice(name, status)[source]

Bases: object

class wlauto.utils.android.AndroidProperties(text)[source]

Bases: object

parse(text)[source]
class wlauto.utils.android.ApkInfo(path=None)[source]

Bases: object

name_regex = <_sre.SRE_Pattern object>
parse(apk_path)[source]
version_regex = <_sre.SRE_Pattern object at 0x353b590>
wlauto.utils.android.adb_background_shell(device, command, stdout=-1, stderr=-1, as_root=False)[source]

Runs the sepcified command in a subprocess, returning the the Popen object.

wlauto.utils.android.adb_command(device, command, timeout=None)[source]
wlauto.utils.android.adb_connect(device, timeout=None)[source]
wlauto.utils.android.adb_disconnect(device)[source]
wlauto.utils.android.adb_get_device()[source]

Returns the serial number of a connected android device.

If there are more than one device connected to the machine, or it could not find any device connected, wlauto.exceptions.ConfigError is raised.

wlauto.utils.android.adb_list_devices()[source]
wlauto.utils.android.adb_shell(device, command, timeout=None, check_exit_code=False, as_root=False)[source]
wlauto.utils.android.fastboot_command(command, timeout=None)[source]
wlauto.utils.android.fastboot_flash_partition(partition, path_to_image)[source]
wlauto.utils.android.poll_for_file(device, dfile)[source]

wlauto.utils.cli module

wlauto.utils.cli.init_argument_parser(parser)[source]

wlauto.utils.cpuinfo module

class wlauto.utils.cpuinfo.Cpuinfo(text)[source]

Bases: object

architecture
parse(text)[source]

wlauto.utils.cros_sdk module

class wlauto.utils.cros_sdk.CrosSdkSession(cros_path, password='')[source]

Bases: object

get_lines(timeout=0, timeout_only_for_first_line=True, from_stderr=False)[source]
kill_session()[source]
read_line(timeout=0)[source]
read_stderr_line(timeout=0)[source]
send_command(cmd, flush=True)[source]
class wlauto.utils.cros_sdk.OutputPollingThread(out, queue, name)[source]

Bases: threading.Thread

run()[source]
set_stop()[source]

wlauto.utils.doc module

Utilities for working with and formatting documentation.

wlauto.utils.doc.count_leading_spaces(text)[source]

Counts the number of leading space characters in a string.

TODO: may need to update this to handle whitespace, but shouldn’t
be necessary as there should be no tabs in Python source.
wlauto.utils.doc.format_body(text, width)[source]

Format the specified text into a column of specified width. The text is assumed to be a “body” of one or more paragraphs separated by one or more blank lines. The initial indentation of the first line of each paragraph will be presevered, but any other formatting may be clobbered.

wlauto.utils.doc.format_bullets(text, width, char='-', shift=3, outchar=None)[source]

Formats text into bulleted list. Assumes each line of input that starts with char (possibly preceeded with whitespace) is a new bullet point. Note: leading whitespace in the input will not be preserved. Instead, it will be determined by shift parameter.

Text:the text to be formated
Width:format width (note: must be at least shift + 4).
Char:character that indicates a new bullet point in the input text.
Shift:How far bulleted entries will be indented. This indicates the indentation level of the bullet point. Text indentation level will be shift + 3.
Outchar:character that will be used to mark bullet points in the output. If left as None, char will be used.
wlauto.utils.doc.format_column(text, width)[source]

Formats text into a column of specified width. If a line is too long, it will be broken on a word boundary. The new lines will have the same number of leading spaces as the original line.

Note: this will not attempt to join up lines that are too short.

wlauto.utils.doc.format_literal(lit)[source]
wlauto.utils.doc.format_paragraph(text, width)[source]

Format the specified text into a column of specified with. The text is assumed to be a single paragraph and existing line breaks will not be preserved. Leading spaces (of the initial line), on the other hand, will be preserved.

wlauto.utils.doc.format_simple_table(rows, headers=None, align='>', show_borders=True, borderchar='=')[source]

Formats a simple table.

wlauto.utils.doc.get_description(aclass)[source]

Return the description of the specified extension class. The description is taken either from description attribute of the class or its docstring.

wlauto.utils.doc.get_params_rst(ext)[source]
wlauto.utils.doc.get_rst_from_extension(ext)[source]
wlauto.utils.doc.get_summary(aclass)[source]

Returns the summary description for an extension class. The summary is the first paragraph (separated by blank line) of the description taken either from the descripton attribute of the class, or if that is not present, from the class’ docstring.

wlauto.utils.doc.get_type_name(obj)[source]

Returns the name of the type object or function specified. In case of a lambda, the definiition is returned with the parameter replaced by “value”.

wlauto.utils.doc.indent(text, spaces=4)[source]

Indent the lines i the specified text by spaces spaces.

wlauto.utils.doc.strip_inlined_text(text)[source]

This function processes multiline inlined text (e.g. form docstrings) to strip away leading spaces and leading and trailing new lines.

wlauto.utils.doc.underline(text, symbol='=')[source]

wlauto.utils.formatter module

class wlauto.utils.formatter.DescriptionListFormatter(title=None, width=None)[source]

Bases: wlauto.utils.formatter.TextFormatter

add_item(new_data, item_title)[source]
data = None
format_data()[source]
get_text_width()[source]
name = 'description_list_formatter'
set_text_width(value)[source]
text_width
class wlauto.utils.formatter.TextFormatter[source]

Bases: object

This is a base class for text formatting. It mainly ask to implement two methods which are add_item and format_data. The formar will add new text to the formatter, whereas the latter will return a formatted text. The name attribute represents the name of the foramtter.

add_item(new_data, item_title)[source]

Add new item to the text formatter.

Parameters:
  • new_data – The data to be added
  • item_title – A title for the added data
data = None
format_data()[source]

It returns a formatted text

name = None

wlauto.utils.fps module

class wlauto.utils.fps.FpsProcessor(data, action=None, extra_data=None)[source]

Bases: object

Provides common object for processing surfaceFlinger output for frame statistics.

This processor returns the four frame statistics below:

FPS:Frames Per Second. This is the frame rate of the workload.
frame_count:The total number of frames rendered during the execution of the workload.
janks:The number of “janks” that occurred during execution of the workload. Janks are sudden shifts in frame rate. They result in a “stuttery” UI. See http://jankfree.org/jank-busters-io
not_at_vsync:The number of frames that did not render in a single vsync cycle.
percentiles()[source]
process(refresh_period, drop_threshold)[source]

Generate frame per second (fps) and associated metrics for workload.

refresh_period - the vsync interval drop_threshold - data points below this fps will be dropped

class wlauto.utils.fps.GfxInfoFrame(Flags, IntendedVsync, Vsync, OldestInputEvent, NewestInputEvent, HandleInputStart, AnimationStart, PerformTraversalsStart, DrawStart, SyncQueued, SyncStart, IssueDrawCommandsStart, SwapBuffers, FrameCompleted)

Bases: tuple

AnimationStart

Alias for field number 6

DrawStart

Alias for field number 8

Flags

Alias for field number 0

FrameCompleted

Alias for field number 13

HandleInputStart

Alias for field number 5

IntendedVsync

Alias for field number 1

IssueDrawCommandsStart

Alias for field number 11

NewestInputEvent

Alias for field number 4

OldestInputEvent

Alias for field number 3

PerformTraversalsStart

Alias for field number 7

SwapBuffers

Alias for field number 12

SyncQueued

Alias for field number 9

SyncStart

Alias for field number 10

Vsync

Alias for field number 2

class wlauto.utils.fps.SurfaceFlingerFrame(desired_present_time, actual_present_time, frame_ready_time)

Bases: tuple

actual_present_time

Alias for field number 1

desired_present_time

Alias for field number 0

frame_ready_time

Alias for field number 2

wlauto.utils.hwmon module

class wlauto.utils.hwmon.HwmonSensor(device, kind, device_name, label, filepath)[source]

Bases: object

clear_readings()[source]
take_reading()[source]
wlauto.utils.hwmon.discover_sensors(device, sensor_kinds)[source]

Discovers HWMON sensors available on the device.

device:Device on which to discover HWMON sensors. Must be an instance of AndroidDevice.
sensor_kinds:A list of names of sensor types to be discovered. The names must be as they appear prefixed to *_input files in sysfs. E.g. 'energy'.
returns:A list of HwmonSensor instantces for each found sensor. If no sensors of the specified types were discovered, an empty list will be returned.

wlauto.utils.ipython module

wlauto.utils.ipython.export_notebook(nbbasename, output_directory, output_format)[source]

Generate a PDF or HTML from the ipython notebook

output_format has to be either ‘pdf’ or ‘html’. These are the only formats currently supported.

ipython nbconvert claims that the CLI is not stable, so keep this function here to be able to cope with inconsistencies

wlauto.utils.ipython.parse_valid_output(msg)[source]

Parse a valid result from an execution of a cell in an ipython kernel

wlauto.utils.ipython.run_cell(kernel_client, cell)[source]

Run a cell of a notebook in an ipython kernel and return its output

wlauto.utils.ipython.run_notebook(notebook)[source]

Run the notebook

wlauto.utils.log module

class wlauto.utils.log.BaseLogWriter(name, level=10)[source]

Bases: object

close()[source]
flush()[source]
class wlauto.utils.log.ColorFormatter(fmt=None, datefmt=None)[source]

Bases: logging.Formatter

Formats logging records with color and prepends record info to each line of the message.

BLUE for DEBUG logging level GREEN for INFO logging level YELLOW for WARNING logging level RED for ERROR logging level BOLD RED for CRITICAL logging level
format(record)[source]
class wlauto.utils.log.ErrorSignalHandler(level=0)[source]

Bases: logging.Handler

Emits signals for ERROR and WARNING level traces.

emit(record)[source]
class wlauto.utils.log.LineFormatter(fmt=None, datefmt=None)[source]

Bases: logging.Formatter

Logs each line of the message separately.

format(record)[source]
class wlauto.utils.log.LineLogWriter(name, level=10)[source]

Bases: wlauto.utils.log.BaseLogWriter

write(data)[source]
class wlauto.utils.log.LogWriter(name, level=10)[source]

Bases: wlauto.utils.log.BaseLogWriter

write(data)[source]
class wlauto.utils.log.StreamLogger(name, stream, level=10, klass=<class 'wlauto.utils.log.LogWriter'>)[source]

Bases: threading.Thread

Logs output from a stream in a thread.

run()[source]
wlauto.utils.log.add_log_file(filepath, level=10)[source]
wlauto.utils.log.init_logging(verbosity)[source]

wlauto.utils.misc module

Miscellaneous functions that don’t fit anywhere else.

exception wlauto.utils.misc.CalledProcessErrorWithStderr(*args, **kwargs)[source]

Bases: subprocess.CalledProcessError

exception wlauto.utils.misc.LoadSyntaxError(message, filepath, lineno)[source]

Bases: exceptions.Exception

exception wlauto.utils.misc.TimeoutError(command, output)[source]

Bases: exceptions.Exception

Raised when a subprocess command times out. This is basically a WAError-derived version of subprocess.CalledProcessError, the thinking being that while a timeout could be due to programming error (e.g. not setting long enough timers), it is often due to some failure in the environment, and there fore should be classed as a “user error”.

wlauto.utils.misc.as_relative(path)[source]

Convert path to relative by stripping away the leading ‘/’ on UNIX or the equivant on other platforms.

wlauto.utils.misc.capitalize(text)[source]

Capitalises the specified text: first letter upper case, all subsequent letters lower case.

wlauto.utils.misc.check_output(command, timeout=None, ignore=None, **kwargs)[source]

This is a version of subprocess.check_output that adds a timeout parameter to kill the subprocess if it does not return within the specified time.

wlauto.utils.misc.commonprefix(file_list, sep='/')[source]

Find the lowest common base folder of a passed list of files.

wlauto.utils.misc.convert_new_lines(text)[source]

Convert new lines to a common format.

wlauto.utils.misc.diff_tokens(before_token, after_token)[source]

Creates a diff of two tokens.

If the two tokens are the same it just returns returns the token (whitespace tokens are considered the same irrespective of type/number of whitespace characters in the token).

If the tokens are numeric, the difference between the two values is returned.

Otherwise, a string in the form [before -> after] is returned.

wlauto.utils.misc.ensure_directory_exists(dirpath)[source]

A filter for directory paths to ensure they exist.

wlauto.utils.misc.ensure_file_directory_exists(filepath)[source]

A filter for file paths to ensure the directory of the file exists and the file can be created there. The file itself is not going to be created if it doesn’t already exist.

wlauto.utils.misc.enum_metaclass(enum_param, return_name=False, start=0)[source]

Returns a type subclass that may be used as a metaclass for an enum.

Paremeters:

enum_param:the name of class attribute that defines enum values. The metaclass will add a class attribute for each value in enum_param. The value of the attribute depends on the type of enum_param and on the values of return_name. If return_name is True, then the value of the new attribute is the name of that attribute; otherwise, if enum_param is a list or a tuple, the value will be the index of that param in enum_param, optionally offset by start, otherwise, it will be assumed that enum_param implementa a dict-like inteface and the value will be enum_param[attr_name].
return_name:If True, the enum values will the names of enum attributes. If False, the default, the values will depend on the type of enum_param (see above).
start:If enum_param is a list or a tuple, and return_name is False, this specifies an “offset” that will be added to the index of the attribute within enum_param to form the value.
wlauto.utils.misc.escape_double_quotes(text)[source]

Escape double quotes, and escaped double quotes, in the specified text.

wlauto.utils.misc.escape_quotes(text)[source]

Escape quotes, and escaped quotes, in the specified text.

wlauto.utils.misc.escape_single_quotes(text)[source]

Escape single quotes, and escaped single quotes, in the specified text.

wlauto.utils.misc.format_duration(seconds, sep=' ', order=['day', 'hour', 'minute', 'second'])[source]

Formats the specified number of seconds into human-readable duration.

wlauto.utils.misc.geomean(values)[source]

Returns the geometric mean of the values.

wlauto.utils.misc.get_article(word)[source]

Returns the appropriate indefinite article for the word (ish).

Note

Indefinite article assignment in English is based on sound rather than spelling, so this will not work correctly in all case; e.g. this will return "a hour".

wlauto.utils.misc.get_cpu_mask(cores)[source]

Return a string with the hex for the cpu mask for the specified core numbers.

wlauto.utils.misc.get_meansd(values)[source]

Returns mean and standard deviation of the specified values.

wlauto.utils.misc.get_null()[source]

Returns the correct null sink based on the OS.

wlauto.utils.misc.get_pager()[source]

Returns the name of the system pager program.

wlauto.utils.misc.get_random_string(length)[source]

Returns a random ASCII string of the specified length).

wlauto.utils.misc.get_traceback(exc=None)[source]

Returns the string with the traceback for the specifiec exc object, or for the current exception exc is not specified.

wlauto.utils.misc.getch(count=1)[source]

Read count characters from standard input.

wlauto.utils.misc.isiterable(obj)[source]

Returns True if the specified object is iterable and is not a string type, False otherwise.

wlauto.utils.misc.list_to_mask(values, base=0)[source]

Converts the specified list of integer values into a bit mask for those values. Optinally, the list can be applied to an existing mask.

wlauto.utils.misc.list_to_ranges(values)[source]

Converts a list, e.g [0,2,3,4], into a sysfs-style ranges string, e.g. "0,2-4"

wlauto.utils.misc.load_class(classpath)[source]

Loads the specified Python class. classpath must be a fully-qualified class name (i.e. namspaced under module/package).

wlauto.utils.misc.load_struct_from_file(filepath)[source]

Attempts to parse a Python structure consisting of basic types from the specified file. Raises a ValueError if the specified file is of unkown format; LoadSyntaxError if there is an issue parsing the file.

wlauto.utils.misc.load_struct_from_python(filepath=None, text=None)[source]

Parses a config structure from a .py file. The structure should be composed of basic Python types (strings, ints, lists, dicts, etc.).

wlauto.utils.misc.load_struct_from_yaml(filepath=None, text=None)[source]

Parses a config structure from a .yaml file. The structure should be composed of basic Python types (strings, ints, lists, dicts, etc.).

wlauto.utils.misc.local_to_utc(dt)[source]

Convert naive datetime to UTC, assuming local time zone.

wlauto.utils.misc.mask_to_list(mask)[source]

Converts the specfied integer bitmask into a list of indexes of bits that are set in the mask.

wlauto.utils.misc.memoized(func)[source]

A decorator for memoizing functions and methods.

wlauto.utils.misc.merge_dicts(*args, **kwargs)[source]
wlauto.utils.misc.merge_lists(*args, **kwargs)[source]
wlauto.utils.misc.normalize(value, dict_type=<type 'dict'>)[source]

Normalize values. Recursively normalizes dict keys to be lower case, no surrounding whitespace, underscore-delimited strings.

wlauto.utils.misc.open_file(filepath)[source]

Open the specified file path with the associated launcher in an OS-agnostic way.

wlauto.utils.misc.parse_value(value_string)[source]

parses a string representing a numerical value and returns a tuple (value, units), where value will be either int or float, and units will be a string representing the units or None.

wlauto.utils.misc.preexec_function()[source]
wlauto.utils.misc.prepare_table_rows(rows)[source]

Given a list of lists, make sure they are prepared to be formatted into a table by making sure each row has the same number of columns and stringifying all values.

wlauto.utils.misc.ranges_to_list(ranges_string)[source]

Converts a sysfs-style ranges string, e.g. "0,2-4", into a list ,e.g [0,2,3,4]

wlauto.utils.misc.sha256(path, chunk=2048)[source]

Calculates SHA256 hexdigest of the file at the specified path.

wlauto.utils.misc.strip_bash_colors(text)[source]
wlauto.utils.misc.to_identifier(text)[source]

Converts text to a valid Python identifier by replacing all whitespace and punctuation.

wlauto.utils.misc.unique(alist)[source]

Returns a list containing only unique elements from the input list (but preserves order, unlike sets).

wlauto.utils.misc.urljoin(*parts)[source]
wlauto.utils.misc.utc_to_local(dt)[source]

Convert naive datetime to local time zone, assuming UTC.

wlauto.utils.misc.walk_modules(path)[source]

Given package name, return a list of all modules (including submodules, etc) in that package.

wlauto.utils.misc.which(name)[source]

Platform-independent version of UNIX which utility.

wlauto.utils.misc.write_table(rows, wfh, align='>', headers=None)[source]

Write a column-aligned table to the specified file object.

wlauto.utils.netio module

This module contains utilities for implemening device hard reset using Netio 230 series power switches. This utilizes the KSHELL connection.

class wlauto.utils.netio.KshellConnection(host='ippowerbar', port=1234, timeout=None)[source]

Bases: object

close()[source]
delay = 0.5
disable_port(port)[source]

Enable the power supply at the specified port.

enable_port(port)[source]

Enable the power supply at the specified port.

login(user, password)[source]
response_regex = <_sre.SRE_Pattern object>
send_command(command)[source]
set_port(port, value)[source]
exception wlauto.utils.netio.NetioError[source]

Bases: exceptions.Exception

wlauto.utils.power module

class wlauto.utils.power.CorePowerDroppedEvents(cpu_id)[source]

Bases: object

cpu_id
kind = 'dropped_events'
class wlauto.utils.power.CorePowerTransitionEvent(timestamp, cpu_id, frequency=None, idle_state=None)[source]

Bases: object

cpu_id
frequency
idle_state
kind = 'transition'
timestamp
class wlauto.utils.power.CpuPowerState(frequency=None, idle_state=None)[source]

Bases: object

frequency
idle_state
is_active
is_idling
class wlauto.utils.power.CpuUtilisationTimeline(filepath, core_names, max_freq_list)[source]

Bases: object

report()[source]
update(timestamp, core_states)[source]
class wlauto.utils.power.ParallelReport[source]

Bases: object

add(value)[source]
write(filepath)[source]
class wlauto.utils.power.ParallelStats(core_clusters, use_ratios=False)[source]

Bases: object

report()[source]
update(timestamp, core_states)[source]
class wlauto.utils.power.PowerStateProcessor(core_clusters, num_idle_states, first_cluster_state=9223372036854775807, first_system_state=9223372036854775807, wait_for_start_marker=False, no_idle=False)[source]

Bases: object

This takes a stream of power transition events and yields a timeline stream of system power states.

cpu_states
current_time
process(event_stream)[source]
update_power_state(event)[source]

Update the tracked power state based on the specified event and return updated power state.

class wlauto.utils.power.PowerStateStats(core_names, idle_state_names=None, use_ratios=False)[source]

Bases: object

report()[source]
update(timestamp, core_states)[source]
class wlauto.utils.power.PowerStateStatsReport(state_stats, core_names, precision=2)[source]

Bases: object

write(filepath)[source]
class wlauto.utils.power.PowerStateTimeline(filepath, core_names, idle_state_names)[source]

Bases: object

report()[source]
update(timestamp, core_states)[source]
class wlauto.utils.power.PowerStateTransitions(filepath)[source]

Bases: object

record_transition(transition)[source]
report()[source]
update(timestamp, core_states)[source]
class wlauto.utils.power.SplitListAction(option_strings, dest, nargs=None, **kwargs)[source]

Bases: argparse.Action

class wlauto.utils.power.SystemPowerState(num_cores, no_idle=False)[source]

Bases: object

copy()[source]
cpus
num_cores
timestamp
class wlauto.utils.power.TraceMarkerEvent(name)[source]

Bases: object

kind = 'marker'
name
wlauto.utils.power.build_idle_domains(core_clusters, num_states, first_cluster_state=None, first_system_state=None)[source]

Returns a list of idle domain groups (one for each idle state). Each group is a list of domains, and a domain is a list of cpu ids for which that idle state is common. E.g.

[[[0], [1], [2]], [[0, 1], [2]], [[0, 1, 2]]]

This defines three idle states for a machine with three cores. The first idle state has three domains with one core in each domain; the second state has two domains, with cores 0 and 1 sharing one domain; the final state has only one domain shared by all cores.

This mapping created based on the assumptions

  • The device is an SMP or a big.LITTLE-like system with cores in one or more clusters (for SMP systems, all cores are considered to be in a “cluster”).
  • Idle domain correspend to either individual cores, individual custers, or the compute subsystem as a whole.
  • Cluster states are always deeper (higher index) than core states, and system states are always deeper than cluster states.

parameters:

core_clusters:a list indicating cluster “ID” of the corresponing core, e.g. [0, 0, 1] represents a three-core machines with cores 0 and 1 on cluster 0, and core 2 on cluster 1.
num_states:total number of idle states on a device.
first_cluster_state:
 the ID of the first idle state shared by all cores in a cluster
first_system_state:
 the ID of the first idle state shared by all cores.
wlauto.utils.power.gather_core_states(system_state_stream, freq_dependent_idle_states=None)[source]
wlauto.utils.power.main()[source]
wlauto.utils.power.parse_arguments()[source]
wlauto.utils.power.record_state_transitions(reporter, stream)[source]
wlauto.utils.power.report_power_stats(trace_file, idle_state_names, core_names, core_clusters, num_idle_states, first_cluster_state=9223372036854775807, first_system_state=9223372036854775807, use_ratios=False, timeline_csv_file=None, cpu_utilisation=None, max_freq_list=None, start_marker_handling='error', transitions_csv_file=None, no_idle=False)[source]
wlauto.utils.power.stream_cpu_power_transitions(events)[source]

wlauto.utils.revent module

class wlauto.utils.revent.ReventEvent(fh, legacy=False)[source]

Bases: object

class wlauto.utils.revent.ReventRecording(f, stream=True)[source]

Bases: object

Represents a parsed revent recording. This contains input events and device descriptions recorded by revent. Two parsing modes are supported. By default, the recording will be parsed in the “streaming” mode. In this mode, initial headers and device descritions are parsed on creation and an open file handle to the recording is saved. Events will be read from the file as they are being iterated over. In this mode, the entire recording is never loaded into memory at once. The underlying file may be “released” by calling close on the recroding, after which further iteration over the events will not be possible (but would still be possible to access the file description and header information).

The alternative is to load the entire recording on creation (in which case the file handle will be closed once the recroding is loaded). This can be enabled by specifying streaming=False. This will make it faster to subsequently iterate over the events, and also will not “hold” the file open.

Note

When starting a new iteration over the events in streaming mode, the postion in the open file will be automatically reset to the beginning of the event stream. This means it’s possible to iterate over the events multiple times without having to re-open the recording, however it is not possible to do so in parallel. If parallel iteration is required, streaming should be disabled.

close()[source]
duration
events
class wlauto.utils.revent.UinputDeviceInfo(fh)[source]

Bases: object

class wlauto.utils.revent.absinfo(ev_code, value, min, max, fuzz, flat, resolution)

Bases: tuple

ev_code

Alias for field number 0

flat

Alias for field number 5

fuzz

Alias for field number 4

max

Alias for field number 3

min

Alias for field number 2

resolution

Alias for field number 6

value

Alias for field number 1

wlauto.utils.revent.count_bits(bitarr)[source]
wlauto.utils.revent.is_set(bitarr, bit)[source]
wlauto.utils.revent.read_string(fh)[source]
wlauto.utils.revent.read_struct(fh, struct_spec)[source]

wlauto.utils.serial_port module

class wlauto.utils.serial_port.PexpectLogger(kind)[source]

Bases: wlauto.utils.log.LogWriter

wlauto.utils.serial_port.get_connection(timeout, init_dtr=None, *args, **kwargs)[source]
wlauto.utils.serial_port.open_serial_connection(*args, **kwds)[source]

Opens a serial connection to a device.

Parameters:
  • timeout – timeout for the fdpexpect spawn object.
  • connbool that specfies whether the underlying connection object should be yielded as well.
  • init_dtr – specifies the initial DTR state stat should be set.

All arguments are passed into the __init__ of serial.Serial. See pyserial documentation for details:

Returns:a pexpect spawn object connected to the device. See: http://pexpect.sourceforge.net/pexpect.html
wlauto.utils.serial_port.pulse_dtr(conn, state=True, duration=0.1)[source]

Set the DTR line of the specified serial connection to the specified state for the specified duration (note: the initial state of the line is not checked.

wlauto.utils.ssh module

class wlauto.utils.ssh.SshShell(password_prompt=None, timeout=10, telnet=False)[source]

Bases: object

background(command, stdout=-1, stderr=-1)[source]
cancel_running_command()[source]
default_password_prompt = '[sudo] password'
execute(command, timeout=None, check_exit_code=True, as_root=False, strip_colors=True)[source]
login(host, username, password=None, keyfile=None, port=None, timeout=None)[source]
logout()[source]
max_cancel_attempts = 5
pull_file(source, dest, timeout=30)[source]
push_file(source, dest, timeout=30)[source]
reconnect()[source]
class wlauto.utils.ssh.TelnetConnection(timeout=30, maxread=2000, searchwindowsize=None, logfile=None, cwd=None, env=None, ignore_sighup=True, echo=True, options={}, encoding=None, codec_errors='strict', debug_command_string=False)[source]

Bases: pexpect.pxssh.pxssh

login(server, username, password='', original_prompt='[#$]', login_timeout=10, auto_prompt_reset=True, sync_multiplier=1, port=23)[source]
wlauto.utils.ssh.check_keyfile(keyfile)[source]

keyfile must have the right access premissions in order to be useable. If the specified file doesn’t, create a temporary copy and set the right permissions for that.

Returns either the keyfile (if the permissions on it are correct) or the path to a temporary copy with the right permissions.

wlauto.utils.ssh.process_backspaces(text)[source]
wlauto.utils.ssh.ssh_get_shell(host, username, password=None, keyfile=None, port=None, timeout=10, telnet=False, original_prompt=None)[source]

wlauto.utils.statedetect module

State detection functionality for revent workloads. Uses OpenCV to analyse screenshots from the device. Requires a ‘statedetection’ directory in the workload directory that includes the state definition yaml file, and the ‘templates’ folder with PNGs of all templates mentioned in the yaml file.

Requires the following Python libraries: numpy, pyyaml (yaml), imutils and opencv-python

exception wlauto.utils.statedetect.StateDefinitionError[source]

Bases: exceptions.RuntimeError

wlauto.utils.statedetect.auto_canny(image, sigma=0.33)[source]
wlauto.utils.statedetect.check_match_state_dependencies()[source]
wlauto.utils.statedetect.match_state(screenshot_file, defpath, state_definitions)[source]
wlauto.utils.statedetect.verify_state(screenshot_file, state_defs_path, workload_phase)[source]

wlauto.utils.terminalsize module

wlauto.utils.terminalsize.get_terminal_size()[source]

getTerminalSize() - get width and height of console - works on linux,os x,windows,cygwin(windows) originally retrieved from: http://stackoverflow.com/questions/566746/how-to-get-console-window-width-in-python

wlauto.utils.trace_cmd module

class wlauto.utils.trace_cmd.DroppedEventsEvent(cpu_id)[source]

Bases: object

fields
name
reporting_cpu_id
text
thread
timestamp
class wlauto.utils.trace_cmd.TraceCmdEvent(thread, cpu_id, ts, name, body, parser=None)[source]

Bases: object

A single trace-cmd event. This will appear in the trace cmd report in the format

<idle>-0     [000]  3284.126993: sched_rq_runnable_load: cpu=0 load=54
   |           |         |              |                |___________|
   |           |         |              |                      |
thread        cpu    timestamp        name                    body
fields
name
reporting_cpu_id
text
thread
timestamp
class wlauto.utils.trace_cmd.TraceCmdTrace(file_path, names=None, filter_markers=True)[source]

Bases: object

has_start_marker
parse()[source]

This is a generator for the trace event stream.

wlauto.utils.trace_cmd.default_body_parser(event, text)[source]

Default parser to attempt to use to parser body text for the event (i.e. after the “header” common to all events has been parsed). This assumes that the body is a whitespace-separated list of key=value pairs. The parser will attempt to convert the value into a numeric type, and failing that, keep it as string.

wlauto.utils.trace_cmd.regex_body_parser(regex, flags=0)[source]

Creates an event body parser form the specified regular expression (could be an re.RegexObject, or a string). The regular expression should contain some named groups, as those will be extracted as the event attributes (unnamed groups and the reset of the match will be ignored).

If the specified regex is a string, it will be compiled, in which case flags may be provided for the resulting regex object (see re standard module documentation). If regex is a pre-compiled object, flags will be ignored.

wlauto.utils.trace_cmd.sched_stat_parser(event, text)[source]

sched_stat_* events unclude the units, “[ns]”, in an otherwise regular key=value sequence; so the units need to be stripped out first.

wlauto.utils.trace_cmd.sched_switch_parser(event, text)[source]

Sched switch output may be presented in a couple of different formats. One is handled by a regex. The other format can almost be handled by the default parser, if it weren’t for the ==> that appears in the middle.

wlauto.utils.trace_cmd.sched_wakeup_parser(event, text)[source]
wlauto.utils.trace_cmd.split_trace_event_line(line)[source]

Split a trace-cmd event line into the preamble (containing the task, cpu id and timestamp), the event name, and the event body. Each of these is delimited by a ‘: ‘ (optionally followed by more whitespace), however ‘: ‘ may also appear in the body of the event and in the thread name. This attempts to identify the correct split by ensureing the there is a ‘[‘ (used to mark the cpu id and not a valid character for a task name) in the peramble.

wlauto.utils.trace_cmd.try_convert_to_numeric(v)[source]

wlauto.utils.types module

Routines for doing various type conversions. These usually embody some higher-level semantics than are present in standard Python types (e.g. boolean will convert the string "false" to False, where as non-empty strings are usually considered to be True).

A lot of these are intened to stpecify type conversions declaratively in place like Parameter’s kind argument. These are basically “hacks” around the fact that Python is not the best language to use for configuration.

class wlauto.utils.types.ParameterDict(*args, **kwargs)[source]

Bases: dict

A dict-like object that automatically encodes various types into a url safe string, and enforces a single type for the contents in a list. Each value is first prefixed with 2 letters to preserve type when encoding to a string. The format used is “value_type, value_dimension” e.g a ‘list of floats’ would become ‘fl’.

get(name)[source]
get_encoded_value(name)[source]
iter_encoded_items()[source]
iteritems()[source]
pop(key)[source]
popitem()[source]
update(*args, **kwargs)[source]
values()[source]
class wlauto.utils.types.arguments(value=None)[source]

Bases: list

Represents command line arguments to be passed to a program.

append(value)[source]
extend(values)[source]
wlauto.utils.types.boolean(value)[source]

Returns bool represented by the value. This is different from calling the builtin bool() in that it will interpret string representations. e.g. boolean(‘0’) and boolean(‘false’) will both yield False.

class wlauto.utils.types.caseless_string[source]

Bases: str

Just like built-in Python string except case-insensitive on comparisons. However, the case is preserved otherwise.

format(*args, **kwargs)[source]
wlauto.utils.types.counter(name=None)[source]

An auto incremeting value (kind of like an AUTO INCREMENT field in SQL). Optionally, the name of the counter to be used is specified (each counter increments separately).

Counts start at 1, not 0.

wlauto.utils.types.file_path(value)[source]

Handles expansion of paths containing ‘~’

wlauto.utils.types.identifier(text)[source]

Converts text to a valid Python identifier by replacing all whitespace and punctuation.

wlauto.utils.types.integer(value)[source]

Handles conversions for string respresentations of binary, octal and hex.

wlauto.utils.types.list_of(type_)[source]

Generates a “list of” callable for the specified type. The callable attempts to convert all elements in the passed value to the specifed type_, raising ValueError on error.

wlauto.utils.types.list_of_bools(value, interpret_strings=True)[source]

Value must be iterable. All elements will be converted to bools.

Note

By default, boolean() conversion function will be used, which means that strings like "0" or "false" will be interpreted as False. If this is undesirable, set interpret_strings to False.

wlauto.utils.types.list_of_integers(value)

Value must be iterable. All elements will be converted to ints.

wlauto.utils.types.list_of_ints(value)[source]

Value must be iterable. All elements will be converted to ints.

wlauto.utils.types.list_of_numbers(value)[source]

Value must be iterable. All elements will be converted to numbers (either ints or floats depending on the elements).

wlauto.utils.types.list_of_strings(value)

Value must be iterable. All elements will be converted to strings.

wlauto.utils.types.list_of_strs(value)[source]

Value must be iterable. All elements will be converted to strings.

wlauto.utils.types.list_or(type_)[source]

Generator for “list or” types. These take either a single value or a list values and return a list of the specfied type_ performing the conversion on the value (if a single value is specified) or each of the elemented of the specified list.

wlauto.utils.types.list_or_bool

alias of list_or_type

wlauto.utils.types.list_or_caseless_string(value)[source]

Converts the value into a list of caseless_string’s. If the value is not iterable a one-element list with stringified value will be returned.

wlauto.utils.types.list_or_integer

alias of list_or_type

wlauto.utils.types.list_or_number

alias of list_or_type

wlauto.utils.types.list_or_string(value)[source]

Converts the value into a list of strings. If the value is not iterable, a one-element list with stringified value will be returned.

wlauto.utils.types.numeric(value)[source]

Returns the value as number (int if possible, or float otherwise), or raises ValueError if the specified value does not have a straight forward numeric conversion.

class wlauto.utils.types.range_dict[source]

Bases: dict

This dict allows you to specify mappings with a range.

If a key is not in the dict it will search downward until the next key and return its value. E.g:

If:
a[5] = “Hello” a[10] = “There”
Then:
a[2] == None a[7] == “Hello” a[999] == “There”
wlauto.utils.types.regex(value)[source]

Regular expression. If value is a string, it will be complied with no flags. If you want to specify flags, value must be precompiled.

wlauto.utils.types.reset_counter(name=None)[source]

wlauto.utils.uboot module

class wlauto.utils.uboot.UbootMenu(conn, start_prompt='Hit any key to stop autoboot')[source]

Bases: object

Allows navigating Das U-boot menu over serial (it relies on a pexpect connection).

boot()[source]
default_timeout = 60
empty_buffer()[source]
enter(value, delay=1)[source]

Like select() except no resolution is performed – the value is sent directly to the serial connection.

fixed_uboot_version = '2016.03'
getenv()[source]
invalid_regex = <_sre.SRE_Pattern object>
load_delay = 1
nudge()[source]

Send a little nudge to ensure there is something to read. This is useful when you’re not sure if all out put from the serial has been read already.

open(timeout=60)[source]

“Open” the UEFI menu by sending an interrupt on STDIN after seeing the starting prompt (configurable upon creation of the UefiMenu object.

option_regex = <_sre.SRE_Pattern object>
prompt_regex = <_sre.SRE_Pattern object>
setenv(variable, value, force=False)[source]
uboot_regex = <_sre.SRE_Pattern object>
write_characters(line)[source]

wlauto.utils.uefi module

class wlauto.utils.uefi.UefiConfig(config_dict)[source]

Bases: object

class wlauto.utils.uefi.UefiMenu(conn, prompt='The default boot selection will start in')[source]

Bases: object

Allows navigating UEFI menu over serial (it relies on a pexpect connection).

create_entry(name, config)[source]

Create a new UEFI entry using the parameters. The menu is assumed to be at the top level. Upon return, the menu will be at the top level.

default_timeout = 60
delete_entry(name)[source]

Delete the specified UEFI entry. The menu is assumed to be at the top level. Upon return, the menu will be at the top level.

empty_buffer()[source]

Read everything from the serial and clear the internal pexpect buffer. This ensures that the next expect() call will time out (unless further input will be sent to the serial beforehand. This is used to create a “known” state and avoid unexpected matches.

enter(value, delay=1)[source]

Like select() except no resolution is performed – the value is sent directly to the serial connection.

get_option_index(text, timeout=60)[source]

Returns the menu index of the specified option text (uses regex matching). If the option is not in the current menu, LookupError will be raised.

has_option(text, timeout=60)[source]

Returns True if at least one of the options in the current menu has matched (using regex) the specified text.

invalid_regex = <_sre.SRE_Pattern object>
load_delay = 1
nudge()[source]

Send a little nudge to ensure there is something to read. This is useful when you’re not sure if all out put from the serial has been read already.

open(timeout=60)[source]

“Open” the UEFI menu by sending an interrupt on STDIN after seeing the starting prompt (configurable upon creation of the UefiMenu object.

option_regex = <_sre.SRE_Pattern object>
prompt_regex = <_sre.SRE_Pattern object>
read_menu(timeout=60)[source]

Parse serial output to get the menu options and the following prompt.

select(option, timeout=60)[source]

Select the specified option from the current menu.

Parameters:
  • option – Could be an int index of the option, or a string/regex to match option text against.
  • timeout – If a non-int option is specified, the option list may need need to be parsed (if it hasn’t been already), this may block and the timeout is used to cap that , resulting in a TIMEOUT exception.
  • delay – A fixed delay to wait after sending the input to the serial connection. This should be set if input this action is known to result in a long-running operation.
write_characters(line)[source]

Write a single line out to serial charcter-by-character. This will ensure that nothing will be dropped for longer lines.

wlauto.utils.uxperf module

class wlauto.utils.uxperf.UxPerfParser(context, prefix='')[source]

Bases: object

Parses logcat messages for UX Performance markers.

UX Performance markers are output from logcat under a debug priority. The logcat tag for the marker messages is UX_PERF. The messages associated with this tag consist of a name for the action to be recorded and a timestamp. These fields are delimited by a single space. e.g.

<TAG> : <MESSAGE> UX_PERF : gestures_swipe_left_start 861975087367 … … UX_PERF : gestures_swipe_left_end 862132085804

Timestamps are produced using the running Java Virtual Machine’s high-resolution time source, in nanoseconds.

add_action_frames(frames, drop_threshold, generate_csv)[source]

Uses FpsProcessor to parse frame.csv extracting fps, frame count, jank and vsync metrics on a per action basis. Adds results to metrics.

add_action_timings()[source]

Add simple action timings in millisecond resolution to metrics

parse(log)[source]

Opens log file and parses UX_PERF markers.

Actions delimited by markers are captured in a dictionary with actions mapped to timestamps.

Module contents