-
-
Notifications
You must be signed in to change notification settings - Fork 138
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move unzip function to update_utils.py
Move unzip function to update_utils.py
- Loading branch information
1 parent
27f4ab8
commit 8f4aea0
Showing
3 changed files
with
23 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |