summaryrefslogtreecommitdiffstats
path: root/deluge/ui/console/cmdline
diff options
context:
space:
mode:
Diffstat (limited to 'deluge/ui/console/cmdline')
-rw-r--r--deluge/ui/console/cmdline/command.py7
-rw-r--r--deluge/ui/console/cmdline/commands/__init__.py3
-rw-r--r--deluge/ui/console/cmdline/commands/add.py17
-rw-r--r--deluge/ui/console/cmdline/commands/cache.py5
-rw-r--r--deluge/ui/console/cmdline/commands/config.py84
-rw-r--r--deluge/ui/console/cmdline/commands/connect.py12
-rw-r--r--deluge/ui/console/cmdline/commands/debug.py3
-rw-r--r--deluge/ui/console/cmdline/commands/gui.py3
-rw-r--r--deluge/ui/console/cmdline/commands/halt.py3
-rw-r--r--deluge/ui/console/cmdline/commands/help.py3
-rw-r--r--deluge/ui/console/cmdline/commands/info.py40
-rw-r--r--deluge/ui/console/cmdline/commands/manage.py9
-rw-r--r--deluge/ui/console/cmdline/commands/move.py5
-rw-r--r--deluge/ui/console/cmdline/commands/pause.py3
-rw-r--r--deluge/ui/console/cmdline/commands/plugin.py5
-rw-r--r--deluge/ui/console/cmdline/commands/quit.py3
-rw-r--r--deluge/ui/console/cmdline/commands/recheck.py3
-rw-r--r--deluge/ui/console/cmdline/commands/resume.py3
-rw-r--r--deluge/ui/console/cmdline/commands/rm.py9
-rw-r--r--deluge/ui/console/cmdline/commands/status.py12
-rw-r--r--deluge/ui/console/cmdline/commands/update_tracker.py3
21 files changed, 72 insertions, 163 deletions
diff --git a/deluge/ui/console/cmdline/command.py b/deluge/ui/console/cmdline/command.py
index 2ff32df..40edd78 100644
--- a/deluge/ui/console/cmdline/command.py
+++ b/deluge/ui/console/cmdline/command.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2008-2009 Ido Abramovich <ido.deluge@gmail.com>
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
@@ -9,8 +8,6 @@
# See LICENSE for more details.
#
-from __future__ import print_function, unicode_literals
-
import logging
import shlex
@@ -23,7 +20,7 @@ from deluge.ui.console.utils.colors import strip_colors
log = logging.getLogger(__name__)
-class Commander(object):
+class Commander:
def __init__(self, cmds, interactive=False):
self._commands = cmds
self.interactive = interactive
@@ -144,7 +141,7 @@ class Commander(object):
return ret
-class BaseCommand(object):
+class BaseCommand:
usage = None
interactive_only = False
diff --git a/deluge/ui/console/cmdline/commands/__init__.py b/deluge/ui/console/cmdline/commands/__init__.py
index 628fae5..39dbefe 100644
--- a/deluge/ui/console/cmdline/commands/__init__.py
+++ b/deluge/ui/console/cmdline/commands/__init__.py
@@ -1,6 +1,3 @@
-# -*- coding: utf-8 -*-
-from __future__ import unicode_literals
-
from deluge.ui.console.cmdline.command import BaseCommand
__all__ = ['BaseCommand']
diff --git a/deluge/ui/console/cmdline/commands/add.py b/deluge/ui/console/cmdline/commands/add.py
index 34881d8..706ae16 100644
--- a/deluge/ui/console/cmdline/commands/add.py
+++ b/deluge/ui/console/cmdline/commands/add.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2008-2009 Ido Abramovich <ido.deluge@gmail.com>
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
@@ -8,10 +7,10 @@
# See LICENSE for more details.
#
-from __future__ import unicode_literals
-
import os
from base64 import b64encode
+from urllib.parse import urlparse
+from urllib.request import url2pathname
from twisted.internet import defer
@@ -21,14 +20,6 @@ from deluge.ui.client import client
from . import BaseCommand
-try:
- from urllib.parse import urlparse
- from urllib.request import url2pathname
-except ImportError:
- # PY2 fallback
- from urlparse import urlparse # pylint: disable=ungrouped-imports
- from urllib import url2pathname # pylint: disable=ungrouped-imports
-
class Command(BaseCommand):
"""Add torrents"""
@@ -81,7 +72,7 @@ class Command(BaseCommand):
continue
if deluge.common.is_url(torrent):
self.console.write(
- '{!info!}Attempting to add torrent from url: %s' % torrent
+ '{!info!}Attempting to add torrent from URL: %s' % torrent
)
deferreds.append(
client.core.add_torrent_url(torrent, t_options)
@@ -90,7 +81,7 @@ class Command(BaseCommand):
)
elif deluge.common.is_magnet(torrent):
self.console.write(
- '{!info!}Attempting to add torrent from magnet uri: %s' % torrent
+ '{!info!}Attempting to add torrent from magnet URI: %s' % torrent
)
deferreds.append(
client.core.add_torrent_magnet(torrent, t_options)
diff --git a/deluge/ui/console/cmdline/commands/cache.py b/deluge/ui/console/cmdline/commands/cache.py
index e427f08..fe6cd58 100644
--- a/deluge/ui/console/cmdline/commands/cache.py
+++ b/deluge/ui/console/cmdline/commands/cache.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
#
@@ -7,8 +6,6 @@
# See LICENSE for more details.
#
-from __future__ import unicode_literals
-
import deluge.component as component
from deluge.ui.client import client
from deluge.ui.common import DISK_CACHE_KEYS
@@ -24,7 +21,7 @@ class Command(BaseCommand):
def on_cache_status(status):
for key, value in sorted(status.items()):
- self.console.write('{!info!}%s: {!input!}%s' % (key, value))
+ self.console.write(f'{{!info!}}{key}: {{!input!}}{value}')
return client.core.get_session_status(DISK_CACHE_KEYS).addCallback(
on_cache_status
diff --git a/deluge/ui/console/cmdline/commands/config.py b/deluge/ui/console/cmdline/commands/config.py
index bd0a1e1..8b31ca3 100644
--- a/deluge/ui/console/cmdline/commands/config.py
+++ b/deluge/ui/console/cmdline/commands/config.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2008-2009 Ido Abramovich <ido.deluge@gmail.com>
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
@@ -8,11 +7,9 @@
# See LICENSE for more details.
#
-from __future__ import unicode_literals
-
+import json
import logging
-import tokenize
-from io import StringIO
+import re
import deluge.component as component
import deluge.ui.console.utils.colors as colors
@@ -23,54 +20,25 @@ from . import BaseCommand
log = logging.getLogger(__name__)
-def atom(src, token):
- """taken with slight modifications from http://effbot.org/zone/simple-iterator-parser.htm"""
- if token[1] == '(':
- out = []
- token = next(src)
- while token[1] != ')':
- out.append(atom(src, token))
- token = next(src)
- if token[1] == ',':
- token = next(src)
- return tuple(out)
- elif token[0] is tokenize.NUMBER or token[1] == '-':
- try:
- if token[1] == '-':
- return int(token[-1], 0)
- else:
- if token[1].startswith('0x'):
- # Hex number so return unconverted as string.
- return token[1].decode('string-escape')
- else:
- return int(token[1], 0)
- except ValueError:
- try:
- return float(token[-1])
- except ValueError:
- return str(token[-1])
- elif token[1].lower() == 'true':
- return True
- elif token[1].lower() == 'false':
- return False
- elif token[0] is tokenize.STRING or token[1] == '/':
- return token[-1].decode('string-escape')
- elif token[1].isalpha():
- # Parse Windows paths e.g. 'C:\\xyz' or 'C:/xyz'.
- if next()[1] == ':' and next()[1] in '\\/':
- return token[-1].decode('string-escape')
-
- raise SyntaxError('malformed expression (%s)' % token[1])
-
-
-def simple_eval(source):
- """ evaluates the 'source' string into a combination of primitive python objects
- taken from http://effbot.org/zone/simple-iterator-parser.htm"""
- src = StringIO(source).readline
- src = tokenize.generate_tokens(src)
- src = (token for token in src if token[0] is not tokenize.NL)
- res = atom(src, next(src))
- return res
+def json_eval(source):
+ """Evaluates string as json data and returns Python objects."""
+ if source == '':
+ return source
+
+ src = source.splitlines()[0]
+
+ # Substitutions to enable usage of pythonic syntax.
+ if src.startswith('(') and src.endswith(')'):
+ src = re.sub(r'^\((.*)\)$', r'[\1]', src)
+ elif src.lower() in ('true', 'false'):
+ src = src.lower()
+ elif src.lower() == 'none':
+ src = 'null'
+
+ try:
+ return json.loads(src)
+ except ValueError:
+ return src
class Command(BaseCommand):
@@ -126,10 +94,10 @@ class Command(BaseCommand):
value = pprint.pformat(value, 2, 80)
new_value = []
for line in value.splitlines():
- new_value.append('%s%s' % (color, line))
+ new_value.append(f'{color}{line}')
value = '\n'.join(new_value)
- string += '%s: %s%s\n' % (key, color, value)
+ string += f'{key}: {color}{value}\n'
self.console.write(string.strip())
return client.core.get_config().addCallback(_on_get_config)
@@ -140,8 +108,8 @@ class Command(BaseCommand):
val = ' '.join(options.values)
try:
- val = simple_eval(val)
- except SyntaxError as ex:
+ val = json_eval(val)
+ except Exception as ex:
self.console.write('{!error!}%s' % ex)
return
@@ -161,7 +129,7 @@ class Command(BaseCommand):
def on_set_config(result):
self.console.write('{!success!}Configuration value successfully updated.')
- self.console.write('Setting "%s" to: %s' % (key, val))
+ self.console.write(f'Setting "{key}" to: {val!r}')
return client.core.set_config({key: val}).addCallback(on_set_config)
def complete(self, text):
diff --git a/deluge/ui/console/cmdline/commands/connect.py b/deluge/ui/console/cmdline/commands/connect.py
index 6588f7a..4c76de3 100644
--- a/deluge/ui/console/cmdline/commands/connect.py
+++ b/deluge/ui/console/cmdline/commands/connect.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2008-2009 Ido Abramovich <ido.deluge@gmail.com>
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
@@ -8,8 +7,6 @@
# See LICENSE for more details.
#
-from __future__ import unicode_literals
-
import logging
import deluge.component as component
@@ -57,17 +54,12 @@ class Command(BaseCommand):
def on_connect(result):
if self.console.interactive:
- self.console.write('{!success!}Connected to %s:%s!' % (host, port))
+ self.console.write(f'{{!success!}}Connected to {host}:{port}!')
return component.start()
def on_connect_fail(result):
- try:
- msg = result.value.exception_msg
- except AttributeError:
- msg = result.value.message
self.console.write(
- '{!error!}Failed to connect to %s:%s with reason: %s'
- % (host, port, msg)
+ f'{{!error!}}Failed to connect to {host}:{port} with reason: {result.value.message}'
)
return result
diff --git a/deluge/ui/console/cmdline/commands/debug.py b/deluge/ui/console/cmdline/commands/debug.py
index 3ca06ed..af48a8b 100644
--- a/deluge/ui/console/cmdline/commands/debug.py
+++ b/deluge/ui/console/cmdline/commands/debug.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2008-2009 Ido Abramovich <ido.deluge@gmail.com>
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
@@ -8,8 +7,6 @@
# See LICENSE for more details.
#
-from __future__ import unicode_literals
-
from twisted.internet import defer
import deluge.component as component
diff --git a/deluge/ui/console/cmdline/commands/gui.py b/deluge/ui/console/cmdline/commands/gui.py
index 10e4c49..575bc9b 100644
--- a/deluge/ui/console/cmdline/commands/gui.py
+++ b/deluge/ui/console/cmdline/commands/gui.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2011 Nick Lanham <nick@afternight.org>
#
@@ -7,8 +6,6 @@
# See LICENSE for more details.
#
-from __future__ import unicode_literals
-
import logging
import deluge.component as component
diff --git a/deluge/ui/console/cmdline/commands/halt.py b/deluge/ui/console/cmdline/commands/halt.py
index 6355958..608f2de 100644
--- a/deluge/ui/console/cmdline/commands/halt.py
+++ b/deluge/ui/console/cmdline/commands/halt.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2008-2009 Ido Abramovich <ido.deluge@gmail.com>
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
@@ -8,8 +7,6 @@
# See LICENSE for more details.
#
-from __future__ import unicode_literals
-
import deluge.component as component
from deluge.ui.client import client
diff --git a/deluge/ui/console/cmdline/commands/help.py b/deluge/ui/console/cmdline/commands/help.py
index 2711eea..754dadb 100644
--- a/deluge/ui/console/cmdline/commands/help.py
+++ b/deluge/ui/console/cmdline/commands/help.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2008-2009 Ido Abramovich <ido.deluge@gmail.com>
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
@@ -8,8 +7,6 @@
# See LICENSE for more details.
#
-from __future__ import unicode_literals
-
import logging
from twisted.internet import defer
diff --git a/deluge/ui/console/cmdline/commands/info.py b/deluge/ui/console/cmdline/commands/info.py
index 0d22f76..7ea9a67 100644
--- a/deluge/ui/console/cmdline/commands/info.py
+++ b/deluge/ui/console/cmdline/commands/info.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2008-2009 Ido Abramovich <ido.deluge@gmail.com>
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
@@ -8,8 +7,6 @@
# See LICENSE for more details.
#
-from __future__ import division, unicode_literals
-
from os.path import sep as dirsep
import deluge.component as component
@@ -70,6 +67,7 @@ STATUS_KEYS = [
'total_payload_download',
'total_payload_upload',
'time_added',
+ 'label',
]
# Add filter specific state to torrent states
@@ -177,7 +175,7 @@ class Command(BaseCommand):
sort_key = 'name'
sort_reverse = False
for key, value in sorted(
- list(status.items()),
+ status.items(),
key=lambda x: x[1].get(sort_key),
reverse=sort_reverse,
):
@@ -218,9 +216,9 @@ class Command(BaseCommand):
for depth, subdir in enumerate(filepath):
indent = ' ' * depth * spaces_per_level
if depth >= len(prevpath):
- self.console.write('%s{!cyan!}%s' % (indent, subdir))
+ self.console.write(f'{indent}{{!cyan!}}{subdir}')
elif subdir != prevpath[depth]:
- self.console.write('%s{!cyan!}%s' % (indent, subdir))
+ self.console.write(f'{indent}{{!cyan!}}{subdir}')
depth = len(filepath)
@@ -296,7 +294,7 @@ class Command(BaseCommand):
s += peer['ip']
else:
# IPv6
- s += '[%s]:%s' % (
+ s += '[{}]:{}'.format(
':'.join(peer['ip'].split(':')[:-1]),
peer['ip'].split(':')[-1],
)
@@ -308,7 +306,7 @@ class Command(BaseCommand):
s += '\t\t'
else:
s += '\t'
- s += '%s%s\t%s%s' % (
+ s += '{}{}\t{}{}'.format(
colors.state_color['Seeding'],
fspeed(peer['up_speed']),
colors.state_color['Downloading'],
@@ -336,7 +334,7 @@ class Command(BaseCommand):
if verbose or detailed:
self.console.write('{!info!}Name: {!input!}%s' % (status['name']))
self.console.write('{!info!}ID: {!input!}%s' % (torrent_id))
- s = '{!info!}State: %s%s' % (
+ s = '{{!info!}}State: {}{}'.format(
colors.state_color[status['state']],
status['state'],
)
@@ -354,12 +352,12 @@ class Command(BaseCommand):
self.console.write(s)
if status['state'] in ('Seeding', 'Downloading', 'Queued'):
- s = '{!info!}Seeds: {!input!}%s (%s)' % (
+ s = '{{!info!}}Seeds: {{!input!}}{} ({})'.format(
status['num_seeds'],
status['total_seeds'],
)
s += sep
- s += '{!info!}Peers: {!input!}%s (%s)' % (
+ s += '{{!info!}}Peers: {{!input!}}{} ({})'.format(
status['num_peers'],
status['total_peers'],
)
@@ -378,7 +376,7 @@ class Command(BaseCommand):
if total_done == total_size:
s = '{!info!}Size: {!input!}%s' % (total_size)
else:
- s = '{!info!}Size: {!input!}%s/%s' % (total_done, total_size)
+ s = f'{{!info!}}Size: {{!input!}}{total_done}/{total_size}'
s += sep
s += '{!info!}Downloaded: {!input!}%s' % fsize(
status['all_time_download'], shortform=True
@@ -418,14 +416,20 @@ class Command(BaseCommand):
pbar = f_progressbar(
status['progress'], cols - (13 + len('%.2f%%' % status['progress']))
)
- s = '{!info!}Progress: {!input!}%.2f%% %s' % (status['progress'], pbar)
+ s = '{{!info!}}Progress: {{!input!}}{:.2f}% {}'.format(
+ status['progress'], pbar
+ )
self.console.write(s)
s = '{!info!}Download Folder: {!input!}%s' % status['download_location']
- self.console.write(s + '\n')
+ self.console.write(s)
+
+ if 'label' in status:
+ s = '{!info!}Label: {!input!}%s' % status['label']
+ self.console.write(s)
if detailed:
- self.console.write('{!info!}Files in torrent')
+ self.console.write('\n{!info!}Files in torrent')
self.show_file_info(torrent_id, status)
self.console.write('{!info!}Connected peers')
self.show_peer_info(torrent_id, status)
@@ -433,7 +437,7 @@ class Command(BaseCommand):
up_color = colors.state_color['Seeding']
down_color = colors.state_color['Downloading']
- s = '%s%s' % (
+ s = '{}{}'.format(
colors.state_color[status['state']],
'[' + status['state'][0] + ']',
)
@@ -458,7 +462,7 @@ class Command(BaseCommand):
)
if status['download_payload_rate'] > 0:
- dl_info += ' @ %s%s' % (
+ dl_info += ' @ {}{}'.format(
down_color,
fspeed(status['download_payload_rate'], shortform=True),
)
@@ -468,7 +472,7 @@ class Command(BaseCommand):
status['total_uploaded'], status['total_payload_upload']
)
if status['upload_payload_rate'] > 0:
- ul_info += ' @ %s%s' % (
+ ul_info += ' @ {}{}'.format(
up_color,
fspeed(status['upload_payload_rate'], shortform=True),
)
diff --git a/deluge/ui/console/cmdline/commands/manage.py b/deluge/ui/console/cmdline/commands/manage.py
index 6375a74..e5ea9b2 100644
--- a/deluge/ui/console/cmdline/commands/manage.py
+++ b/deluge/ui/console/cmdline/commands/manage.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2008-2009 Ido Abramovich <ido.deluge@gmail.com>
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
@@ -8,8 +7,6 @@
# See LICENSE for more details.
#
-from __future__ import unicode_literals
-
import logging
from twisted.internet import defer
@@ -69,7 +66,7 @@ class Command(BaseCommand):
self.console.write('{!info!}ID: {!input!}%s' % torrentid)
for k, v in data.items():
if k != 'name':
- self.console.write('{!info!}%s: {!input!}%s' % (k, v))
+ self.console.write(f'{{!info!}}{k}: {{!input!}}{v}')
def on_torrents_status_fail(reason):
self.console.write('{!error!}Failed to get torrent data.')
@@ -106,9 +103,7 @@ class Command(BaseCommand):
self.console.write('{!success!}Torrent option successfully updated.')
deferred.callback(True)
- self.console.write(
- 'Setting %s to %s for torrents %s..' % (key, val, torrent_ids)
- )
+ self.console.write(f'Setting {key} to {val} for torrents {torrent_ids}..')
client.core.set_torrent_options(torrent_ids, {key: val}).addCallback(
on_set_config
)
diff --git a/deluge/ui/console/cmdline/commands/move.py b/deluge/ui/console/cmdline/commands/move.py
index 13e475e..67ee0af 100644
--- a/deluge/ui/console/cmdline/commands/move.py
+++ b/deluge/ui/console/cmdline/commands/move.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2011 Nick Lanham <nick@afternight.org>
#
@@ -7,8 +6,6 @@
# See LICENSE for more details.
#
-from __future__ import unicode_literals
-
import logging
import os.path
@@ -52,7 +49,7 @@ class Command(BaseCommand):
names.append(self.console.get_torrent_name(tid))
def on_move(res):
- msg = 'Moved "%s" to %s' % (', '.join(names), options.path)
+ msg = 'Moved "{}" to {}'.format(', '.join(names), options.path)
self.console.write(msg)
log.info(msg)
diff --git a/deluge/ui/console/cmdline/commands/pause.py b/deluge/ui/console/cmdline/commands/pause.py
index 1f7ef31..1334242 100644
--- a/deluge/ui/console/cmdline/commands/pause.py
+++ b/deluge/ui/console/cmdline/commands/pause.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2008-2009 Ido Abramovich <ido.deluge@gmail.com>
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
@@ -8,8 +7,6 @@
# See LICENSE for more details.
#
-from __future__ import unicode_literals
-
import deluge.component as component
from deluge.ui.client import client
diff --git a/deluge/ui/console/cmdline/commands/plugin.py b/deluge/ui/console/cmdline/commands/plugin.py
index fafc77a..c424cb2 100644
--- a/deluge/ui/console/cmdline/commands/plugin.py
+++ b/deluge/ui/console/cmdline/commands/plugin.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
#
@@ -7,8 +6,6 @@
# See LICENSE for more details.
#
-from __future__ import unicode_literals
-
import deluge.component as component
import deluge.configmanager
from deluge.ui.client import client
@@ -106,8 +103,8 @@ class Command(BaseCommand):
elif options.install:
import os.path
- from base64 import b64encode
import shutil
+ from base64 import b64encode
filepath = options.install
diff --git a/deluge/ui/console/cmdline/commands/quit.py b/deluge/ui/console/cmdline/commands/quit.py
index 261a01a..4459dfc 100644
--- a/deluge/ui/console/cmdline/commands/quit.py
+++ b/deluge/ui/console/cmdline/commands/quit.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2008-2009 Ido Abramovich <ido.deluge@gmail.com>
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
@@ -8,8 +7,6 @@
# See LICENSE for more details.
#
-from __future__ import unicode_literals
-
import deluge.component as component
from . import BaseCommand
diff --git a/deluge/ui/console/cmdline/commands/recheck.py b/deluge/ui/console/cmdline/commands/recheck.py
index c9b6360..046cb0b 100644
--- a/deluge/ui/console/cmdline/commands/recheck.py
+++ b/deluge/ui/console/cmdline/commands/recheck.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
#
@@ -7,8 +6,6 @@
# See LICENSE for more details.
#
-from __future__ import unicode_literals
-
import deluge.component as component
from deluge.ui.client import client
diff --git a/deluge/ui/console/cmdline/commands/resume.py b/deluge/ui/console/cmdline/commands/resume.py
index 1f62c5f..27b8528 100644
--- a/deluge/ui/console/cmdline/commands/resume.py
+++ b/deluge/ui/console/cmdline/commands/resume.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2008-2009 Ido Abramovich <ido.deluge@gmail.com>
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
@@ -8,8 +7,6 @@
# See LICENSE for more details.
#
-from __future__ import unicode_literals
-
import deluge.component as component
from deluge.ui.client import client
diff --git a/deluge/ui/console/cmdline/commands/rm.py b/deluge/ui/console/cmdline/commands/rm.py
index ff3125d..4a3fd00 100644
--- a/deluge/ui/console/cmdline/commands/rm.py
+++ b/deluge/ui/console/cmdline/commands/rm.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2008-2009 Ido Abramovich <ido.deluge@gmail.com>
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
@@ -8,8 +7,6 @@
# See LICENSE for more details.
#
-from __future__ import unicode_literals
-
import logging
import deluge.component as component
@@ -70,9 +67,11 @@ class Command(BaseCommand):
def on_removed_finished(errors):
if errors:
- self.console.write('Error(s) occured when trying to delete torrent(s).')
+ self.console.write(
+ 'Error(s) occurred when trying to delete torrent(s).'
+ )
for t_id, e_msg in errors:
- self.console.write('Error removing torrent %s : %s' % (t_id, e_msg))
+ self.console.write(f'Error removing torrent {t_id} : {e_msg}')
log.info('Removing %d torrents', len(torrent_ids))
d = client.core.remove_torrents(torrent_ids, options.remove_data)
diff --git a/deluge/ui/console/cmdline/commands/status.py b/deluge/ui/console/cmdline/commands/status.py
index 948ad6b..05c9796 100644
--- a/deluge/ui/console/cmdline/commands/status.py
+++ b/deluge/ui/console/cmdline/commands/status.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2011 Nick Lanham <nick@afternight.org>
#
@@ -7,8 +6,6 @@
# See LICENSE for more details.
#
-from __future__ import unicode_literals
-
import logging
from twisted.internet import defer
@@ -65,7 +62,12 @@ class Command(BaseCommand):
deferreds = []
ds = client.core.get_session_status(
- ['num_peers', 'payload_upload_rate', 'payload_download_rate', 'dht_nodes']
+ [
+ 'peer.num_peers_connected',
+ 'payload_upload_rate',
+ 'payload_download_rate',
+ 'dht.dht_nodes',
+ ]
)
ds.addCallback(on_session_status)
deferreds.append(ds)
@@ -95,7 +97,7 @@ class Command(BaseCommand):
'{!info!}Total download: %s'
% fspeed(self.status['payload_download_rate'])
)
- self.console.write('{!info!}DHT Nodes: %i' % self.status['dht_nodes'])
+ self.console.write('{!info!}DHT Nodes: %i' % self.status['dht.dht_nodes'])
if isinstance(self.torrents, int):
if self.torrents == -2:
diff --git a/deluge/ui/console/cmdline/commands/update_tracker.py b/deluge/ui/console/cmdline/commands/update_tracker.py
index 591b951..c05569d 100644
--- a/deluge/ui/console/cmdline/commands/update_tracker.py
+++ b/deluge/ui/console/cmdline/commands/update_tracker.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2008-2009 Ido Abramovich <ido.deluge@gmail.com>
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
@@ -8,8 +7,6 @@
# See LICENSE for more details.
#
-from __future__ import unicode_literals
-
import deluge.component as component
from deluge.ui.client import client