wlauto.utils package


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

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

Bases: object

name_regex = <_sre.SRE_Pattern object>
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]

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_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.cpuinfo module

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

Bases: object


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]
send_command(cmd, flush=True)[source]
class wlauto.utils.cros_sdk.OutputPollingThread(out, queue, name)[source]

Bases: threading.Thread


wlauto.utils.doc module

Utilities for working with and formatting documentation.


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_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.


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


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.


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.


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
name = 'description_list_formatter'
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.

  • new_data – The data to be added
  • item_title – A title for the added data
data = None

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.
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


Alias for field number 6


Alias for field number 8


Alias for field number 0


Alias for field number 13


Alias for field number 5


Alias for field number 1


Alias for field number 11


Alias for field number 4


Alias for field number 3


Alias for field number 7


Alias for field number 12


Alias for field number 9


Alias for field number 10


Alias for field number 2

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

Bases: tuple


Alias for field number 1


Alias for field number 0


Alias for field number 2

wlauto.utils.hwmon module

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

Bases: object

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


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


Run the notebook

wlauto.utils.log module

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

Bases: object

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
class wlauto.utils.log.ErrorSignalHandler(level=0)[source]

Bases: logging.Handler

Emits signals for ERROR and WARNING level traces.

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

Bases: logging.Formatter

Logs each line of the message separately.

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

Bases: wlauto.utils.log.BaseLogWriter

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

Bases: wlauto.utils.log.BaseLogWriter

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.

wlauto.utils.log.add_log_file(filepath, level=10)[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”.


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


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.


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.


A filter for directory paths to ensure they exist.


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.


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.

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


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


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.


Returns the geometric mean of the values.


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


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".


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


Returns mean and standard deviation of the specified values.


Returns the correct null sink based on the OS.


Returns the name of the system pager program.


Returns a random ASCII string of the specified length).


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


Read count characters from standard input.


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.


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


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


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.).


Convert naive datetime to UTC, assuming local time zone.


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


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.


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


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.


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.


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.


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


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


Convert naive datetime to local time zone, assuming UTC.


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


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

delay = 0.5

Enable the power supply at the specified port.


Enable the power supply at the specified port.

login(user, password)[source]
response_regex = <_sre.SRE_Pattern object>
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

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

Bases: object

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

Bases: object

class wlauto.utils.power.CpuUtilisationTimeline(filepath, core_names, max_freq_list)[source]

Bases: object

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

Bases: object

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

Bases: object

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.


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

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

Bases: object

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

Bases: object

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

Bases: object

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

class wlauto.utils.power.TraceMarkerEvent(name)[source]

Bases: object

kind = 'marker'
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.


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.
 the ID of the first idle state shared by all cores in a cluster
 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.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.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.


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.

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

Bases: object

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

Bases: tuple


Alias for field number 0


Alias for field number 5


Alias for field number 4


Alias for field number 3


Alias for field number 2


Alias for field number 6


Alias for field number 1

wlauto.utils.revent.is_set(bitarr, bit)[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.

  • 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]
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]
max_cancel_attempts = 5
pull_file(source, dest, timeout=30)[source]
push_file(source, dest, timeout=30)[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]

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.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.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


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

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
class wlauto.utils.trace_cmd.TraceCmdTrace(file_path, names=None, filter_markers=True)[source]

Bases: object


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]

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.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’.

update(*args, **kwargs)[source]
class wlauto.utils.types.arguments(value=None)[source]

Bases: list

Represents command line arguments to be passed to a program.


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]

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.


Handles expansion of paths containing ‘~’


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


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


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.


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.


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


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


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


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


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


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.


alias of list_or_type


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.


alias of list_or_type


alias of list_or_type


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


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:

a[5] = “Hello” a[10] = “There”
a[2] == None a[7] == “Hello” a[999] == “There”

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.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).

default_timeout = 60
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'
invalid_regex = <_sre.SRE_Pattern object>
load_delay = 1

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” 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>

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 the specified UEFI entry. The menu is assumed to be at the top level. Upon return, the menu will be at the top level.


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

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” 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>

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.

  • 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 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 simple action timings in millisecond resolution to metrics


Opens log file and parses UX_PERF markers.

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

Module contents