# Copyright (c) 2016-2018 Intra2net AG <info@intra2net.com>
"""
-
-SUMMARY
-------------------------------------------------------
Miscellaneous system utility: Collection of various common system stuff / idioms.
Copyright: 2015 Intra2net AG
-
-CONTENTS
-------------------------------------------------------
The library exports the symbols below and some custom logging functions.
-run_cmd_with_pipe
- Wrapper for the default use case of the cumbersome "subprocess" library.
- Accepts a list of arguments that describe the command invocation. Returns
- ``True`` and the contents of ``stdout`` if the pipe returned sucessfully,
- ``False`` plus ``stderr`` and the exit status otherwise. For example::
-
- import sysmisc
- (success, output, _ret) = sysmisc.run_cmd_with_pipe([ "/usr/bin/date", "+%F" ])
- if success is True:
- print("Today is %s" % output)
- else:
- print("Failed to read date from pipe.")
-
-get_mountpoints_by_type
- Extract mount points for the given file system type from */proc/mounts*.
- Returns ``None`` if the file system is not mounted, a list of mount points
- otherwise. Raises a test error if */proc/mounts* cannot be accessed.
-
-read_linewise
- Similar to run_cmd_with_pipe but allows processing of output line-by-line
- as it becomes available. This may be necessary when the underlying binary
- creates lots of output that cannot be buffered until the process finishes.
- Example::
-
- import re
- import sysmisc
- def parse(line):
- if re.match(r'\d', line):
- print('found digits in line!')
- sysmisc.read_linewise('dump_db', parse)
-
-hash_file
- Return a hash of a file.
-
-cheat_reboot
- Replace the reboot binary with a fake one.
-
-cmd_block_till
- Run a command and wait until a condition evaluates to True.
-
-cd
- A context manager that temporarily changes the current working directory
+ * run_cmd_with_pipe
+ Wrapper for the default use case of the cumbersome "subprocess" library.
+ Accepts a list of arguments that describe the command invocation. Returns
+ ``True`` and the contents of ``stdout`` if the pipe returned sucessfully,
+ ``False`` plus ``stderr`` and the exit status otherwise. For example::
+
+ import sysmisc
+ (success, output, _ret) = sysmisc.run_cmd_with_pipe([ "/usr/bin/date", "+%F" ])
+ if success is True:
+ print("Today is %s" % output)
+ else:
+ print("Failed to read date from pipe.")
+
+ * get_mountpoints_by_type
+ Extract mount points for the given file system type from */proc/mounts*.
+ Returns ``None`` if the file system is not mounted, a list of mount points
+ otherwise. Raises a test error if */proc/mounts* cannot be accessed.
+
+ * read_linewise
+ Similar to run_cmd_with_pipe but allows processing of output line-by-line
+ as it becomes available. This may be necessary when the underlying binary
+ creates lots of output that cannot be buffered until the process finishes.
+ Example::
+
+ import re
+ import sysmisc
+ def parse(line):
+ if re.match(r'\d', line):
+ print('found digits in line!')
+ sysmisc.read_linewise('dump_db', parse)
+
+ * hash_file
+ Return a hash of a file.
+
+ * cheat_reboot
+ Replace the reboot binary with a fake one.
+
+ * cmd_block_till
+ Run a command and wait until a condition evaluates to True.
+
+ * cd
+ A context manager that temporarily changes the current working directory
The logging functions either use the format capability or play
the simple role of providing shorter names.
-
-
-INTERFACE
-------------------------------------------------------
-
"""
import re