Author: damoxc
Revision: 5500
Log:
change download_torrent_from_url to use the httpdownloader module
Diff:
Modified: trunk/deluge/ui/web/json_api.py
===================================================================
--- trunk/deluge/ui/web/json_api.py 2009-07-20 04:49:55 UTC (rev 5499)
+++ trunk/deluge/ui/web/json_api.py 2009-07-20 08:20:17 UTC (rev 5500)
@@ -45,7 +45,7 @@
from twisted.internet.defer import Deferred, DeferredList
from twisted.web import http, resource, server
-from deluge import common, component
+from deluge import common, component, httpdownloader
from deluge.configmanager import ConfigManager
from deluge.ui import common as uicommon
from deluge.ui.client import client, Client
@@ -439,12 +439,15 @@
:returns: the temporary file name of the torrent file
:rtype: str
"""
+
tmp_file = os.path.join(tempfile.gettempdir(), url.split("/")[-1])
- filename, headers = urllib.urlretrieve(url, tmp_file)
+ d = Deferred()
+ httpdownloader.download_file(url,
tmp_file).addCallback(self._on_torrent_downloaded, tmp_file, d)
+ return d
+
+ def _on_torrent_downloaded(self, result, filename, d):
log.debug("filename: %s", filename)
- d = Deferred()
d.callback(filename)
- return d
@export
def get_torrent_info(self, filename):
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"deluge-commit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/deluge-commit?hl=en
-~----------~----~----~----~------~----~------~--~---