diff --git a/openadapt/app/tray.py b/openadapt/app/tray.py index dfa3be5fa..1cc13eb65 100644 --- a/openadapt/app/tray.py +++ b/openadapt/app/tray.py @@ -41,7 +41,8 @@ from openadapt.app.dashboard.run import cleanup as cleanup_dashboard from openadapt.app.dashboard.run import run as run_dashboard from openadapt.app.main import FPATH # , start -from openadapt.build_utils import is_running_from_executable, unzip_file +from openadapt.build_utils import is_running_from_executable +from openadapt.update_utils import unzip_file from openadapt.db import crud from openadapt.models import Recording from openadapt.replay import replay diff --git a/openadapt/build_utils.py b/openadapt/build_utils.py index 010901237..36d748725 100644 --- a/openadapt/build_utils.py +++ b/openadapt/build_utils.py @@ -3,24 +3,6 @@ import os import pathlib import sys -import shutil - - -def set_permissions(path: str) -> None: - """Set the permissions of all files to make the executable.""" - for root, dirs, files in os.walk(path): - for dir in dirs: - os.chmod(os.path.join(root, dir), 0o755) - for file in files: - os.chmod(os.path.join(root, file), 0o755) - - -def unzip_file(file_path: str) -> None: - """Unzip a file to the given directory.""" - if os.path.exists(file_path): - shutil.unpack_archive(file_path, os.path.dirname(file_path)) - set_permissions(os.path.dirname(file_path)) - print("Unzipped") def get_root_dir_path() -> pathlib.Path: diff --git a/openadapt/update_utils.py b/openadapt/update_utils.py new file mode 100644 index 000000000..2b37e58ef --- /dev/null +++ b/openadapt/update_utils.py @@ -0,0 +1,21 @@ +"""Utility functions for the download app updates.""" + +import os +import shutil + + +def set_permissions(path: str) -> None: + """Set the permissions of all files to make the executable.""" + for root, dirs, files in os.walk(path): + for dir in dirs: + os.chmod(os.path.join(root, dir), 0o755) + for file in files: + os.chmod(os.path.join(root, file), 0o755) + + +def unzip_file(file_path: str) -> None: + """Unzip a file to the given directory.""" + if os.path.exists(file_path): + shutil.unpack_archive(file_path, os.path.dirname(file_path)) + set_permissions(os.path.dirname(file_path)) + print("Unzipped")