archivebox.misc.system
Module Contents
Classes
A context manager for doing a “deep suppression” of stdout and stderr in Python, i.e. will suppress all print, even if the print originates in a compiled C/Fortran sub-function. |
Functions
Patched of subprocess.run to kill forked child subprocesses and fix blocking io making timeout=innefective Mostly copied from https://github.com/python/cpython/blob/master/Lib/subprocess.py |
|
Safe atomic write to filesystem by writing to temp file + atomic rename |
|
chmod -R |
|
copy a given file or directory to a given path, overwriting the destination |
|
get the total disk size of a given directory, optionally summing up recursively and limiting to a given filter list |
|
Data
API
- archivebox.misc.system.__package__
‘archivebox.misc’
- archivebox.misc.system.run(cmd, *args, input=None, capture_output=True, timeout=None, check=False, text=False, start_new_session=True, **kwargs)
Patched of subprocess.run to kill forked child subprocesses and fix blocking io making timeout=innefective Mostly copied from https://github.com/python/cpython/blob/master/Lib/subprocess.py
- archivebox.misc.system.atomic_write(path: Union[pathlib.Path, str], contents: Union[dict, str, bytes], overwrite: bool = True) None
Safe atomic write to filesystem by writing to temp file + atomic rename
- archivebox.misc.system.chmod_file(path: str, cwd: str = '') None
chmod -R
/
- archivebox.misc.system.copy_and_overwrite(from_path: Union[str, pathlib.Path], to_path: Union[str, pathlib.Path])
copy a given file or directory to a given path, overwriting the destination
- archivebox.misc.system.get_dir_size(path: Union[str, pathlib.Path], recursive: bool = True, pattern: Optional[str] = None) Tuple[int, int, int]
get the total disk size of a given directory, optionally summing up recursively and limiting to a given filter list
- archivebox.misc.system.CRON_COMMENT
‘archivebox_schedule’
- archivebox.misc.system.dedupe_cron_jobs(cron: crontab.CronTab) crontab.CronTab
- class archivebox.misc.system.suppress_output(stdout=True, stderr=True)
Bases:
object
A context manager for doing a “deep suppression” of stdout and stderr in Python, i.e. will suppress all print, even if the print originates in a compiled C/Fortran sub-function.
This will not suppress raised exceptions, since exceptions are printed to stderr just before a script exits, and after the context manager has exited (at least, I think that is why it lets exceptions through).
with suppress_stdout_stderr(): rogue_function()
Initialization
- __enter__()
- __exit__(*_)