diff --git a/exec/file.py b/exec/file.py index 00653aa..c677e09 100644 --- a/exec/file.py +++ b/exec/file.py @@ -4,7 +4,7 @@ import os import stat import subprocess -from shutil import rmtree +from shutil import copyfile, rmtree from tempfile import mkdtemp from typing import Optional, Union @@ -41,7 +41,7 @@ def chown(path: str, user: Optional[Union[str, int]] = None, group: Optional[Uni raise Exception(f"Failed to change owner of '{path}' to '{owner}'") -def chmod(path, mode: Union[int, str] = 0o0755, force_sticky=True, privileged: bool = True): +def chmod(path: str, mode: Union[int, str] = 0o0755, force_sticky=True, privileged: bool = True): if not isinstance(mode, str): octal = oct(mode)[2:] else: @@ -60,11 +60,14 @@ def chmod(path, mode: Union[int, str] = 0o0755, force_sticky=True, privileged: b raise Exception(f"Failed to set mode of '{path}' to '{chmod}'") -def root_check_exists(path): +copy_file = copyfile + + +def root_check_exists(path: str): return os.path.exists(path) or run_root_cmd(['[', '-e', path, ']']).returncode == 0 -def root_check_is_dir(path): +def root_check_is_dir(path: str): return os.path.isdir(path) or run_root_cmd(['[', '-d', path, ']'])