-
-
Notifications
You must be signed in to change notification settings - Fork 191
Feat : Add download update feature in user app. Issue #755 #782
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
shashank40
wants to merge
14
commits into
OpenAdaptAI:main
Choose a base branch
from
shashank40:feat/download_latest_app_updates
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+231
−16
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
85baf3f
Feat : Add download update feature in user app. Issue #755
shashank40 8dc47e7
Added functionality to unzip
shashank40 3bb05ba
Formatting fixes
shashank40 656e0fb
Move unzip function to update_utils.py
shashank40 57027e9
Added toast post download complete
shashank40 f579890
Added live update of download
shashank40 70815f5
Moved from global to threading event
shashank40 c4e72f7
refactor file_name/download_url
abrichr d00fad3
fix file_name; update pyqttoast
abrichr ca1993b
Added try/catch to download file
shashank40 cb99b9a
Added diable action + unzipping toast
shashank40 fdd140e
Added try catch to set permissions
shashank40 623a4c3
Permission set only on specified folder while unzipping
shashank40 322cd6b
Handling toast with .hide()
shashank40 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
---|---|---|
@@ -1,12 +1,25 @@ | ||
"""Get the version of the package.""" | ||
|
||
import importlib.metadata | ||
import requests | ||
import json | ||
|
||
APP_VERSION_URL = ( | ||
"https://api.github.com/repos/OpenAdaptAI/OpenAdapt/releases?per_page=10&page=1" | ||
) | ||
|
||
|
||
def get_version() -> str: | ||
"""Get the version of the package.""" | ||
return importlib.metadata.version("openadapt") | ||
|
||
|
||
def get_latest_version() -> str: | ||
"""Get the latest version of the app available.""" | ||
response = requests.get(APP_VERSION_URL, stream=True) | ||
data = json.loads(response.text) | ||
return data[0]["tag_name"].replace("v", "") | ||
|
||
|
||
if __name__ == "__main__": | ||
print(get_version()) |
This file contains hidden or 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 hidden or 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,38 @@ | ||
"""Utility functions for the download app updates.""" | ||
|
||
import os | ||
import shutil | ||
|
||
from loguru import logger | ||
|
||
|
||
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: | ||
dir_path = os.path.join(root, dir) | ||
try: | ||
os.chmod(os.path.join(root, dir), 0o755) | ||
except PermissionError: | ||
logger.info(f"Skipping directory due to PermissionError: {dir_path}") | ||
except Exception as e: | ||
logger.info(f"An error occurred for directory {dir_path}: {e}") | ||
for file in files: | ||
file_path = os.path.join(root, file) | ||
try: | ||
os.chmod(os.path.join(root, file), 0o755) | ||
except PermissionError: | ||
logger.info(f"Skipping file due to PermissionError: {file_path}") | ||
except Exception as e: | ||
logger.info(f"An error occurred for file {file_path}: {e}") | ||
|
||
|
||
def unzip_file(file_path: str, base_file_name: str) -> None: | ||
"""Unzip a file to the given directory.""" | ||
if os.path.exists(file_path): | ||
unzipping_directory_path = f"{os.path.dirname(file_path)}/{base_file_name}" | ||
if not os.path.exists(unzipping_directory_path): | ||
os.makedirs(unzipping_directory_path) | ||
shutil.unpack_archive(file_path, unzipping_directory_path) | ||
set_permissions(unzipping_directory_path) | ||
logger.info("Unzipped") |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.