Skip to content
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

[UI][Common] Add daemon version check #427

Conversation

DjLegolas
Copy link
Contributor

For new UI features to be added, one should make sure the backend daemon is supported and add fallback in case it doesn't.
Here we add the ability to get the daemon version from the Client class and also check the version against a desired version.

@DjLegolas DjLegolas force-pushed the Feature/add-daemon-version-to-ui branch from 548a3c0 to a9044df Compare June 3, 2023 07:40
@DjLegolas
Copy link
Contributor Author

@cas-- - this is going to be a dependency for some other MRs, so it will be best to merge this first.
I'll link each MR that needs this one so it will be easier to manage.


return ''

def is_daemon_version_equal_or_greater(self, version_check):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can improve on the naming here and simplify it.

The expected use-case is new core functionality usage by the client so that could either be the latest daemon version or less likely a previous version. So the parameter can be an optional version where we use get_version() as default.

From there the method naming could be improved to is_daemon_compatible unless you have other suggestions?

return ''

def is_daemon_version_equal_or_greater(self, version_check):
if VersionSplit(version_check) and self.connected():
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't need these checks since VersionSplit will always return True or TypeError and calling above function does a connected check. Instead I would add a guard clause:

if not (daemon_version and version):
    return False

@@ -741,6 +743,25 @@ def connection_info(self):

return None

def connection_version(self):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel this is ambiguous method name since it is not clearly defining whether this is daemon or client version. I think would be better as daemon_version and probably nice as a property.

I know that using connection ties into connection_info but that also feels rather vague, especially since we get version using daemon.info RPC call...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, ok, changed

Comment on lines 753 to 756
if self.connected():
return self._daemon_proxy.daemon_info

return ''
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be a one line return:

Suggested change
if self.connected():
return self._daemon_proxy.daemon_info
return ''
return self._daemon_proxy.daemon_info if self.connected() else ''

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed

Get the connected daemon version

Returns:
str: the daemon version
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The str type should be moved to function definition

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

For new UI features to be added, one should make sure the backend daemon
is supported and add fallback in case it doesn't.
Here we add the ability to get the daemon version from the `Client`
class and also check the version against a desired version.
@DjLegolas DjLegolas force-pushed the Feature/add-daemon-version-to-ui branch from a9044df to d60ccf0 Compare June 3, 2023 15:43
@DjLegolas
Copy link
Contributor Author

Don't know why I'm responding to each message when I can just write here - all changed as suggested :)

@cas-- cas-- closed this in 1989d0d Nov 20, 2023
@cas--
Copy link
Member

cas-- commented Nov 20, 2023

Thanks for this!

I did change my mind about the naming of the function and settled on daemon_version_check_min. I wanted it to be descriptive but not verbose, almost chose is_daemon_version_at_least! I did ponder creating a DaemonConnection class but not sure it would have gained much more clarity here.

doadin pushed a commit to doadin/deluge that referenced this pull request Jun 4, 2024
For new UI features to be added, one should make sure the backend daemon
is supported and add fallback in case it doesn't.
Here we add the ability to get the daemon version from the `Client`
class and also check the version against a desired version.

Closes: deluge-torrent#427
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants