Patched transmissionrpc 0.8 to work with python 2.4

This commit is contained in:
Correl Roush 2012-01-03 20:43:59 -05:00
parent 4b8a270714
commit 7e91d7c582
3 changed files with 57 additions and 2 deletions

View file

@ -2,6 +2,7 @@
# Copyright (c) 2008-2011 Erik Svensson <erik.public@gmail.com>
# Licensed under the MIT license.
import sys
import re, time
import urllib2, urlparse, base64
@ -40,6 +41,55 @@ def debug_httperror(error):
)
)
if sys.version_info[:2] < (2, 5):
"""
Mimic python 2.5+ urlparse.urlparse
"""
_old_urlparse = urlparse.urlparse
def _urlparse(address):
class ParsedResult(tuple):
def __init__(self, address = None):
self.scheme = ''
self.netloc = ''
self.path = ''
self.params = ''
self.query = ''
self.fragment = ''
self.username = None
self.password = None
self.hostname = None
self.port = None
if address:
self.parse(address)
def parse(self, address):
(
self.scheme,
self.netloc,
self.path,
self.params,
self.query,
self.fragment
) = _old_urlparse(address)
self.hostname = self.netloc
if '@' in self.netloc:
(login, self.hostname) = self.netloc.split('@')
if ':' in login:
(self.username, self.password) = login.split(':')
else:
self.username = login
if ':' in self.hostname:
(self.hostname, self.port) = self.hostname.split(':')
try:
self.port = int(self.port)
except:
self.port = None
result = ParsedResult(address)
return result
urlparse.urlparse = _urlparse
"""
Torrent ids

View file

@ -128,7 +128,9 @@ class Torrent(object):
priorities = self.fields['priorities']
wanted = self.fields['wanted']
for item in zip(indices, files, priorities, wanted):
selected = True if item[3] else False
selected = False
if item[3]:
selected = True
priority = PRIORITY[item[2]]
result[item[0]] = {
'selected': selected,

View file

@ -91,7 +91,10 @@ def rpc_bool(arg):
arg = bool(int(arg))
except ValueError:
arg = arg.lower() in [u'true', u'yes']
return 1 if bool(arg) else 0
if bool(arg):
return 1
else:
return 0
TR_TYPE_MAP = {
'number' : int,