Guest User

Untitled

a guest
Jul 13th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.49 KB | None | 0 0
  1. $ Projects/deluge-geektool.py
  2. Connection was successful!
  3. Connection failed!
  4. result: [Failure instance: Traceback: <type 'exceptions.TypeError'>: 'RemoteMethod' object is unsubscriptable
  5. /sw/lib/python2.5/site-packages/twisted/internet/defer.py:328:_runCallbacks
  6. /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
  7. /sw/lib/python2.5/site-packages/twisted/internet/defer.py:243:callback
  8. /sw/lib/python2.5/site-packages/twisted/internet/defer.py:312:_startRunCallbacks
  9. --- <exception caught here> ---
  10. /sw/lib/python2.5/site-packages/twisted/internet/defer.py:328:_runCallbacks
  11. Projects/deluge-geektool.py:32:on_connect_success
  12. ]
  13. ## deluge-geektool.py
  14.  
  15. #!/sw/bin/python2.5
  16. # Import the client module
  17. from deluge.ui.client import client
  18. # Import the reactor module from Twisted - this is for our mainloop
  19. from twisted.internet import reactor
  20. import deluge.component as component
  21. import deluge.common
  22. from deluge.ui.client import client
  23. # Set up the logger to print out errors
  24. from deluge.log import setupLogger
  25. setupLogger()
  26.  
  27. # Connect to a daemon running on the localhost
  28. # We get a Deferred object from this method and we use this to know if and when
  29. # the connection succeeded or failed.
  30. d = client.connect(host='192.168.1.200', port=58846, username='jackolas', password='securepassword')
  31.  
  32. # We create a callback function to be called upon a successful connection
  33. def on_connect_success(result):
  34. print "Connection was successful!"
  35. def on_get_config_value(value, key):
  36. print "Got config value from the daemon!"
  37. print "%s: %s" % (key, value)
  38. client.core.get_session_status()
  39. # Disconnect from the daemon once we've got what we needed
  40. client.disconnect()
  41.  
  42. # Stop the twisted main loop and exit
  43. reactor.stop()
  44.  
  45. # Request the config value for the key 'download_location'
  46. client.core.get_config_values["max_download_speed", "max_upload_speed"].addCallback(on_get_config_value, ["max_download_speed", "max_upload_speed"])
  47.  
  48.  
  49. # We add the callback to the Deferred object we got from connect()
  50. d.addCallback(on_connect_success)
  51.  
  52. # We create another callback function to be called when an error is encountered
  53. def on_connect_fail(result):
  54. print "Connection failed!"
  55. print "result:", result
  56.  
  57. # We add the callback (in this case it's an errback, for error)
  58. d.addErrback(on_connect_fail)
  59.  
  60. # Run the twisted main loop to make everything go
  61. reactor.run()
Add Comment
Please, Sign In to add comment