From 852f6049bd0b5bf31c8c578b8e112108239847ea Mon Sep 17 00:00:00 2001 From: Andrew Resch Date: Tue, 6 Aug 2013 18:51:33 -0700 Subject: [PATCH 1/2] Fix twisted 13.1 compat -- the _parse() function was replaced by the _URI class --- deluge/httpdownloader.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/deluge/httpdownloader.py b/deluge/httpdownloader.py index 3f3467a72..4cc5cb1ce 100644 --- a/deluge/httpdownloader.py +++ b/deluge/httpdownloader.py @@ -196,7 +196,17 @@ def download_file(url, filename, callback=None, headers=None, headers = {} headers["accept-encoding"] = "deflate, gzip, x-gzip" - scheme, host, port, path = client._parse(url) + # In twisted 13.1.0 the _parse() function was replaced by the _URI class + if hasattr(client, '_parse'): + scheme, host, port, path = client._parse(url) + else: + from twisted.web import _URI + uri = _URI.fromBytes(url) + scheme = uri.scheme + host = uri.host + port = uri.port + path = uri.originFrom + factory = HTTPDownloader(url, filename, callback, headers, force_filename, allow_compression) if scheme == "https": from twisted.internet import ssl From 4ab4998bf7d645cf6548e8ab56c6ffc3c6c4d759 Mon Sep 17 00:00:00 2001 From: Andrew Resch Date: Tue, 12 Nov 2013 14:04:01 -0800 Subject: [PATCH 2/2] Fix #2355 previous fix was incorrect - thanks Thomas Hipp --- deluge/httpdownloader.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/deluge/httpdownloader.py b/deluge/httpdownloader.py index 4cc5cb1ce..e051b7aa4 100644 --- a/deluge/httpdownloader.py +++ b/deluge/httpdownloader.py @@ -200,12 +200,12 @@ def download_file(url, filename, callback=None, headers=None, if hasattr(client, '_parse'): scheme, host, port, path = client._parse(url) else: - from twisted.web import _URI + from twisted.web.client import _URI uri = _URI.fromBytes(url) scheme = uri.scheme host = uri.host port = uri.port - path = uri.originFrom + path = uri.path factory = HTTPDownloader(url, filename, callback, headers, force_filename, allow_compression) if scheme == "https":