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.run(cmd, *args, input=None, capture_output=True, timeout=None, check=False, text=False, start_new_session=True, **kwargs)[source]
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: pathlib.Path | str, contents: dict | str | bytes, overwrite: bool = True, config=None, **config_kwargs) None[source]
Safe atomic write to filesystem by writing to temp file + atomic rename
- archivebox.misc.system.chmod_file(path: str, cwd: str = '', config=None, **config_kwargs) None[source]
chmod -R
/
- archivebox.misc.system.copy_and_overwrite(from_path: str | pathlib.Path, to_path: str | pathlib.Path)[source]
copy a given file or directory to a given path, overwriting the destination
- archivebox.misc.system.get_dir_size(path: str | pathlib.Path, recursive: bool = True, pattern: str | None = None) tuple[int, int, int][source]
get the total disk size of a given directory, optionally summing up recursively and limiting to a given filter list
- class archivebox.misc.system.suppress_output(stdout=True, stderr=True)[source]
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