-
Notifications
You must be signed in to change notification settings - Fork 1
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
renamed and moved ComponentStatus enum #15
Conversation
@@ -12,6 +12,9 @@ def get(self, *, value, column="component_uid"): | |||
return super().get(value=value, column=column) | |||
|
|||
def enable(self, *, component: M.Component): | |||
|
|||
if component.status == CS.DOWNLOAD_COMPLETE and component.enabled is True: | |||
return component | |||
component.enabled = True | |||
component.status = "SCHEDULED" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
component.status = CS.SCHEDULED I think no ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. I missed that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably CS.SCHEDULED.value, but test both
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
zpodcommon/src/zpodcommon/enums.py
Outdated
DOWNLOAD_COMPLETE = "DOWNLOAD_COMPLETE" | ||
FAILED_AUTHENTICATION = "FAILED_AUTHENTICATION" | ||
SCHEDULED = "SCHEDULED" | ||
DOWNLOAD_INCOMPLETE = "DOWNLOAD_INCOMPLETE " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove extra space after DOWNLOAD_INCOMPLETE
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I fixed the extra space
@@ -12,6 +12,9 @@ def get(self, *, value, column="component_uid"): | |||
return super().get(value=value, column=column) | |||
|
|||
def enable(self, *, component: M.Component): | |||
|
|||
if component.status == CS.DOWNLOAD_COMPLETE and component.enabled is True: | |||
return component | |||
component.enabled = True | |||
component.status = "SCHEDULED" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably CS.SCHEDULED.value, but test both
@@ -1,5 +1,5 @@ | |||
from sqlmodel import SQLModel | |||
|
|||
from zpodcommon.enums import ComponentStatus as CS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like isort wasn't applied here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
applied isort
@@ -178,11 +170,11 @@ def download_component(component: Component) -> int: | |||
return 0 | |||
except RuntimeError as e: | |||
if e.args[0] == "AuthenticationError": | |||
update_db(component.component_uid, DownloadState.FAILED_AUTHENTICATION.name) | |||
update_db(component.component_uid, CS.FAILED_AUTHENTICATION) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you need .value here?
logger.error("The provided credentials are not correct.") | ||
raise e | ||
if e.args[0] == "EntitlementError": | ||
update_db(component.component_uid, DownloadState.NOT_ENTITLED.name) | ||
update_db(component.component_uid, CS.NOT_ENTITLED.name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you need .value here instead of .name or remove .name?
@@ -258,7 +250,7 @@ def verify_checksum(component: Component, filename: Path) -> bool: | |||
if component.component_download_file_checksum is None: | |||
if component.component_dl_path.exists(): | |||
update_db( | |||
uid=component.component_uid, status=DownloadState.DOWNLOAD_COMPLETE.name | |||
uid=component.component_uid, status=CS.DOWNLOAD_COMPLETE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you need .value here?
@@ -269,11 +261,11 @@ def verify_checksum(component: Component, filename: Path) -> bool: | |||
logger.info(f"Checksum: {checksum}") | |||
if checksum != expected_checksum: | |||
update_db( | |||
uid=component.component_uid, status=DownloadState.DOWNLOAD_INCOMPLETE.name | |||
uid=component.component_uid, status=CS.DOWNLOAD_INCOMPLETE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you need .value here?
) | ||
raise ValueError("Checksum does not match") | ||
logger.info(f"Updating {component.component_uid} status") | ||
update_db(uid=component.component_uid, status=DownloadState.DOWNLOAD_COMPLETE.name) | ||
update_db(uid=component.component_uid, status=CS.DOWNLOAD_COMPLETE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you need .value here?
CS.FAILED_AUTHENTICATION, | ||
CS.FAILED_DOWNLOAD, | ||
CS.NOT_ENTITLED, | ||
CS.DOWNLOAD_COMPLETE, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you need .value here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. I tested it and it worked just fine. Initially it was defined as int and needed string that's why I used the .name above
In this PR;