example_clearall.py 919 B

1234567891011121314151617181920212223242526272829303132333435
  1. import sys
  2. from pyaria2 import Xmlrpc
  3. rpc = Xmlrpc('localhost', 6800)
  4. resp = rpc.getGlobalStat()
  5. print resp
  6. if( int(resp["numActive"]) > 0 ):
  7. resp2 = rpc.tellActive()
  8. print resp2
  9. for i in resp2:
  10. rpc.remove(i["gid"])
  11. rpc.removeDownloadResult(i["gid"])
  12. if( int(resp["numWaiting"]) > 0):
  13. offset = 0
  14. num = int(resp["numWaiting"])
  15. resp2 = rpc.tellWaiting(offset,num)
  16. print resp2
  17. for i in resp2:
  18. rpc.remove(i["gid"])
  19. rpc.removeDownloadResult(i["gid"])
  20. if( int(resp["numStopped"]) > 0):
  21. offset = 0
  22. num = int(resp["numStopped"])
  23. print num
  24. print "numStopped"
  25. resp2 = rpc.tellStopped(offset,num)
  26. print resp2[0]["files"][0]["uris"]
  27. for i in resp2:
  28. rpc.remove(i["gid"])#may occurs errors like: <Fault 1: Active Download not found for GID#3c9df48c8ff636e6>...
  29. rpc.removeDownloadResult(i["gid"]) #clear the records