summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--deluge/core/core.py4
-rw-r--r--deluge/plugins/AutoAdd/deluge/plugins/autoadd/core.py4
-rw-r--r--deluge/tests/test_core.py16
-rw-r--r--deluge/tests/test_torrent.py6
-rw-r--r--deluge/tests/test_torrentmanager.py4
-rw-r--r--deluge/ui/console/cmdline/commands/add.py4
-rw-r--r--deluge/ui/console/cmdline/commands/plugin.py4
-rw-r--r--deluge/ui/console/modes/add_util.py4
-rw-r--r--deluge/ui/console/modes/addtorrents.py4
-rw-r--r--deluge/ui/gtkui/addtorrentdialog.py4
-rw-r--r--deluge/ui/gtkui/createtorrentdialog.py4
-rw-r--r--deluge/ui/gtkui/ipcinterface.py4
-rw-r--r--deluge/ui/gtkui/preferences.py4
-rw-r--r--deluge/ui/web/auth.py6
-rw-r--r--deluge/ui/web/json_api.py6
15 files changed, 39 insertions, 39 deletions
diff --git a/deluge/core/core.py b/deluge/core/core.py
index 4def9d727..00266fac2 100644
--- a/deluge/core/core.py
+++ b/deluge/core/core.py
@@ -390,7 +390,7 @@ class Core(component.Component):
"""
try:
filedump = b64decode(filedump)
- except Exception as ex:
+ except TypeError as ex:
log.error('There was an error decoding the filedump string: %s', ex)
try:
@@ -958,7 +958,7 @@ class Core(component.Component):
try:
filedump = b64decode(filedump)
- except Exception as ex:
+ except TypeError as ex:
log.error('There was an error decoding the filedump string!')
log.exception(ex)
return
diff --git a/deluge/plugins/AutoAdd/deluge/plugins/autoadd/core.py b/deluge/plugins/AutoAdd/deluge/plugins/autoadd/core.py
index f09540e4d..0d87cfd22 100644
--- a/deluge/plugins/AutoAdd/deluge/plugins/autoadd/core.py
+++ b/deluge/plugins/AutoAdd/deluge/plugins/autoadd/core.py
@@ -15,10 +15,10 @@
from __future__ import unicode_literals
-import base64
import logging
import os
import shutil
+from base64 import b64encode
from twisted.internet import reactor
from twisted.internet.task import LoopingCall, deferLater
@@ -333,7 +333,7 @@ class Core(CorePluginBase):
d = component.get('Core').add_torrent_magnet(filedump.strip(), options)
else:
d = component.get('Core').add_torrent_file_async(
- filename, base64.encodestring(filedump), options,
+ filename, b64encode(filedump), options,
)
d.addCallback(on_torrent_added, filename, filepath)
d.addErrback(fail_torrent_add, filepath, magnet)
diff --git a/deluge/tests/test_core.py b/deluge/tests/test_core.py
index 1d71c645a..c77253c98 100644
--- a/deluge/tests/test_core.py
+++ b/deluge/tests/test_core.py
@@ -7,7 +7,7 @@
from __future__ import unicode_literals
-import base64
+from base64 import b64encode
from hashlib import sha1 as sha
import pytest
@@ -123,7 +123,7 @@ class CoreTestCase(BaseTestCase):
for f in filenames:
filename = common.get_test_data_file(f)
with open(filename, 'rb') as _file:
- filedump = base64.encodestring(_file.read())
+ filedump = b64encode(_file.read())
files_to_add.append((filename, filedump, options))
errors = yield self.core.add_torrent_files(files_to_add)
self.assertEqual(len(errors), 0)
@@ -136,7 +136,7 @@ class CoreTestCase(BaseTestCase):
for f in filenames:
filename = common.get_test_data_file(f)
with open(filename, 'rb') as _file:
- filedump = base64.encodestring(_file.read())
+ filedump = b64encode(_file.read())
files_to_add.append((filename, filedump, options))
errors = yield self.core.add_torrent_files(files_to_add)
self.assertEqual(len(errors), 1)
@@ -147,7 +147,7 @@ class CoreTestCase(BaseTestCase):
options = {}
filename = common.get_test_data_file('test.torrent')
with open(filename, 'rb') as _file:
- filedump = base64.encodestring(_file.read())
+ filedump = b64encode(_file.read())
torrent_id = yield self.core.add_torrent_file_async(filename, filedump, options)
# Get the info hash from the test.torrent
@@ -215,7 +215,7 @@ class CoreTestCase(BaseTestCase):
options = {}
filename = common.get_test_data_file('test.torrent')
with open(filename, 'rb') as _file:
- filedump = base64.encodestring(_file.read())
+ filedump = b64encode(_file.read())
torrent_id = yield self.core.add_torrent_file_async(filename, filedump, options)
removed = self.core.remove_torrent(torrent_id, True)
self.assertTrue(removed)
@@ -229,12 +229,12 @@ class CoreTestCase(BaseTestCase):
options = {}
filename = common.get_test_data_file('test.torrent')
with open(filename, 'rb') as _file:
- filedump = base64.encodestring(_file.read())
+ filedump = b64encode(_file.read())
torrent_id = yield self.core.add_torrent_file_async(filename, filedump, options)
filename2 = common.get_test_data_file('unicode_filenames.torrent')
with open(filename2, 'rb') as _file:
- filedump = base64.encodestring(_file.read())
+ filedump = b64encode(_file.read())
torrent_id2 = yield self.core.add_torrent_file_async(filename2, filedump, options)
d = self.core.remove_torrents([torrent_id, torrent_id2], True)
@@ -252,7 +252,7 @@ class CoreTestCase(BaseTestCase):
options = {}
filename = common.get_test_data_file('test.torrent')
with open(filename, 'rb') as _file:
- filedump = base64.encodestring(_file.read())
+ filedump = b64encode(_file.read())
torrent_id = yield self.core.add_torrent_file_async(filename, filedump, options)
val = yield self.core.remove_torrents(['invalidid1', 'invalidid2', torrent_id], False)
self.assertEqual(len(val), 2)
diff --git a/deluge/tests/test_torrent.py b/deluge/tests/test_torrent.py
index d74b82fe6..4d54c2659 100644
--- a/deluge/tests/test_torrent.py
+++ b/deluge/tests/test_torrent.py
@@ -7,9 +7,9 @@
from __future__ import print_function, unicode_literals
-import base64
import os
import time
+from base64 import b64encode
from twisted.internet import reactor
from twisted.internet.task import deferLater
@@ -129,7 +129,7 @@ class TorrentTestCase(BaseTestCase):
options = {'seed_mode': True}
filename = common.get_test_data_file('test_torrent.file.torrent')
with open(filename) as _file:
- filedump = base64.encodestring(_file.read())
+ filedump = b64encode(_file.read())
torrent_id = self.core.add_torrent_file(filename, filedump, options)
torrent = self.core.torrentmanager.torrents[torrent_id]
@@ -147,7 +147,7 @@ class TorrentTestCase(BaseTestCase):
options = {'seed_mode': True, 'add_paused': True}
filename = common.get_test_data_file('test_torrent.file.torrent')
with open(filename) as _file:
- filedump = base64.encodestring(_file.read())
+ filedump = b64encode(_file.read())
torrent_id = self.core.add_torrent_file(filename, filedump, options)
torrent = self.core.torrentmanager.torrents[torrent_id]
diff --git a/deluge/tests/test_torrentmanager.py b/deluge/tests/test_torrentmanager.py
index 55ea66b32..88e0fdf49 100644
--- a/deluge/tests/test_torrentmanager.py
+++ b/deluge/tests/test_torrentmanager.py
@@ -7,8 +7,8 @@
from __future__ import unicode_literals
-import base64
import warnings
+from base64 import b64encode
import pytest
from twisted.internet import defer
@@ -46,7 +46,7 @@ class TorrentmanagerTestCase(BaseTestCase):
def test_remove_torrent(self):
filename = common.get_test_data_file('test.torrent')
with open(filename) as _file:
- filedump = base64.encodestring(_file.read())
+ filedump = b64encode(_file.read())
torrent_id = yield self.core.add_torrent_file_async(filename, filedump, {})
self.assertTrue(self.core.torrentmanager.remove(torrent_id, False))
diff --git a/deluge/ui/console/cmdline/commands/add.py b/deluge/ui/console/cmdline/commands/add.py
index 47f9d5689..df0da2db3 100644
--- a/deluge/ui/console/cmdline/commands/add.py
+++ b/deluge/ui/console/cmdline/commands/add.py
@@ -10,8 +10,8 @@
from __future__ import unicode_literals
-import base64
import os
+from base64 import b64encode
from twisted.internet import defer
@@ -85,7 +85,7 @@ class Command(BaseCommand):
self.console.write('{!info!}Attempting to add torrent: %s' % path)
filename = os.path.split(path)[-1]
with open(path, 'rb') as _file:
- filedump = base64.encodestring(_file.read())
+ filedump = b64encode(_file.read())
deferreds.append(
client.core.add_torrent_file_async(
filename, filedump, t_options,
diff --git a/deluge/ui/console/cmdline/commands/plugin.py b/deluge/ui/console/cmdline/commands/plugin.py
index dd910d9da..b9d59173a 100644
--- a/deluge/ui/console/cmdline/commands/plugin.py
+++ b/deluge/ui/console/cmdline/commands/plugin.py
@@ -84,7 +84,7 @@ class Command(BaseCommand):
elif options.install:
import os.path
- import base64
+ from base64 import b64encode
import shutil
filepath = options.install
@@ -102,7 +102,7 @@ class Command(BaseCommand):
if not client.is_localhost():
# We need to send this plugin to the daemon
with open(filepath, 'rb') as _file:
- filedump = base64.encodestring(_file.read())
+ filedump = b64encode(_file.read())
try:
client.core.upload_plugin(filename, filedump)
client.core.rescan_plugins()
diff --git a/deluge/ui/console/modes/add_util.py b/deluge/ui/console/modes/add_util.py
index 4fd4702a7..4138a2f5f 100644
--- a/deluge/ui/console/modes/add_util.py
+++ b/deluge/ui/console/modes/add_util.py
@@ -11,10 +11,10 @@
from __future__ import unicode_literals
-import base64
import glob
import logging
import os
+from base64 import b64encode
import deluge.common
from deluge.ui.client import client
@@ -78,7 +78,7 @@ def add_torrent(t_file, options, success_cb, fail_cb, ress):
filename = os.path.split(f)[-1]
with open(f, 'rb') as _file:
- filedump = base64.encodestring(_file.read())
+ filedump = b64encode(_file.read())
client.core.add_torrent_file_async(
filename, filedump, t_options,
diff --git a/deluge/ui/console/modes/addtorrents.py b/deluge/ui/console/modes/addtorrents.py
index f65b92880..32892a60d 100644
--- a/deluge/ui/console/modes/addtorrents.py
+++ b/deluge/ui/console/modes/addtorrents.py
@@ -9,9 +9,9 @@
from __future__ import unicode_literals
-import base64
import logging
import os
+from base64 import b64encode
import deluge.common
import deluge.component as component
@@ -393,7 +393,7 @@ class AddTorrents(BaseMode):
directory = os.path.join(*self.path_stack[:self.path_stack_pos])
path = os.path.join(directory, filename)
with open(path, 'rb') as _file:
- filedump = base64.encodestring(_file.read())
+ filedump = b64encode(_file.read())
t_options = {}
if result['location']['value']:
t_options['download_location'] = result['location']['value']
diff --git a/deluge/ui/gtkui/addtorrentdialog.py b/deluge/ui/gtkui/addtorrentdialog.py
index a06758e2d..a7599db06 100644
--- a/deluge/ui/gtkui/addtorrentdialog.py
+++ b/deluge/ui/gtkui/addtorrentdialog.py
@@ -9,9 +9,9 @@
from __future__ import division, unicode_literals
-import base64
import logging
import os
+from base64 import b64encode
from xml.sax.saxutils import escape as xml_escape
from xml.sax.saxutils import unescape as xml_unescape
@@ -753,7 +753,7 @@ class AddTorrentDialog(component.Component):
else:
torrents_to_add.append((
os.path.split(filename)[-1],
- base64.encodestring(self.infos[torrent_id]),
+ b64encode(self.infos[torrent_id]),
options,
))
row = self.torrent_liststore.iter_next(row)
diff --git a/deluge/ui/gtkui/createtorrentdialog.py b/deluge/ui/gtkui/createtorrentdialog.py
index 29256fc59..5ca7586fc 100644
--- a/deluge/ui/gtkui/createtorrentdialog.py
+++ b/deluge/ui/gtkui/createtorrentdialog.py
@@ -9,9 +9,9 @@
from __future__ import division, unicode_literals
-import base64
import logging
import os.path
+from base64 import b64encode
import gtk
from gobject import TYPE_UINT64, idle_add
@@ -385,7 +385,7 @@ class CreateTorrentDialog(object):
if add_to_session:
with open(target, 'rb') as _file:
- filedump = base64.encodestring(_file.read())
+ filedump = b64encode(_file.read())
client.core.add_torrent_file_async(
os.path.split(target)[-1],
filedump,
diff --git a/deluge/ui/gtkui/ipcinterface.py b/deluge/ui/gtkui/ipcinterface.py
index d84ccbd79..373d9e39f 100644
--- a/deluge/ui/gtkui/ipcinterface.py
+++ b/deluge/ui/gtkui/ipcinterface.py
@@ -9,10 +9,10 @@
from __future__ import unicode_literals
-import base64
import logging
import os
import sys
+from base64 import b64encode
from glob import glob
from tempfile import mkstemp
@@ -223,5 +223,5 @@ def process_args(args):
component.get('AddTorrentDialog').show(config['focus_add_dialog'])
else:
with open(path, 'rb') as _file:
- filedump = base64.encodestring(_file.read())
+ filedump = b64encode(_file.read())
client.core.add_torrent_file(os.path.split(path)[-1], filedump, None)
diff --git a/deluge/ui/gtkui/preferences.py b/deluge/ui/gtkui/preferences.py
index a5b49a71f..ef7ac2a11 100644
--- a/deluge/ui/gtkui/preferences.py
+++ b/deluge/ui/gtkui/preferences.py
@@ -954,7 +954,7 @@ class Preferences(component.Component):
chooser.destroy()
return
- import base64
+ from base64 import b64encode
import shutil
filename = os.path.split(filepath)[1]
shutil.copyfile(
@@ -967,7 +967,7 @@ class Preferences(component.Component):
if not client.is_localhost():
# We need to send this plugin to the daemon
with open(filepath, 'rb') as _file:
- filedump = base64.encodestring(_file.read())
+ filedump = b64encode(_file.read())
client.core.upload_plugin(filename, filedump)
client.core.rescan_plugins()
diff --git a/deluge/ui/web/auth.py b/deluge/ui/web/auth.py
index 3ab8ccf9f..3929f949f 100644
--- a/deluge/ui/web/auth.py
+++ b/deluge/ui/web/auth.py
@@ -143,11 +143,11 @@ class Auth(JSONComponent):
elif 'old_pwd_md5' in config.config:
# We are using the 1.1 webui auth method
log.debug('Received a password via the 1.1 auth method')
- from base64 import decodestring
+ from base64 import b64decode
m = hashlib.md5()
- m.update(decodestring(config['old_pwd_salt']))
+ m.update(b64decode(config['old_pwd_salt']))
m.update(password.encode('utf8'))
- if m.digest() == decodestring(config['old_pwd_md5']):
+ if m.digest() == b64decode(config['old_pwd_md5']):
# We want to move the password over to sha1 and remove
# the old passwords from the config file.
diff --git a/deluge/ui/web/json_api.py b/deluge/ui/web/json_api.py
index 1cc78610c..db9df59fb 100644
--- a/deluge/ui/web/json_api.py
+++ b/deluge/ui/web/json_api.py
@@ -9,13 +9,13 @@
from __future__ import division, unicode_literals
-import base64
import cgi
import json
import logging
import os
import shutil
import tempfile
+from base64 import b64encode
from types import FunctionType
from twisted.internet import defer, reactor
@@ -703,7 +703,7 @@ class WebApi(JSONComponent):
else:
filename = os.path.basename(torrent['path'])
with open(torrent['path'], 'rb') as _file:
- fdump = base64.encodestring(_file.read())
+ fdump = b64encode(_file.read())
log.info(
'Adding torrent from file `%s` with options `%r`',
filename, torrent['options'],
@@ -903,7 +903,7 @@ class WebApi(JSONComponent):
client.core.rescan_plugins()
return True
with open(path, 'rb') as _file:
- plugin_data = base64.encodestring(_file.read())
+ plugin_data = b64encode(_file.read())
def on_upload_complete(*args):
client.core.rescan_plugins()