Source

TransmissionScripts / transmission-list.py

Diff from to

transmission-list.py

-#!/usr/bin/env python
-'''
-Created on Feb 5, 2011
+#!/usr/bin/env python2.7
 
-@author: gmoreau
-'''
 import transmissionrpc
 import logging
-from datetime import datetime
+import argparse
+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
     return '%02d:%02d:%02d:%02d' % (self.days, hours, minutes, seconds) 
 
 def Main():
-    tc = transmissionrpc.Client(TRANS_HOST, TRANS_PORT, TRANS_USER, TRANS_PW)
+    options = argparse.ArgumentParser(description='Removes all torrents on a given host that are either older then the given days or have a larger then given ratio')
+    options.add_argument('-p', '--port', default='9091', help='port to connect on. default=9091')
+    options.add_argument('-u', '--user', default='', help='The user to connect as. Defaults to empty')
+    options.add_argument('-w', '--password', default='', help='The password to connect with.  Default is empty')
+    options.add_argument('host', default='localhost', help='the host to connect to. default=localhost')
+    theargs = options.parse_args()
+    
+    tc = transmissionrpc.Client(theargs.host, theargs.port, theargs.user, theargs.password)
     tl = tc.info()
     
     print 'ID'.ljust(ID_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)
+        FormatTD(datetime.datetime.now() - tl[t].date_added).ljust(AGE_WIDTH)
   
 if __name__ == '__main__':
     Main()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.