diff options
author | Calum Lind <calumlind+deluge@gmail.com> | 2017-07-03 10:41:09 +0100 |
---|---|---|
committer | Calum Lind <calumlind+deluge@gmail.com> | 2018-06-26 12:42:26 +0100 |
commit | 277576268c51431196a84ebd0789ad415cf4e58e (patch) | |
tree | 7c854cfa9212dd8b0501f20e63fe62afeec6cee8 /deluge/ui | |
parent | 74aa0db95603b2396fe9a0f297e8d80a056be95e (diff) | |
download | deluge-277576268c51431196a84ebd0789ad415cf4e58e.tar.gz deluge-277576268c51431196a84ebd0789ad415cf4e58e.tar.bz2 deluge-277576268c51431196a84ebd0789ad415cf4e58e.zip |
[Py2to3] Replace deprecated base64.(de|en)codestring
* In Py3 base64.encodestring is deprecated so rather than use the
Py3 only encodebytes instead use b64encode. The other advantage is
that with issue a consistent TypeError is raised that we can catch.
Diffstat (limited to 'deluge/ui')
-rw-r--r-- | deluge/ui/console/cmdline/commands/add.py | 4 | ||||
-rw-r--r-- | deluge/ui/console/cmdline/commands/plugin.py | 4 | ||||
-rw-r--r-- | deluge/ui/console/modes/add_util.py | 4 | ||||
-rw-r--r-- | deluge/ui/console/modes/addtorrents.py | 4 | ||||
-rw-r--r-- | deluge/ui/gtkui/addtorrentdialog.py | 4 | ||||
-rw-r--r-- | deluge/ui/gtkui/createtorrentdialog.py | 4 | ||||
-rw-r--r-- | deluge/ui/gtkui/ipcinterface.py | 4 | ||||
-rw-r--r-- | deluge/ui/gtkui/preferences.py | 4 | ||||
-rw-r--r-- | deluge/ui/web/auth.py | 6 | ||||
-rw-r--r-- | deluge/ui/web/json_api.py | 6 |
10 files changed, 22 insertions, 22 deletions
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() |