Commits

Erik Svensson committed 61d45e2

Additional Transmission 2.40 changes.
Fixed test.
Fixed RPC Version handling in Torrent.

Comments (0)

Files changed (4)

contrib/helical.py

         except transmissionrpc.TransmissionError, e:
             print(u'Failed to add torrent "%s"' % e)
 
+    def do_magnet(self, line):
+        args = self.arg_tokenize(line)
+
+        if len(args) == 0:
+            print(u'Specify a torrent file or url')
+            return
+
+        torrent_url = args[0]
+        
+        try:
+            self.tc.add_uri(torrent_url)
+        except transmissionrpc.TransmissionError, e:
+            print(u'Failed to add torrent "%s"' % e)
+            
     def complete_remove(self, text, line, begidx, endidx):
         return self._complete_torrent_command(text, line, begidx, endidx)
 
         
         data = {
             'id': 1,
-            'status': transmissionrpc.constants.TR_STATUS_DOWNLOAD,
+            'status': 4,
             'sizeWhenDone': 1000,
             'leftUntilDone': 500,
             'uploadedEver': 1000,
     def testUnicode(self):
         torrent = transmissionrpc.Torrent(None, {'id': 42, 'name': 'あみ'})
         self.assertEqual(torrent.id, 42)
-        torrent
+        repr(torrent)
         str(torrent)
 
 def suite():

transmissionrpc/constants.py

         'priority-high':                ('array', 1, None, None, None, "A list of file id's that should have high priority."),
         'priority-low':                 ('array', 1, None, None, None, "A list of file id's that should have normal priority."),
         'priority-normal':              ('array', 1, None, None, None, "A list of file id's that should have low priority."),
-        'queuePosition':                ('number', 14, None, None, None, 'Position of this torrent in its queue.'),
+        'queuePosition':                ('number', 14, None, None, None, 'Position of this transfer in its queue.'),
         'seedIdleLimit':                ('number', 10, None, None, None, 'Seed inactivity limit in minutes.'),
         'seedIdleMode':                 ('number', 10, None, None, None, 'Seed inactivity mode. 0 = Use session limit, 1 = Use transfer limit, 2 = Disable limit.'),
         'seedRatioLimit':               ('double', 5, None, None, None, 'Seeding ratio.'),
         "cache-size-mb":                ('number', 10, None, None, None, 'The maximum size of the disk cache in MB'),
         "dht-enabled":                  ('boolean', 6, None, None, None, 'Enables DHT.'),
         "download-dir":                 ('string', 1, None, None, None, 'Set the session download directory.'),
+        "download-queue-size":          ('number', 14, None, None, None, 'Number of parallel downloads.'),
+        "download-queue-enabled":       ('boolean', 14, None, None, None, 'Enable parallel download restriction.'),
         "encryption":                   ('string', 1, None, None, None, 'Set the session encryption mode, one of ``required``, ``preferred`` or ``tolerated``.'),
         "idle-seeding-limit":           ('number', 10, None, None, None, 'The default seed inactivity limit in minutes.'),
         "idle-seeding-limit-enabled":   ('boolean', 10, None, None, None, 'Enables the default seed inactivity limit'),
         "peer-port-random-on-start":    ('boolean', 5, None, None, None, 'Enables randomized peer port on start of Transmission.'),
         "port-forwarding-enabled":      ('boolean', 1, None, None, None, 'Enables port forwarding.'),
         "rename-partial-files":         ('boolean', 8, None, None, None, 'Appends ".part" to incomplete files'),
+        "queue-stalled-minutes":        ('number', 14, None, None, None, 'Number of minutes of idle that marks a transfer as stalled.'),
+        "queue-stalled-enabled":        ('boolean', 14, None, None, None, 'Enable tracking of stalled transfers.'),
         "script-torrent-done-enabled":  ('boolean', 9, None, None, None, 'Whether or not to call the "done" script.'),
         "script-torrent-done-filename": ('string', 9, None, None, None, 'Filename of the script to run when the transfer is done.'),
+        "seed-queue-size":              ('number', 14, None, None, None, 'Number of parallel uploads.'),
+        "seed-queue-enabled":           ('boolean', 14, None, None, None, 'Enable parallel upload restriction.'),
         "seedRatioLimit":               ('double', 5, None, None, None, 'Seed ratio limit. 1.0 means 1:1 download and upload ratio.'),
         "seedRatioLimited":             ('boolean', 5, None, None, None, 'Enables seed ration limit.'),
         "speed-limit-down":             ('number', 1, None, None, None, 'Download speed limit (in Kib/s).'),

transmissionrpc/torrent.py

 
     def __copy__(self):
         return Torrent(self.client, self.fields)
+
+    def _rpc_version(self):
+        if self.client:
+            return self.client.rpc_version()
+        return 2
     
     def _status_old(self, code):
         mapping = {
     
     def _status(self):
         code = self.fields['status']
-        if self.client.protocol_version >= 14:
+        if self._rpc_version() >= 14:
             return self._status_new(code)
         else:
             return self._status_old(code)
         """
         result = {}
         if 'files' in self.fields:
-            indicies = xrange(len(self.fields['files']))
+            indices = xrange(len(self.fields['files']))
             files = self.fields['files']
             priorities = self.fields['priorities']
             wanted = self.fields['wanted']
-            for item in zip(indicies, files, priorities, wanted):
+            for item in zip(indices, files, priorities, wanted):
                 selected = True if item[3] else False
                 priority = PRIORITY[item[2]]
                 result[item[0]] = {