rsudp.__init__
(initialization functions)¶
These are the initialization functions in rsudp.
The useful things here are likely printM
, printW
and printE
which interface with the logging utility to print messages, warnings,
and errors in color and save them to the logs.
-
class
rsudp.__init__.
LevelFormatter
(fmt=None, datefmt=None, level_fmts={})¶ A class that formats messages differently depending on their level. Adapted from this stackoverflow answer.
Parameters: - fmt (str or None) – Format of message strings (see
logging
; example:'%(asctime)-15s %(msg)s'
) - datefmt (str or None) – Date strings in strftime format (see
logging
example:'%Y-%m-%d %H:%M:%S'
) - level_fmts (dict) – Dictionary of log levels and associated formats
{logging.INFO: 'infoformat', logging.WARNING: 'warnformat', logging.ERROR: 'errformat'}
- fmt (str or None) – Format of message strings (see
-
rsudp.__init__.
add_debug_handler
(testing=False)¶ Creates an additional handler for logging info and warnings to the command line.
Parameters: testing (bool) – whether or not testing is active (adds a “TESTING” label to messages) Returns: True
Return type: bool
-
rsudp.__init__.
get_scap_dir
()¶ This function returns the screen capture directory from the init function. This allows the variable to be more threadsafe.
>>> get_scap_dir() '/home/pi/rsudp/screenshots/'
Returns: the path of the screenshot directory
-
rsudp.__init__.
init_dirs
(odir)¶ Initialize the write directories if they do not already exist.
Parameters: odir (str) – output directory Returns: True
Return type: bool
-
rsudp.__init__.
make_colors_friendly
()¶ Makes colors Windows-friendly if necessary.
-
rsudp.__init__.
printE
(msg, sender='', announce=True, spaces=False)¶ Prints errors with datetime stamp and sends their output to the logging handlers.
Parameters:
-
rsudp.__init__.
printM
(msg, sender='', announce=False)¶ Prints messages with datetime stamp and sends their output to the logging handlers.
Parameters:
-
rsudp.__init__.
printW
(msg, sender='', announce=True, spaces=False)¶ Prints warnings with datetime stamp and sends their output to the logging handlers.
Parameters: