In the docs it's stated that plugins can use deluge.ui.client API through coreclient wrapper, however that wrapper(coreclient.py) has been removed so cannot be utilized anymore.
When making a python client script, instead of plugin, then I can comunicate with daemon through deluge.ui.client fine, but I cannot from plugin, obviously, as docs state, but was wondering why removed wrapper and what's the alternative.
My main thing is that I want to utilize client.daemon.shutdown(), to close daemon, which I can only do in client script and not plugin, as errors out with no call atribute from nonetype object. Other simple api-calls I tested from that, like client.daemon.get_version() through a twisted addCallback, also doesn't work from plugin, only in my script, as previous issue(tested since was thinking maybe only daemon.shutdown() being problematic and the ui.client limitation possibly lifted since wrapper removed, hence the further tests).
Is there something else I can do? Sorry in advance for beeing a complete noob in this I have messed with this on and off for months actually, trying alternative variations of component.get.xxxx etc calls(mainly 'component.get("Core").shutdown()' where docs states also stops daemon, erronyously, as not even works from client script neither), but cannot see how can call daemon's shutdown() command there, and also tried importing deluge.core.daemon and calling it's shutdown() still without luck(Then realized it's from a Daemon() class therein, so then tried importing the Daemon class from it, instatiate it and call it's shutdown() funtion, or _shutdown() one, or it's content direct instead i.e. component.stop or reactor.stop etc etc, no luck with anything though), so thought I finally would ask for help here. Thanks alot again in advance.
I searched the git commit log for the commit that removed the coreclient.py wrapper, for an explenation maybe, or alternative, but the commit only deletes the file and adds example plugin and various seemingly irrelevant other stuff. This is the commit message, and the removal part, strangely replaced with entirely unrelated file, but probaby just the way git/diff works i'm sure:
Code: Select all
martin@arch ~/Downloads/deluge % git log --full-history -1 -- deluge/plugins/coreclient.py commit 703e9def05584bef55f822e00ad471a586a530e8 Author: Andrew Resch <email@example.com> Date: Mon Feb 23 23:54:06 2009 +0000 Change some plugin stuff and add an example plugin
I even added the coreclient.py wrapper back in-place manually, and called it as referenced in docs, but then error out about no attribute funcs in core object, though not surpricingly since so freakin old codebase it was from.
Code: Select all
martin@arch ~/Downloads/deluge % git show 703e9 [...] diff --git a/deluge/plugins/coreclient.py b/deluge/plugins/example/example/webui.py similarity index 61% rename from deluge/plugins/coreclient.py rename to deluge/plugins/example/example/webui.py index d39778098..c75ce8858 100644 --- a/deluge/plugins/coreclient.py +++ b/deluge/plugins/example/example/webui.py @@ -1,7 +1,7 @@ # -# coreclient.py +# webui.py # -# Copyright (C) 2008 Martijn Voncken <firstname.lastname@example.org> +# Copyright (C) 2009 Martijn Voncken <email@example.com> # # Deluge is free software. # @@ -23,19 +23,13 @@ # +from deluge.log import LOG as log +from deluge.ui.client import client +from deluge import component -import deluge.component as component - -class CoreClient(object): - """ - provides the uiclient interface to core plugins - see http://dev.deluge-torrent.org/wiki/Development/UiClient - """ - def __init__(self): - self.core = component.get("Core") - - def __getattr__(self, func_name): - return self.core.funcs[func_name] - -client = CoreClient() +class WebUI(WebPluginBase): + def enable(self): + log.debug("Example Web plugin enabled!") + def disable(self): + log.debug("Example Web plugin disabled!") [...]
(Autoshutdown plugin from Cas don't feature close daemon functionality, which I else of-course would have used for inspiration, and an unmerged pull-request submitted, was using the GTKUI api for it, well 'MainWindow', whereas I wanna have it working from thinclient without UIs running.)