ConsoleUser

Copyright (c) 2010-2023 Skaion Corporarion, www.skaion.com

This project was developed in part by numerous sponsorships from the U.S. Government. The U.S. Government is authorized to reproduce and distribute reprints of Governmental purposes notwithstanding any copyright notation thereon.

All content reflects those of the authors and should not be interpreted as necessarily representing the official policies or endorsements, either expressed or implied, of the U.S. Government or Skaion Corporation.

utils.generic_factory(mods, desired, system, config)

Many instances of ApplicationImpl provide factories that will iterate over a list of possible modules that could provide the desired type. Rather than each having to implement that search directly, this will perform the search and return the suitable instance.

Parameters:

  • mods: a list of string module names to check

  • desired: a string matching the TYPE parameter of the module we want

  • system: a <no title> instance this user is connected to

  • config: a <no title> object defining this user

utils.get_coords(corner, size)

Given the upper left corner of an area and the size of the area to stay within, this will generate a set of random coordinates within that area.

utils.get_desktop_window(system, config)

Get the whole desktop as a <no title>.

Parameters:

  • system: the <no title> to interact with the target system

  • config: the <no title> defining the current user

utils.get_time(low, high)

Get a random amount of time between the low and high values.

utils.load_region(config, root, candidates, reg_name, logger=None)

Attempt to load the correct region by searching a given set of paths in order. All of the given paths can be relative to a given root path.

Parameters:

  • config: a <no title> instance for the <no title> of this region

  • root: the root directory to search all relative paths

  • candidates: an iteratble list of possible directories to search in order

  • reg_name: the filename, absent the path, to try to load

  • logger: optionally a <no title> object to write messages to

Return: a Region loaded if it can be found

utils.select_bottom(choices)

Pick one that is the lowest down on the screen

utils.select_random(choices)

Pick a random value from the available choices and return that one.

utils.select_rightest(choices)

Pick one that is the furthest right on the screen.

utils.select_top(choices)

Pick one that is the highest up on the screen

utils.skip_top(choices)

Pick a random choice that is not the topmost choice

utils.str2bool(string)

Convert a string of assorted recognized boolean types to the correct bool

Parameters:

  • string: the string to be converted

Return: True if the string looks like a true value, False otherwise