pyloggr.utils package¶
The utils subpackage provides various tools used by other packages.
-
ask_question
(question)[source]¶ Ask a Y/N question on command line
Parameters: question – question text Returns: user answer Return type: bool
-
check_directory
(dname, uid=None, gid=None, create=True)[source]¶ Checks that directory dname exists (we create it if needed), is really a directory, and is writeable
Parameters: dname – directory name Returns: absolute directory name Return type: str Raises OSError: when tests fail
-
chown_r
(path, uid, gid)[source]¶ Recursively chown a directory
Parameters: - path – directory path
- uid – numeric UID
- gid – numeric GID
-
drop_capabilities
(all=True)[source]¶ Drop capabilities on Linux in case pyloggr runs as root. Only keep “net_bind_service” and “syslog”.
-
make_dir_r
(path)[source]¶ Recursively create directories
Parameters: path – directory to create Returns: list of created directories
-
sanitize_key
(key)[source]¶ Remove unwanted chars (=, spaces, quote marks, [], (), commas) from key. Convert to pure ASCII.
Parameters: key – key Returns: sanitized key Return type: unicode
-
sanitize_tag
(tag)[source]¶ Remove unwanted chars from tag
Parameters: tag – tag Returns: sanitized tag Return type: unicode
-
sleep
(duration, wake_event=None, threading_event=None)[source]¶ Return a Future that just ‘sleeps’. The Future can be interrupted in case of process shutdown.
Parameters: - duration (int) – sleep time in seconds
- wake_event (toro.Event) – optional event to wake the sleeper
- threading_event (threading.Event) – optional threading.Event to wake up the sleeper
Return type: Future