mirror of
https://github.com/correl/Transmission-XBMC.git
synced 2024-11-25 03:00:15 +00:00
81 lines
4.1 KiB
Diff
81 lines
4.1 KiB
Diff
|
diff -rupN transmissionrpc-0.3/transmission.py transmissionrpc/transmission.py
|
||
|
--- transmissionrpc-0.3/transmission.py 2009-12-10 16:39:33.134130829 -0500
|
||
|
+++ transmissionrpc/transmission.py 2009-12-10 16:45:37.385258836 -0500
|
||
|
@@ -69,7 +69,7 @@ class Torrent(object):
|
||
|
wanted = self.fields['wanted']
|
||
|
index = 1
|
||
|
for item in zip(indicies, files, priorities, wanted):
|
||
|
- selected = True if item[3] else False
|
||
|
+ selected = bool(item[3])
|
||
|
priority = PRIORITY[item[2]]
|
||
|
result[item[0]] = {
|
||
|
'selected': selected,
|
||
|
@@ -252,29 +252,30 @@ class Client(object):
|
||
|
while True:
|
||
|
error_data = ""
|
||
|
try:
|
||
|
- self._debug_request(request)
|
||
|
- socket.setdefaulttimeout(10)
|
||
|
- if (sys.version_info[0] == 2 and sys.version_info[1] > 5) or sys.version_info[0] > 2:
|
||
|
- response = urllib2.urlopen(request, timeout=60)
|
||
|
- else:
|
||
|
- response = urllib2.urlopen(request)
|
||
|
- break
|
||
|
- except urllib2.HTTPError, error:
|
||
|
- error_data = error.read()
|
||
|
- if error.code == 409:
|
||
|
- logger.info('Server responded with 409, trying to set session-id.')
|
||
|
- if request_count > 1:
|
||
|
- raise TransmissionError('Session ID negotiation failed.', error)
|
||
|
- if 'X-Transmission-Session-Id' in error.headers:
|
||
|
- self.sessionid = error.headers['X-Transmission-Session-Id']
|
||
|
- request.add_header('X-Transmission-Session-Id', self.sessionid)
|
||
|
+ try:
|
||
|
+ self._debug_request(request)
|
||
|
+ socket.setdefaulttimeout(10)
|
||
|
+ if (sys.version_info[0] == 2 and sys.version_info[1] > 5) or sys.version_info[0] > 2:
|
||
|
+ response = urllib2.urlopen(request, timeout=60)
|
||
|
else:
|
||
|
- raise TransmissionError('Unknown conflict.', error)
|
||
|
- except urllib2.URLError, error:
|
||
|
- raise TransmissionError('Failed to connect to daemon.', error)
|
||
|
- except httplib.BadStatusLine, error:
|
||
|
- if (request_count > 1):
|
||
|
- raise TransmissionError('Failed to request %s "%s".' % (self.url, query), error)
|
||
|
+ response = urllib2.urlopen(request)
|
||
|
+ break
|
||
|
+ except urllib2.HTTPError, error:
|
||
|
+ error_data = error.read()
|
||
|
+ if error.code == 409:
|
||
|
+ logger.info('Server responded with 409, trying to set session-id.')
|
||
|
+ if request_count > 1:
|
||
|
+ raise TransmissionError('Session ID negotiation failed.', error)
|
||
|
+ if 'X-Transmission-Session-Id' in error.headers:
|
||
|
+ self.sessionid = error.headers['X-Transmission-Session-Id']
|
||
|
+ request.add_header('X-Transmission-Session-Id', self.sessionid)
|
||
|
+ else:
|
||
|
+ raise TransmissionError('Unknown conflict.', error)
|
||
|
+ except urllib2.URLError, error:
|
||
|
+ raise TransmissionError('Failed to connect to daemon.', error)
|
||
|
+ except httplib.BadStatusLine, error:
|
||
|
+ if (request_count > 1):
|
||
|
+ raise TransmissionError('Failed to request %s "%s".' % (self.url, query), error)
|
||
|
finally:
|
||
|
if error_data:
|
||
|
self._debug_response(error, error_data)
|
||
|
diff -rupN transmissionrpc-0.3/utils.py transmissionrpc/utils.py
|
||
|
--- transmissionrpc-0.3/utils.py 2009-12-10 16:39:33.134130829 -0500
|
||
|
+++ transmissionrpc/utils.py 2009-12-10 16:45:37.386133947 -0500
|
||
|
@@ -64,7 +64,10 @@ def rpc_bool(arg):
|
||
|
arg = bool(int(arg))
|
||
|
except:
|
||
|
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,
|