Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $ Projects/deluge-geektool.py
- Connection was successful!
- Connection failed!
- result: [Failure instance: Traceback: <type 'exceptions.TypeError'>: 'RemoteMethod' object is unsubscriptable
- /sw/lib/python2.5/site-packages/twisted/internet/defer.py:328:_runCallbacks
- /sw/lib/python2.5/site-packages/deluge-1.2.0_dev-py2.5-macosx-10.5-i386.egg/deluge/ui/client.py:392:__on_login
- /sw/lib/python2.5/site-packages/twisted/internet/defer.py:243:callback
- /sw/lib/python2.5/site-packages/twisted/internet/defer.py:312:_startRunCallbacks
- --- <exception caught here> ---
- /sw/lib/python2.5/site-packages/twisted/internet/defer.py:328:_runCallbacks
- Projects/deluge-geektool.py:32:on_connect_success
- ]
- ## deluge-geektool.py
- #!/sw/bin/python2.5
- # Import the client module
- from deluge.ui.client import client
- # Import the reactor module from Twisted - this is for our mainloop
- from twisted.internet import reactor
- import deluge.component as component
- import deluge.common
- from deluge.ui.client import client
- # Set up the logger to print out errors
- from deluge.log import setupLogger
- setupLogger()
- # Connect to a daemon running on the localhost
- # We get a Deferred object from this method and we use this to know if and when
- # the connection succeeded or failed.
- d = client.connect(host='192.168.1.200', port=58846, username='jackolas', password='securepassword')
- # We create a callback function to be called upon a successful connection
- def on_connect_success(result):
- print "Connection was successful!"
- def on_get_config_value(value, key):
- print "Got config value from the daemon!"
- print "%s: %s" % (key, value)
- client.core.get_session_status()
- # Disconnect from the daemon once we've got what we needed
- client.disconnect()
- # Stop the twisted main loop and exit
- reactor.stop()
- # Request the config value for the key 'download_location'
- client.core.get_config_values["max_download_speed", "max_upload_speed"].addCallback(on_get_config_value, ["max_download_speed", "max_upload_speed"])
- # We add the callback to the Deferred object we got from connect()
- d.addCallback(on_connect_success)
- # We create another callback function to be called when an error is encountered
- def on_connect_fail(result):
- print "Connection failed!"
- print "result:", result
- # We add the callback (in this case it's an errback, for error)
- d.addErrback(on_connect_fail)
- # Run the twisted main loop to make everything go
- reactor.run()
Add Comment
Please, Sign In to add comment