ape.parts.watchers.thewatcher.TheWatcher

class ape.parts.watchers.thewatcher.TheWatcher(query, storage, fields, use_header=True, interval=1, separator=', ', use_timestamp=True, timestamp=None)

A watcher of wifi information

TheWatcher constructor

Param:
  • query: A query (e.g. IwconfigQuery)
  • storage: a file-like (thread-safe) object to write output to
  • fields: a list of attribute-names for the query object
  • use_header: if True, saves field-names as header before data starts
  • interval: seconds between queries
  • separator: token to separate fields in the data output
  • use_timestamp: if true first column of data will be timestamp
  • timestamp: timestamp format (strftime format) (uses storage.timestamp if None)
__init__(query, storage, fields, use_header=True, interval=1, separator=', ', use_timestamp=True, timestamp=None)

TheWatcher constructor

Param:
  • query: A query (e.g. IwconfigQuery)
  • storage: a file-like (thread-safe) object to write output to
  • fields: a list of attribute-names for the query object
  • use_header: if True, saves field-names as header before data starts
  • interval: seconds between queries
  • separator: token to separate fields in the data output
  • use_timestamp: if true first column of data will be timestamp
  • timestamp: timestamp format (strftime format) (uses storage.timestamp if None)

Methods

__init__(query, storage, fields[, ...]) TheWatcher constructor
check_rep() Checks that the querier has the fields passed in
close() sets stopped to true, closes storage
log_data(*args, **kwargs)
log_error(error[, message]) Logs the error in bold red
run() The method to be called by the BaseThreadClass’ run_thread
run_thread(*args, **kwargs)
param:Whatever self.run accepts
stop()
postcondition:self.stopped is True

Attributes

header
return:fields joined by separator to use as first line of data output
logger
return:A logging object.
thread This passes no arguments to run_thread – override if needed
timer An event timer for the wait decorator to keep time
check_rep()

Checks that the querier has the fields passed in

close()

sets stopped to true, closes storage

log_error(error, message='')

Logs the error in bold red

Param:
  • error: error type (prefix in red and bold)
  • message: descriptive message (red but not bold)
run()

The method to be called by the BaseThreadClass’ run_thread

run_thread(*args, **kwargs)
Param:Whatever self.run accepts
Precondition:self.run method exists and is thread-safe
stop()
Postcondition:self.stopped is True
header
Returns:fields joined by separator to use as first line of data output
logger
Returns:A logging object.
thread

This passes no arguments to run_thread – override if needed

Returns:threading.Thread with self.run_thread as target and daemon True
timer

An event timer for the wait decorator to keep time

timestamp
Returns:strftime string format for datetime

Navigation