Commits

anothergene committed bfe4665

added a script for listing the active torrents.

  • Participants
  • Parent commits 84b5559

Comments (0)

Files changed (1)

transmission-list.py

+#!/usr/bin/env python
+'''
+Created on Feb 5, 2011
+
+@author: gmoreau
+'''
+import transmissionrpc
+import logging
+from datetime import datetime
+
+TRANS_HOST = '192.168.100.150'  # The host transmission is running on
+TRANS_PORT = '9091' # The port the host is listening on
+TRANS_USER =  ''    # The user id you have set
+TRANS_PW = ''   # the password you have set
+ID_WIDTH = 5
+NAME_WIDTH = 60
+STATUS_WIDTH = 10
+PROG_WIDTH = 8
+RATIO_WIDTH = 8
+AGE_WIDTH = 15
+
+def FormatTD(self): 
+    hours = self.seconds // 3600 
+    minutes = (self.seconds % 3600) // 60 
+    seconds = self.seconds % 60 
+    return '%02d:%02d:%02d:%02d' % (self.days, hours, minutes, seconds) 
+
+def Main():
+    tc = transmissionrpc.Client(TRANS_HOST, TRANS_PORT, TRANS_USER, TRANS_PW)
+    tl = tc.info()
+    
+    print 'ID'.ljust(ID_WIDTH) + \
+    'Name'.ljust(NAME_WIDTH) + \
+    'Status'.ljust(STATUS_WIDTH) + \
+    'Prog'.ljust(PROG_WIDTH) + \
+    'Ratio'.ljust(RATIO_WIDTH) + \
+    'Age'.ljust(AGE_WIDTH)
+         
+    for t in tl:
+        print str(t).ljust(ID_WIDTH) + \
+        tl[t].name.ljust(NAME_WIDTH) + \
+        tl[t].status.ljust(STATUS_WIDTH) + \
+        str(round(tl[t].progress,2)).ljust(PROG_WIDTH) + \
+        str(round(tl[t].ratio,2)).ljust(RATIO_WIDTH) + \
+        FormatTD(datetime.now() - tl[t].date_added).ljust(AGE_WIDTH)
+  
+if __name__ == '__main__':
+    Main()
+        
+        
+        
+