Skip to content

Commit

Permalink
Move unzip function to update_utils.py
Browse files Browse the repository at this point in the history
Move unzip function to update_utils.py
  • Loading branch information
shashank40 committed Jun 21, 2024
1 parent 27f4ab8 commit 8f4aea0
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 19 deletions.
3 changes: 2 additions & 1 deletion openadapt/app/tray.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 0 additions & 18 deletions openadapt/build_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
21 changes: 21 additions & 0 deletions openadapt/update_utils.py
Original file line number Diff line number Diff line change
@@ -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")

0 comments on commit 8f4aea0

Please sign in to comment.