Formatting Module sw.formatting

Functions

sw.formatting.avg(numbers)[source]

Averages a list of numbers.

Parameters:numbers – A list of numbers.
Returns:The average
sw.formatting.errorLevelToStr(level, parens=True)[source]

Takes a numeric error level and translates it into a string for displaying in a log.

Parameters:
  • level – The level to translate into a loggable string.
  • parens (True) – If the level will be contained in parenthesis
Returns:

String of the level in parenthesis.

sw.formatting.format(t)[source]

Formats a Float into a displayable form, rounding it into converting to a string.

Parameters:t – Input float.
Returns:String that’s formatted like so: 54.32.
sw.formatting.formatError(res, type='message')[source]

Formats the GhostDriver json-encoded error message for easier printing. In the end, this amounts to replacing escaped quotation marks, parsing the JSON message, and extracting the ‘errorMessage’ portion. It also trims the message to 81 characters if it is over that.

Parameters:
  • res – The json-encoded string from a webdriver exception.
  • type (message) – The type of message passed to this function. If it isn’t the default, regex ignores it.
Returns:

String of the formatted res initially passed in.

sw.formatting.stats(good, bad, timetaken, children, times, starttime)[source]

Prints out statistics for the current running pool.

This includes the following:
  • Successful/failed jobs
  • Total jobs done
  • Remaining jobs
  • Failure rate
  • Number of children currently and at peak
  • Average time per job
  • Average jobs per minute, seconds, and more
Parameters:
  • good – The number of jobs completed successfully.
  • bad – The number of jobs that failed.
  • timetaken – An array of job completion times from all children.
  • children – An array of our pool’s children. Counted and checked if alive for display.
  • times – The number of jobs initially given to our pool.
  • starttime – A timestamp for when our pool started.
Returns:

None

Table Of Contents

Previous topic

Utilities Module sw.utils

Next topic

UI Module sw.ui

This Page