~cmiller/ubuntu/quantal/deluge/fix-parameter-move-storage

« back to all changes in this revision

Viewing changes to deluge/core/core.py

  • Committer: Bazaar Package Importer
  • Author(s): Andrew Starr-Bochicchio
  • Date: 2010-09-21 17:34:33 UTC
  • mfrom: (1.1.19 upstream)
  • Revision ID: james.westby@ubuntu.com-20100921173433-ex8inlhklmcmuyqi
Tags: 1.3.0-0ubuntu1
* Update to final release (LP: #643990).
 - Fix key error after enabling a plugin that introduces
   a new status key (LP: #627200).
* Drop debian/patches/save_timer_active.patch
 - Included upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
42
42
import threading
43
43
import pkg_resources
44
44
import warnings
 
45
import tempfile
45
46
 
46
47
 
47
48
from twisted.internet import reactor, defer
238
239
        log.info("Attempting to add url %s", url)
239
240
        def on_get_file(filename):
240
241
            # We got the file, so add it to the session
241
 
            data = open(filename, "rb").read()
 
242
            f = open(filename, "rb")
 
243
            data = f.read()
 
244
            f.close()
 
245
            try:
 
246
                os.remove(filename)
 
247
            except Exception, e:
 
248
                log.warning("Couldn't remove temp file: %s", e)
242
249
            return self.add_torrent_file(filename, base64.encodestring(data), options)
243
250
 
244
251
        def on_get_file_error(failure):
247
254
            log.error("Reason: %s", failure.getErrorMessage())
248
255
            return failure
249
256
 
250
 
        d = download_file(url, url.split("/")[-1], headers=headers)
 
257
        d = download_file(url, tempfile.mkstemp()[1], headers=headers)
251
258
        d.addCallback(on_get_file)
252
259
        d.addErrback(on_get_file_error)
253
260
        return d