Upgrade codebase with pyupgrade (>=py3.6)
Added pyupgrade utility with manual stage to pre-commit and run on all files. Ref: https://github.com/asottile/pyupgrade Closes: deluge-torrent/deluge#326
This commit is contained in:
parent
16895b4a49
commit
ec0bcc11f5
|
@ -41,3 +41,9 @@ repos:
|
||||||
args: [--fix=auto]
|
args: [--fix=auto]
|
||||||
- id: trailing-whitespace
|
- id: trailing-whitespace
|
||||||
name: Fix Trailing whitespace
|
name: Fix Trailing whitespace
|
||||||
|
- repo: https://github.com/asottile/pyupgrade
|
||||||
|
rev: v2.29.1
|
||||||
|
hooks:
|
||||||
|
- id: pyupgrade
|
||||||
|
args: [--py36-plus]
|
||||||
|
stages: [manual]
|
||||||
|
|
|
@ -7,7 +7,7 @@ All modules will require the [common](#common) section dependencies.
|
||||||
|
|
||||||
## Prerequisite
|
## Prerequisite
|
||||||
|
|
||||||
- [Python] _>= 3.5_
|
- [Python] _>= 3.6_
|
||||||
|
|
||||||
## Build
|
## Build
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
|
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
|
||||||
#
|
#
|
||||||
|
@ -32,5 +31,5 @@ LT_VERSION = lt.__version__
|
||||||
|
|
||||||
if VersionSplit(LT_VERSION) < VersionSplit(REQUIRED_VERSION):
|
if VersionSplit(LT_VERSION) < VersionSplit(REQUIRED_VERSION):
|
||||||
raise LibtorrentImportError(
|
raise LibtorrentImportError(
|
||||||
'Deluge %s requires libtorrent >= %s' % (get_version(), REQUIRED_VERSION)
|
f'Deluge {get_version()} requires libtorrent >= {REQUIRED_VERSION}'
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2007 Andrew Resch <andrewresch@gmail.com>
|
# Copyright (C) 2007 Andrew Resch <andrewresch@gmail.com>
|
||||||
#
|
#
|
||||||
|
@ -93,7 +92,7 @@ def _get_version_detail():
|
||||||
except ImportError:
|
except ImportError:
|
||||||
pass
|
pass
|
||||||
version_str += 'Python: %s\n' % platform.python_version()
|
version_str += 'Python: %s\n' % platform.python_version()
|
||||||
version_str += 'OS: %s %s\n' % (platform.system(), common.get_os_version())
|
version_str += f'OS: {platform.system()} {common.get_os_version()}\n'
|
||||||
return version_str
|
return version_str
|
||||||
|
|
||||||
|
|
||||||
|
@ -135,7 +134,7 @@ class DelugeTextHelpFormatter(argparse.RawDescriptionHelpFormatter):
|
||||||
default = action.dest.upper()
|
default = action.dest.upper()
|
||||||
args_string = self._format_args(action, default)
|
args_string = self._format_args(action, default)
|
||||||
opt = ', '.join(action.option_strings)
|
opt = ', '.join(action.option_strings)
|
||||||
parts.append('%s %s' % (opt, args_string))
|
parts.append(f'{opt} {args_string}')
|
||||||
return ', '.join(parts)
|
return ', '.join(parts)
|
||||||
|
|
||||||
|
|
||||||
|
@ -163,7 +162,7 @@ class ArgParserBase(argparse.ArgumentParser):
|
||||||
self.log_stream = kwargs['log_stream']
|
self.log_stream = kwargs['log_stream']
|
||||||
del kwargs['log_stream']
|
del kwargs['log_stream']
|
||||||
|
|
||||||
super(ArgParserBase, self).__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
self.common_setup = False
|
self.common_setup = False
|
||||||
self.process_arg_group = False
|
self.process_arg_group = False
|
||||||
|
@ -244,7 +243,7 @@ class ArgParserBase(argparse.ArgumentParser):
|
||||||
argparse.Namespace: The parsed arguments.
|
argparse.Namespace: The parsed arguments.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
options = super(ArgParserBase, self).parse_args(args=args)
|
options = super().parse_args(args=args)
|
||||||
return self._handle_ui_options(options)
|
return self._handle_ui_options(options)
|
||||||
|
|
||||||
def parse_known_ui_args(self, args, withhold=None):
|
def parse_known_ui_args(self, args, withhold=None):
|
||||||
|
@ -260,7 +259,7 @@ class ArgParserBase(argparse.ArgumentParser):
|
||||||
"""
|
"""
|
||||||
if withhold:
|
if withhold:
|
||||||
args = [a for a in args if a not in withhold]
|
args = [a for a in args if a not in withhold]
|
||||||
options, remaining = super(ArgParserBase, self).parse_known_args(args=args)
|
options, remaining = super().parse_known_args(args=args)
|
||||||
options.remaining = remaining
|
options.remaining = remaining
|
||||||
# Handle common and process group options
|
# Handle common and process group options
|
||||||
return self._handle_ui_options(options)
|
return self._handle_ui_options(options)
|
||||||
|
|
|
@ -84,7 +84,7 @@ def bdecode(x):
|
||||||
return r
|
return r
|
||||||
|
|
||||||
|
|
||||||
class Bencached(object):
|
class Bencached:
|
||||||
|
|
||||||
__slots__ = ['bencoded']
|
__slots__ = ['bencoded']
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2007,2008 Andrew Resch <andrewresch@gmail.com>
|
# Copyright (C) 2007,2008 Andrew Resch <andrewresch@gmail.com>
|
||||||
#
|
#
|
||||||
|
@ -24,7 +23,7 @@ import tarfile
|
||||||
import time
|
import time
|
||||||
from contextlib import closing
|
from contextlib import closing
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from io import BytesIO, open
|
from io import BytesIO
|
||||||
from urllib.parse import unquote_plus, urljoin
|
from urllib.parse import unquote_plus, urljoin
|
||||||
from urllib.request import pathname2url
|
from urllib.request import pathname2url
|
||||||
|
|
||||||
|
@ -135,14 +134,14 @@ def get_default_download_dir():
|
||||||
|
|
||||||
try:
|
try:
|
||||||
user_dirs_path = os.path.join(xdg_config_home, 'user-dirs.dirs')
|
user_dirs_path = os.path.join(xdg_config_home, 'user-dirs.dirs')
|
||||||
with open(user_dirs_path, 'r', encoding='utf8') as _file:
|
with open(user_dirs_path, encoding='utf8') as _file:
|
||||||
for line in _file:
|
for line in _file:
|
||||||
if not line.startswith('#') and line.startswith('XDG_DOWNLOAD_DIR'):
|
if not line.startswith('#') and line.startswith('XDG_DOWNLOAD_DIR'):
|
||||||
download_dir = os.path.expandvars(
|
download_dir = os.path.expandvars(
|
||||||
line.partition('=')[2].rstrip().strip('"')
|
line.partition('=')[2].rstrip().strip('"')
|
||||||
)
|
)
|
||||||
break
|
break
|
||||||
except IOError:
|
except OSError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if not download_dir:
|
if not download_dir:
|
||||||
|
@ -540,9 +539,9 @@ def fpeer(num_peers, total_peers):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
if total_peers > -1:
|
if total_peers > -1:
|
||||||
return '{:d} ({:d})'.format(num_peers, total_peers)
|
return f'{num_peers:d} ({total_peers:d})'
|
||||||
else:
|
else:
|
||||||
return '{:d}'.format(num_peers)
|
return f'{num_peers:d}'
|
||||||
|
|
||||||
|
|
||||||
def ftime(secs):
|
def ftime(secs):
|
||||||
|
@ -568,17 +567,17 @@ def ftime(secs):
|
||||||
if secs <= 0:
|
if secs <= 0:
|
||||||
time_str = ''
|
time_str = ''
|
||||||
elif secs < 60:
|
elif secs < 60:
|
||||||
time_str = '{}s'.format(secs)
|
time_str = f'{secs}s'
|
||||||
elif secs < 3600:
|
elif secs < 3600:
|
||||||
time_str = '{}m {}s'.format(secs // 60, secs % 60)
|
time_str = f'{secs // 60}m {secs % 60}s'
|
||||||
elif secs < 86400:
|
elif secs < 86400:
|
||||||
time_str = '{}h {}m'.format(secs // 3600, secs // 60 % 60)
|
time_str = f'{secs // 3600}h {secs // 60 % 60}m'
|
||||||
elif secs < 604800:
|
elif secs < 604800:
|
||||||
time_str = '{}d {}h'.format(secs // 86400, secs // 3600 % 24)
|
time_str = f'{secs // 86400}d {secs // 3600 % 24}h'
|
||||||
elif secs < 31449600:
|
elif secs < 31449600:
|
||||||
time_str = '{}w {}d'.format(secs // 604800, secs // 86400 % 7)
|
time_str = f'{secs // 604800}w {secs // 86400 % 7}d'
|
||||||
else:
|
else:
|
||||||
time_str = '{}y {}w'.format(secs // 31449600, secs // 604800 % 52)
|
time_str = f'{secs // 31449600}y {secs // 604800 % 52}w'
|
||||||
|
|
||||||
return time_str
|
return time_str
|
||||||
|
|
||||||
|
@ -934,7 +933,7 @@ def is_ipv4(ip):
|
||||||
return socket.inet_aton(ip)
|
return socket.inet_aton(ip)
|
||||||
else:
|
else:
|
||||||
return socket.inet_pton(socket.AF_INET, ip)
|
return socket.inet_pton(socket.AF_INET, ip)
|
||||||
except socket.error:
|
except OSError:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
@ -960,7 +959,7 @@ def is_ipv6(ip):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
return socket.inet_pton(socket.AF_INET6, ip)
|
return socket.inet_pton(socket.AF_INET6, ip)
|
||||||
except (socket.error, AttributeError):
|
except (OSError, AttributeError):
|
||||||
if windows_check():
|
if windows_check():
|
||||||
log.warning('Unable to verify IPv6 Address on Windows.')
|
log.warning('Unable to verify IPv6 Address on Windows.')
|
||||||
return True
|
return True
|
||||||
|
@ -1048,7 +1047,7 @@ def utf8_encode_structure(data):
|
||||||
|
|
||||||
|
|
||||||
@functools.total_ordering
|
@functools.total_ordering
|
||||||
class VersionSplit(object):
|
class VersionSplit:
|
||||||
"""
|
"""
|
||||||
Used for comparing version numbers.
|
Used for comparing version numbers.
|
||||||
|
|
||||||
|
@ -1246,7 +1245,7 @@ def set_env_variable(name, value):
|
||||||
)
|
)
|
||||||
|
|
||||||
# Update the copy maintained by msvcrt (used by gtk+ runtime)
|
# Update the copy maintained by msvcrt (used by gtk+ runtime)
|
||||||
result = cdll.msvcrt._wputenv('%s=%s' % (name, value))
|
result = cdll.msvcrt._wputenv(f'{name}={value}')
|
||||||
if result != 0:
|
if result != 0:
|
||||||
log.info("Failed to set Env Var '%s' (msvcrt._putenv)", name)
|
log.info("Failed to set Env Var '%s' (msvcrt._putenv)", name)
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2007-2010 Andrew Resch <andrewresch@gmail.com>
|
# Copyright (C) 2007-2010 Andrew Resch <andrewresch@gmail.com>
|
||||||
#
|
#
|
||||||
|
@ -24,13 +23,13 @@ class ComponentAlreadyRegistered(Exception):
|
||||||
|
|
||||||
class ComponentException(Exception):
|
class ComponentException(Exception):
|
||||||
def __init__(self, message, tb):
|
def __init__(self, message, tb):
|
||||||
super(ComponentException, self).__init__(message)
|
super().__init__(message)
|
||||||
self.message = message
|
self.message = message
|
||||||
self.tb = tb
|
self.tb = tb
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
s = super(ComponentException, self).__str__()
|
s = super().__str__()
|
||||||
return '%s\n%s' % (s, ''.join(self.tb))
|
return '{}\n{}'.format(s, ''.join(self.tb))
|
||||||
|
|
||||||
def __eq__(self, other):
|
def __eq__(self, other):
|
||||||
if isinstance(other, self.__class__):
|
if isinstance(other, self.__class__):
|
||||||
|
@ -42,7 +41,7 @@ class ComponentException(Exception):
|
||||||
return not self.__eq__(other)
|
return not self.__eq__(other)
|
||||||
|
|
||||||
|
|
||||||
class Component(object):
|
class Component:
|
||||||
"""Component objects are singletons managed by the :class:`ComponentRegistry`.
|
"""Component objects are singletons managed by the :class:`ComponentRegistry`.
|
||||||
|
|
||||||
When a new Component object is instantiated, it will be automatically
|
When a new Component object is instantiated, it will be automatically
|
||||||
|
@ -247,7 +246,7 @@ class Component(object):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class ComponentRegistry(object):
|
class ComponentRegistry:
|
||||||
"""The ComponentRegistry holds a list of currently registered :class:`Component` objects.
|
"""The ComponentRegistry holds a list of currently registered :class:`Component` objects.
|
||||||
|
|
||||||
It is used to manage the Components by starting, stopping, pausing and shutting them down.
|
It is used to manage the Components by starting, stopping, pausing and shutting them down.
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2008 Andrew Resch <andrewresch@gmail.com>
|
# Copyright (C) 2008 Andrew Resch <andrewresch@gmail.com>
|
||||||
#
|
#
|
||||||
|
@ -45,7 +44,6 @@ import os
|
||||||
import pickle
|
import pickle
|
||||||
import shutil
|
import shutil
|
||||||
from codecs import getwriter
|
from codecs import getwriter
|
||||||
from io import open
|
|
||||||
from tempfile import NamedTemporaryFile
|
from tempfile import NamedTemporaryFile
|
||||||
|
|
||||||
from deluge.common import JSON_FORMAT, get_default_config_dir
|
from deluge.common import JSON_FORMAT, get_default_config_dir
|
||||||
|
@ -102,7 +100,7 @@ def find_json_objects(text, decoder=json.JSONDecoder()):
|
||||||
return objects
|
return objects
|
||||||
|
|
||||||
|
|
||||||
class Config(object):
|
class Config:
|
||||||
"""This class is used to access/create/modify config files.
|
"""This class is used to access/create/modify config files.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -396,9 +394,9 @@ class Config(object):
|
||||||
filename = self.__config_file
|
filename = self.__config_file
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with open(filename, 'r', encoding='utf8') as _file:
|
with open(filename, encoding='utf8') as _file:
|
||||||
data = _file.read()
|
data = _file.read()
|
||||||
except IOError as ex:
|
except OSError as ex:
|
||||||
log.warning('Unable to open config file %s: %s', filename, ex)
|
log.warning('Unable to open config file %s: %s', filename, ex)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -451,7 +449,7 @@ class Config(object):
|
||||||
# Check to see if the current config differs from the one on disk
|
# Check to see if the current config differs from the one on disk
|
||||||
# We will only write a new config file if there is a difference
|
# We will only write a new config file if there is a difference
|
||||||
try:
|
try:
|
||||||
with open(filename, 'r', encoding='utf8') as _file:
|
with open(filename, encoding='utf8') as _file:
|
||||||
data = _file.read()
|
data = _file.read()
|
||||||
objects = find_json_objects(data)
|
objects = find_json_objects(data)
|
||||||
start, end = objects[0]
|
start, end = objects[0]
|
||||||
|
@ -463,7 +461,7 @@ class Config(object):
|
||||||
if self._save_timer and self._save_timer.active():
|
if self._save_timer and self._save_timer.active():
|
||||||
self._save_timer.cancel()
|
self._save_timer.cancel()
|
||||||
return True
|
return True
|
||||||
except (IOError, IndexError) as ex:
|
except (OSError, IndexError) as ex:
|
||||||
log.warning('Unable to open config file: %s because: %s', filename, ex)
|
log.warning('Unable to open config file: %s because: %s', filename, ex)
|
||||||
|
|
||||||
# Save the new config and make sure it's written to disk
|
# Save the new config and make sure it's written to disk
|
||||||
|
@ -477,7 +475,7 @@ class Config(object):
|
||||||
json.dump(self.__config, getwriter('utf8')(_file), **JSON_FORMAT)
|
json.dump(self.__config, getwriter('utf8')(_file), **JSON_FORMAT)
|
||||||
_file.flush()
|
_file.flush()
|
||||||
os.fsync(_file.fileno())
|
os.fsync(_file.fileno())
|
||||||
except IOError as ex:
|
except OSError as ex:
|
||||||
log.error('Error writing new config file: %s', ex)
|
log.error('Error writing new config file: %s', ex)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -488,7 +486,7 @@ class Config(object):
|
||||||
try:
|
try:
|
||||||
log.debug('Backing up old config file to %s.bak', filename)
|
log.debug('Backing up old config file to %s.bak', filename)
|
||||||
shutil.move(filename, filename + '.bak')
|
shutil.move(filename, filename + '.bak')
|
||||||
except IOError as ex:
|
except OSError as ex:
|
||||||
log.warning('Unable to backup old config: %s', ex)
|
log.warning('Unable to backup old config: %s', ex)
|
||||||
|
|
||||||
# The new config file has been written successfully, so let's move it over
|
# The new config file has been written successfully, so let's move it over
|
||||||
|
@ -496,7 +494,7 @@ class Config(object):
|
||||||
try:
|
try:
|
||||||
log.debug('Moving new config file %s to %s', filename_tmp, filename)
|
log.debug('Moving new config file %s to %s', filename_tmp, filename)
|
||||||
shutil.move(filename_tmp, filename)
|
shutil.move(filename_tmp, filename)
|
||||||
except IOError as ex:
|
except OSError as ex:
|
||||||
log.error('Error moving new config file: %s', ex)
|
log.error('Error moving new config file: %s', ex)
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2007 Andrew Resch <andrewresch@gmail.com>
|
# Copyright (C) 2007 Andrew Resch <andrewresch@gmail.com>
|
||||||
#
|
#
|
||||||
|
@ -17,7 +16,7 @@ from deluge.config import Config
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class _ConfigManager(object):
|
class _ConfigManager:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
log.debug('ConfigManager started..')
|
log.debug('ConfigManager started..')
|
||||||
self.config_files = {}
|
self.config_files = {}
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2007-2009 Andrew Resch <andrewresch@gmail.com>
|
# Copyright (C) 2007-2009 Andrew Resch <andrewresch@gmail.com>
|
||||||
#
|
#
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
|
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
|
||||||
# Copyright (C) 2011 Pedro Algarvio <pedro@algarvio.me>
|
# Copyright (C) 2011 Pedro Algarvio <pedro@algarvio.me>
|
||||||
|
@ -11,7 +10,6 @@
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
from io import open
|
|
||||||
|
|
||||||
import deluge.component as component
|
import deluge.component as component
|
||||||
import deluge.configmanager as configmanager
|
import deluge.configmanager as configmanager
|
||||||
|
@ -37,7 +35,7 @@ AUTH_LEVELS_MAPPING = {
|
||||||
AUTH_LEVELS_MAPPING_REVERSE = {v: k for k, v in AUTH_LEVELS_MAPPING.items()}
|
AUTH_LEVELS_MAPPING_REVERSE = {v: k for k, v in AUTH_LEVELS_MAPPING.items()}
|
||||||
|
|
||||||
|
|
||||||
class Account(object):
|
class Account:
|
||||||
__slots__ = ('username', 'password', 'authlevel')
|
__slots__ = ('username', 'password', 'authlevel')
|
||||||
|
|
||||||
def __init__(self, username, password, authlevel):
|
def __init__(self, username, password, authlevel):
|
||||||
|
@ -54,10 +52,10 @@ class Account(object):
|
||||||
}
|
}
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return '<Account username="%(username)s" authlevel=%(authlevel)s>' % {
|
return '<Account username="{username}" authlevel={authlevel}>'.format(
|
||||||
'username': self.username,
|
username=self.username,
|
||||||
'authlevel': self.authlevel,
|
authlevel=self.authlevel,
|
||||||
}
|
)
|
||||||
|
|
||||||
|
|
||||||
class AuthManager(component.Component):
|
class AuthManager(component.Component):
|
||||||
|
@ -182,7 +180,7 @@ class AuthManager(component.Component):
|
||||||
if os.path.isfile(filepath):
|
if os.path.isfile(filepath):
|
||||||
log.debug('Creating backup of %s at: %s', filename, filepath_bak)
|
log.debug('Creating backup of %s at: %s', filename, filepath_bak)
|
||||||
shutil.copy2(filepath, filepath_bak)
|
shutil.copy2(filepath, filepath_bak)
|
||||||
except IOError as ex:
|
except OSError as ex:
|
||||||
log.error('Unable to backup %s to %s: %s', filepath, filepath_bak, ex)
|
log.error('Unable to backup %s to %s: %s', filepath, filepath_bak, ex)
|
||||||
else:
|
else:
|
||||||
log.info('Saving the %s at: %s', filename, filepath)
|
log.info('Saving the %s at: %s', filename, filepath)
|
||||||
|
@ -196,7 +194,7 @@ class AuthManager(component.Component):
|
||||||
_file.flush()
|
_file.flush()
|
||||||
os.fsync(_file.fileno())
|
os.fsync(_file.fileno())
|
||||||
shutil.move(filepath_tmp, filepath)
|
shutil.move(filepath_tmp, filepath)
|
||||||
except IOError as ex:
|
except OSError as ex:
|
||||||
log.error('Unable to save %s: %s', filename, ex)
|
log.error('Unable to save %s: %s', filename, ex)
|
||||||
if os.path.isfile(filepath_bak):
|
if os.path.isfile(filepath_bak):
|
||||||
log.info('Restoring backup of %s from: %s', filename, filepath_bak)
|
log.info('Restoring backup of %s from: %s', filename, filepath_bak)
|
||||||
|
@ -225,9 +223,9 @@ class AuthManager(component.Component):
|
||||||
for _filepath in (auth_file, auth_file_bak):
|
for _filepath in (auth_file, auth_file_bak):
|
||||||
log.info('Opening %s for load: %s', filename, _filepath)
|
log.info('Opening %s for load: %s', filename, _filepath)
|
||||||
try:
|
try:
|
||||||
with open(_filepath, 'r', encoding='utf8') as _file:
|
with open(_filepath, encoding='utf8') as _file:
|
||||||
file_data = _file.readlines()
|
file_data = _file.readlines()
|
||||||
except IOError as ex:
|
except OSError as ex:
|
||||||
log.warning('Unable to load %s: %s', _filepath, ex)
|
log.warning('Unable to load %s: %s', _filepath, ex)
|
||||||
file_data = []
|
file_data = []
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2007-2009 Andrew Resch <andrewresch@gmail.com>
|
# Copyright (C) 2007-2009 Andrew Resch <andrewresch@gmail.com>
|
||||||
# Copyright (C) 2011 Pedro Algarvio <pedro@algarvio.me>
|
# Copyright (C) 2011 Pedro Algarvio <pedro@algarvio.me>
|
||||||
|
@ -112,7 +111,7 @@ class Core(component.Component):
|
||||||
component.Component.__init__(self, 'Core')
|
component.Component.__init__(self, 'Core')
|
||||||
|
|
||||||
# Start the libtorrent session.
|
# Start the libtorrent session.
|
||||||
user_agent = 'Deluge/{} libtorrent/{}'.format(DELUGE_VER, LT_VERSION)
|
user_agent = f'Deluge/{DELUGE_VER} libtorrent/{LT_VERSION}'
|
||||||
peer_id = self._create_peer_id(DELUGE_VER)
|
peer_id = self._create_peer_id(DELUGE_VER)
|
||||||
log.debug('Starting session (peer_id: %s, user_agent: %s)', peer_id, user_agent)
|
log.debug('Starting session (peer_id: %s, user_agent: %s)', peer_id, user_agent)
|
||||||
settings_pack = {
|
settings_pack = {
|
||||||
|
@ -293,7 +292,7 @@ class Core(component.Component):
|
||||||
if os.path.isfile(filepath):
|
if os.path.isfile(filepath):
|
||||||
log.debug('Creating backup of %s at: %s', filename, filepath_bak)
|
log.debug('Creating backup of %s at: %s', filename, filepath_bak)
|
||||||
shutil.copy2(filepath, filepath_bak)
|
shutil.copy2(filepath, filepath_bak)
|
||||||
except IOError as ex:
|
except OSError as ex:
|
||||||
log.error('Unable to backup %s to %s: %s', filepath, filepath_bak, ex)
|
log.error('Unable to backup %s to %s: %s', filepath, filepath_bak, ex)
|
||||||
else:
|
else:
|
||||||
log.info('Saving the %s at: %s', filename, filepath)
|
log.info('Saving the %s at: %s', filename, filepath)
|
||||||
|
@ -303,7 +302,7 @@ class Core(component.Component):
|
||||||
_file.flush()
|
_file.flush()
|
||||||
os.fsync(_file.fileno())
|
os.fsync(_file.fileno())
|
||||||
shutil.move(filepath_tmp, filepath)
|
shutil.move(filepath_tmp, filepath)
|
||||||
except (IOError, EOFError) as ex:
|
except (OSError, EOFError) as ex:
|
||||||
log.error('Unable to save %s: %s', filename, ex)
|
log.error('Unable to save %s: %s', filename, ex)
|
||||||
if os.path.isfile(filepath_bak):
|
if os.path.isfile(filepath_bak):
|
||||||
log.info('Restoring backup of %s from: %s', filename, filepath_bak)
|
log.info('Restoring backup of %s from: %s', filename, filepath_bak)
|
||||||
|
@ -325,7 +324,7 @@ class Core(component.Component):
|
||||||
try:
|
try:
|
||||||
with open(_filepath, 'rb') as _file:
|
with open(_filepath, 'rb') as _file:
|
||||||
state = lt.bdecode(_file.read())
|
state = lt.bdecode(_file.read())
|
||||||
except (IOError, EOFError, RuntimeError) as ex:
|
except (OSError, EOFError, RuntimeError) as ex:
|
||||||
log.warning('Unable to load %s: %s', _filepath, ex)
|
log.warning('Unable to load %s: %s', _filepath, ex)
|
||||||
else:
|
else:
|
||||||
log.info('Successfully loaded %s: %s', filename, _filepath)
|
log.info('Successfully loaded %s: %s', filename, _filepath)
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2007-2009 Andrew Resch <andrewresch@gmail.com>
|
# Copyright (C) 2007-2009 Andrew Resch <andrewresch@gmail.com>
|
||||||
#
|
#
|
||||||
|
@ -42,8 +41,8 @@ def is_daemon_running(pid_file):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with open(pid_file) as _file:
|
with open(pid_file) as _file:
|
||||||
pid, port = [int(x) for x in _file.readline().strip().split(';')]
|
pid, port = (int(x) for x in _file.readline().strip().split(';'))
|
||||||
except (EnvironmentError, ValueError):
|
except (OSError, ValueError):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if is_process_running(pid):
|
if is_process_running(pid):
|
||||||
|
@ -51,7 +50,7 @@ def is_daemon_running(pid_file):
|
||||||
_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
try:
|
try:
|
||||||
_socket.connect(('127.0.0.1', port))
|
_socket.connect(('127.0.0.1', port))
|
||||||
except socket.error:
|
except OSError:
|
||||||
# Can't connect, so pid is not a deluged process.
|
# Can't connect, so pid is not a deluged process.
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
|
@ -60,7 +59,7 @@ def is_daemon_running(pid_file):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
class Daemon(object):
|
class Daemon:
|
||||||
"""The Deluge Daemon class"""
|
"""The Deluge Daemon class"""
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
|
@ -154,7 +153,7 @@ class Daemon(object):
|
||||||
pid = os.getpid()
|
pid = os.getpid()
|
||||||
log.debug('Storing pid %s & port %s in: %s', pid, self.port, self.pid_file)
|
log.debug('Storing pid %s & port %s in: %s', pid, self.port, self.pid_file)
|
||||||
with open(self.pid_file, 'w') as _file:
|
with open(self.pid_file, 'w') as _file:
|
||||||
_file.write('%s;%s\n' % (pid, self.port))
|
_file.write(f'{pid};{self.port}\n')
|
||||||
|
|
||||||
component.start()
|
component.start()
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2007 Andrew Resch <andrewresch@gmail.com>
|
# Copyright (C) 2007 Andrew Resch <andrewresch@gmail.com>
|
||||||
# Copyright (C) 2010 Pedro Algarvio <pedro@algarvio.me>
|
# Copyright (C) 2010 Pedro Algarvio <pedro@algarvio.me>
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
|
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
|
||||||
#
|
#
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
||||||
#
|
#
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2007 Andrew Resch <andrewresch@gmail.com>
|
# Copyright (C) 2007 Andrew Resch <andrewresch@gmail.com>
|
||||||
#
|
#
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2008-2010 Andrew Resch <andrewresch@gmail.com>
|
# Copyright (C) 2008-2010 Andrew Resch <andrewresch@gmail.com>
|
||||||
#
|
#
|
||||||
|
@ -218,7 +217,7 @@ class PreferencesManager(component.Component):
|
||||||
self.config['listen_use_sys_port'],
|
self.config['listen_use_sys_port'],
|
||||||
)
|
)
|
||||||
interfaces = [
|
interfaces = [
|
||||||
'%s:%s' % (interface, port)
|
f'{interface}:{port}'
|
||||||
for port in range(listen_ports[0], listen_ports[1] + 1)
|
for port in range(listen_ports[0], listen_ports[1] + 1)
|
||||||
]
|
]
|
||||||
self.core.apply_session_settings(
|
self.core.apply_session_settings(
|
||||||
|
@ -393,7 +392,7 @@ class PreferencesManager(component.Component):
|
||||||
+ quote_plus(':'.join(self.config['enabled_plugins']))
|
+ quote_plus(':'.join(self.config['enabled_plugins']))
|
||||||
)
|
)
|
||||||
urlopen(url)
|
urlopen(url)
|
||||||
except IOError as ex:
|
except OSError as ex:
|
||||||
log.debug('Network error while trying to send info: %s', ex)
|
log.debug('Network error while trying to send info: %s', ex)
|
||||||
else:
|
else:
|
||||||
self.config['info_sent'] = now
|
self.config['info_sent'] = now
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2008,2009 Andrew Resch <andrewresch@gmail.com>
|
# Copyright (C) 2008,2009 Andrew Resch <andrewresch@gmail.com>
|
||||||
#
|
#
|
||||||
|
@ -65,7 +64,7 @@ def export(auth_level=AUTH_LEVEL_DEFAULT):
|
||||||
if func.__doc__:
|
if func.__doc__:
|
||||||
if func.__doc__.endswith(' '):
|
if func.__doc__.endswith(' '):
|
||||||
indent = func.__doc__.split('\n')[-1]
|
indent = func.__doc__.split('\n')[-1]
|
||||||
func.__doc__ += '\n{}'.format(indent)
|
func.__doc__ += f'\n{indent}'
|
||||||
else:
|
else:
|
||||||
func.__doc__ += '\n\n'
|
func.__doc__ += '\n\n'
|
||||||
func.__doc__ += rpc_text
|
func.__doc__ += rpc_text
|
||||||
|
@ -110,7 +109,7 @@ def format_request(call):
|
||||||
|
|
||||||
class DelugeRPCProtocol(DelugeTransferProtocol):
|
class DelugeRPCProtocol(DelugeTransferProtocol):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(DelugeRPCProtocol, self).__init__()
|
super().__init__()
|
||||||
# namedtuple subclass with auth_level, username for the connected session.
|
# namedtuple subclass with auth_level, username for the connected session.
|
||||||
self.AuthLevel = namedtuple('SessionAuthlevel', 'auth_level, username')
|
self.AuthLevel = namedtuple('SessionAuthlevel', 'auth_level, username')
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2007-2009 Andrew Resch <andrewresch@gmail.com>
|
# Copyright (C) 2007-2009 Andrew Resch <andrewresch@gmail.com>
|
||||||
#
|
#
|
||||||
|
@ -148,7 +147,7 @@ class TorrentOptions(dict):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(TorrentOptions, self).__init__()
|
super().__init__()
|
||||||
config = ConfigManager('core.conf').config
|
config = ConfigManager('core.conf').config
|
||||||
options_conf_map = {
|
options_conf_map = {
|
||||||
'add_paused': 'add_paused',
|
'add_paused': 'add_paused',
|
||||||
|
@ -178,14 +177,14 @@ class TorrentOptions(dict):
|
||||||
self['seed_mode'] = False
|
self['seed_mode'] = False
|
||||||
|
|
||||||
|
|
||||||
class TorrentError(object):
|
class TorrentError:
|
||||||
def __init__(self, error_message, was_paused=False, restart_to_resume=False):
|
def __init__(self, error_message, was_paused=False, restart_to_resume=False):
|
||||||
self.error_message = error_message
|
self.error_message = error_message
|
||||||
self.was_paused = was_paused
|
self.was_paused = was_paused
|
||||||
self.restart_to_resume = restart_to_resume
|
self.restart_to_resume = restart_to_resume
|
||||||
|
|
||||||
|
|
||||||
class Torrent(object):
|
class Torrent:
|
||||||
"""Torrent holds information about torrents added to the libtorrent session.
|
"""Torrent holds information about torrents added to the libtorrent session.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -825,7 +824,7 @@ class Torrent(object):
|
||||||
'client': client,
|
'client': client,
|
||||||
'country': country,
|
'country': country,
|
||||||
'down_speed': peer.payload_down_speed,
|
'down_speed': peer.payload_down_speed,
|
||||||
'ip': '%s:%s' % (peer.ip[0], peer.ip[1]),
|
'ip': f'{peer.ip[0]}:{peer.ip[1]}',
|
||||||
'progress': peer.progress,
|
'progress': peer.progress,
|
||||||
'seed': peer.flags & peer.seed,
|
'seed': peer.flags & peer.seed,
|
||||||
'up_speed': peer.payload_up_speed,
|
'up_speed': peer.payload_up_speed,
|
||||||
|
@ -897,7 +896,7 @@ class Torrent(object):
|
||||||
# Check if hostname is an IP address and just return it if that's the case
|
# Check if hostname is an IP address and just return it if that's the case
|
||||||
try:
|
try:
|
||||||
socket.inet_aton(host)
|
socket.inet_aton(host)
|
||||||
except socket.error:
|
except OSError:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
# This is an IP address because an exception wasn't raised
|
# This is an IP address because an exception wasn't raised
|
||||||
|
@ -1292,7 +1291,7 @@ class Torrent(object):
|
||||||
try:
|
try:
|
||||||
with open(filepath, 'wb') as save_file:
|
with open(filepath, 'wb') as save_file:
|
||||||
save_file.write(filedump)
|
save_file.write(filedump)
|
||||||
except IOError as ex:
|
except OSError as ex:
|
||||||
log.error('Unable to save torrent file to: %s', ex)
|
log.error('Unable to save torrent file to: %s', ex)
|
||||||
|
|
||||||
filepath = os.path.join(get_config_dir(), 'state', self.torrent_id + '.torrent')
|
filepath = os.path.join(get_config_dir(), 'state', self.torrent_id + '.torrent')
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2007-2009 Andrew Resch <andrewresch@gmail.com>
|
# Copyright (C) 2007-2009 Andrew Resch <andrewresch@gmail.com>
|
||||||
#
|
#
|
||||||
|
@ -819,8 +818,8 @@ class TorrentManager(component.Component):
|
||||||
try:
|
try:
|
||||||
with open(filepath, 'rb') as _file:
|
with open(filepath, 'rb') as _file:
|
||||||
state = pickle.load(_file, encoding='utf8')
|
state = pickle.load(_file, encoding='utf8')
|
||||||
except (IOError, EOFError, pickle.UnpicklingError) as ex:
|
except (OSError, EOFError, pickle.UnpicklingError) as ex:
|
||||||
message = 'Unable to load {}: {}'.format(filepath, ex)
|
message = f'Unable to load {filepath}: {ex}'
|
||||||
log.error(message)
|
log.error(message)
|
||||||
if not filepath.endswith('.bak'):
|
if not filepath.endswith('.bak'):
|
||||||
self.archive_state(message)
|
self.archive_state(message)
|
||||||
|
@ -1076,7 +1075,7 @@ class TorrentManager(component.Component):
|
||||||
try:
|
try:
|
||||||
with open(_filepath, 'rb') as _file:
|
with open(_filepath, 'rb') as _file:
|
||||||
resume_data = lt.bdecode(_file.read())
|
resume_data = lt.bdecode(_file.read())
|
||||||
except (IOError, EOFError, RuntimeError) as ex:
|
except (OSError, EOFError, RuntimeError) as ex:
|
||||||
if self.torrents:
|
if self.torrents:
|
||||||
log.warning('Unable to load %s: %s', _filepath, ex)
|
log.warning('Unable to load %s: %s', _filepath, ex)
|
||||||
resume_data = None
|
resume_data = None
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2007,2008 Andrew Resch <andrewresch@gmail.com>
|
# Copyright (C) 2007,2008 Andrew Resch <andrewresch@gmail.com>
|
||||||
#
|
#
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2010 John Garland <johnnybg+deluge@gmail.com>
|
# Copyright (C) 2010 John Garland <johnnybg+deluge@gmail.com>
|
||||||
#
|
#
|
||||||
|
@ -125,7 +124,7 @@ def _overrides(stack, method, explicit_base_classes=None):
|
||||||
% (
|
% (
|
||||||
method.__name__,
|
method.__name__,
|
||||||
cls,
|
cls,
|
||||||
'File: %s:%s' % (stack[1][1], stack[1][2]),
|
f'File: {stack[1][1]}:{stack[1][2]}',
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -135,7 +134,7 @@ def _overrides(stack, method, explicit_base_classes=None):
|
||||||
% (
|
% (
|
||||||
method.__name__,
|
method.__name__,
|
||||||
check_classes,
|
check_classes,
|
||||||
'File: %s:%s' % (stack[1][1], stack[1][2]),
|
f'File: {stack[1][1]}:{stack[1][2]}',
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
return method
|
return method
|
||||||
|
@ -152,7 +151,7 @@ def deprecated(func):
|
||||||
def depr_func(*args, **kwargs):
|
def depr_func(*args, **kwargs):
|
||||||
warnings.simplefilter('always', DeprecationWarning) # Turn off filter
|
warnings.simplefilter('always', DeprecationWarning) # Turn off filter
|
||||||
warnings.warn(
|
warnings.warn(
|
||||||
'Call to deprecated function {}.'.format(func.__name__),
|
f'Call to deprecated function {func.__name__}.',
|
||||||
category=DeprecationWarning,
|
category=DeprecationWarning,
|
||||||
stacklevel=2,
|
stacklevel=2,
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2008 Andrew Resch <andrewresch@gmail.com>
|
# Copyright (C) 2008 Andrew Resch <andrewresch@gmail.com>
|
||||||
# Copyright (C) 2011 Pedro Algarvio <pedro@algarvio.me>
|
# Copyright (C) 2011 Pedro Algarvio <pedro@algarvio.me>
|
||||||
|
@ -11,13 +10,13 @@
|
||||||
|
|
||||||
class DelugeError(Exception):
|
class DelugeError(Exception):
|
||||||
def __new__(cls, *args, **kwargs):
|
def __new__(cls, *args, **kwargs):
|
||||||
inst = super(DelugeError, cls).__new__(cls, *args, **kwargs)
|
inst = super().__new__(cls, *args, **kwargs)
|
||||||
inst._args = args
|
inst._args = args
|
||||||
inst._kwargs = kwargs
|
inst._kwargs = kwargs
|
||||||
return inst
|
return inst
|
||||||
|
|
||||||
def __init__(self, message=None):
|
def __init__(self, message=None):
|
||||||
super(DelugeError, self).__init__(message)
|
super().__init__(message)
|
||||||
self.message = message
|
self.message = message
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
|
@ -42,12 +41,12 @@ class InvalidPathError(DelugeError):
|
||||||
|
|
||||||
class WrappedException(DelugeError):
|
class WrappedException(DelugeError):
|
||||||
def __init__(self, message, exception_type, traceback):
|
def __init__(self, message, exception_type, traceback):
|
||||||
super(WrappedException, self).__init__(message)
|
super().__init__(message)
|
||||||
self.type = exception_type
|
self.type = exception_type
|
||||||
self.traceback = traceback
|
self.traceback = traceback
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return '%s\n%s' % (self.message, self.traceback)
|
return f'{self.message}\n{self.traceback}'
|
||||||
|
|
||||||
|
|
||||||
class _ClientSideRecreateError(DelugeError):
|
class _ClientSideRecreateError(DelugeError):
|
||||||
|
@ -61,7 +60,7 @@ class IncompatibleClient(_ClientSideRecreateError):
|
||||||
'Your deluge client is not compatible with the daemon. '
|
'Your deluge client is not compatible with the daemon. '
|
||||||
'Please upgrade your client to %(daemon_version)s'
|
'Please upgrade your client to %(daemon_version)s'
|
||||||
) % {'daemon_version': self.daemon_version}
|
) % {'daemon_version': self.daemon_version}
|
||||||
super(IncompatibleClient, self).__init__(message=msg)
|
super().__init__(message=msg)
|
||||||
|
|
||||||
|
|
||||||
class NotAuthorizedError(_ClientSideRecreateError):
|
class NotAuthorizedError(_ClientSideRecreateError):
|
||||||
|
@ -70,14 +69,14 @@ class NotAuthorizedError(_ClientSideRecreateError):
|
||||||
'current_level': current_level,
|
'current_level': current_level,
|
||||||
'required_level': required_level,
|
'required_level': required_level,
|
||||||
}
|
}
|
||||||
super(NotAuthorizedError, self).__init__(message=msg)
|
super().__init__(message=msg)
|
||||||
self.current_level = current_level
|
self.current_level = current_level
|
||||||
self.required_level = required_level
|
self.required_level = required_level
|
||||||
|
|
||||||
|
|
||||||
class _UsernameBasedPasstroughError(_ClientSideRecreateError):
|
class _UsernameBasedPasstroughError(_ClientSideRecreateError):
|
||||||
def __init__(self, message, username):
|
def __init__(self, message, username):
|
||||||
super(_UsernameBasedPasstroughError, self).__init__(message)
|
super().__init__(message)
|
||||||
self.username = username
|
self.username = username
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
|
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
|
||||||
#
|
#
|
||||||
|
@ -23,7 +22,7 @@ class DelugeEventMetaClass(type):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(cls, name, bases, dct): # pylint: disable=bad-mcs-method-argument
|
def __init__(cls, name, bases, dct): # pylint: disable=bad-mcs-method-argument
|
||||||
super(DelugeEventMetaClass, cls).__init__(name, bases, dct)
|
super().__init__(name, bases, dct)
|
||||||
if name != 'DelugeEvent':
|
if name != 'DelugeEvent':
|
||||||
known_events[name] = cls
|
known_events[name] = cls
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
|
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
|
||||||
#
|
#
|
||||||
|
@ -38,11 +37,11 @@ class CompressionDecoderProtocol(client._GzipProtocol):
|
||||||
"""A compression decoder protocol for CompressionDecoder."""
|
"""A compression decoder protocol for CompressionDecoder."""
|
||||||
|
|
||||||
def __init__(self, protocol, response):
|
def __init__(self, protocol, response):
|
||||||
super(CompressionDecoderProtocol, self).__init__(protocol, response)
|
super().__init__(protocol, response)
|
||||||
self._zlibDecompress = zlib.decompressobj(32 + zlib.MAX_WBITS)
|
self._zlibDecompress = zlib.decompressobj(32 + zlib.MAX_WBITS)
|
||||||
|
|
||||||
|
|
||||||
class BodyHandler(HTTPClientParser, object):
|
class BodyHandler(HTTPClientParser):
|
||||||
"""An HTTP parser that saves the response to a file."""
|
"""An HTTP parser that saves the response to a file."""
|
||||||
|
|
||||||
def __init__(self, request, finished, length, agent, encoding=None):
|
def __init__(self, request, finished, length, agent, encoding=None):
|
||||||
|
@ -54,7 +53,7 @@ class BodyHandler(HTTPClientParser, object):
|
||||||
length (int): The length of the response.
|
length (int): The length of the response.
|
||||||
agent (t.w.i.IAgent): The agent from which the request was sent.
|
agent (t.w.i.IAgent): The agent from which the request was sent.
|
||||||
"""
|
"""
|
||||||
super(BodyHandler, self).__init__(request, finished)
|
super().__init__(request, finished)
|
||||||
self.agent = agent
|
self.agent = agent
|
||||||
self.finished = finished
|
self.finished = finished
|
||||||
self.total_length = length
|
self.total_length = length
|
||||||
|
@ -74,12 +73,12 @@ class BodyHandler(HTTPClientParser, object):
|
||||||
with open(self.agent.filename, 'wb') as _file:
|
with open(self.agent.filename, 'wb') as _file:
|
||||||
_file.write(self.data)
|
_file.write(self.data)
|
||||||
self.finished.callback(self.agent.filename)
|
self.finished.callback(self.agent.filename)
|
||||||
self.state = u'DONE'
|
self.state = 'DONE'
|
||||||
HTTPClientParser.connectionLost(self, reason)
|
HTTPClientParser.connectionLost(self, reason)
|
||||||
|
|
||||||
|
|
||||||
@implementer(IAgent)
|
@implementer(IAgent)
|
||||||
class HTTPDownloaderAgent(object):
|
class HTTPDownloaderAgent:
|
||||||
"""A File Downloader Agent."""
|
"""A File Downloader Agent."""
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
|
@ -144,7 +143,7 @@ class HTTPDownloaderAgent(object):
|
||||||
fileext = os.path.splitext(new_file_name)[1]
|
fileext = os.path.splitext(new_file_name)[1]
|
||||||
while os.path.isfile(new_file_name):
|
while os.path.isfile(new_file_name):
|
||||||
# Increment filename if already exists
|
# Increment filename if already exists
|
||||||
new_file_name = '%s-%s%s' % (fileroot, count, fileext)
|
new_file_name = f'{fileroot}-{count}{fileext}'
|
||||||
count += 1
|
count += 1
|
||||||
|
|
||||||
self.filename = new_file_name
|
self.filename = new_file_name
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# This file is public domain.
|
# This file is public domain.
|
||||||
#
|
#
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2007,2008 Andrew Resch <andrewresch@gmail.com>
|
# Copyright (C) 2007,2008 Andrew Resch <andrewresch@gmail.com>
|
||||||
#
|
#
|
||||||
|
@ -77,7 +76,7 @@ def set_language(lang):
|
||||||
translation = gettext.translation(
|
translation = gettext.translation(
|
||||||
'deluge', localedir=get_translations_path(), languages=[lang]
|
'deluge', localedir=get_translations_path(), languages=[lang]
|
||||||
)
|
)
|
||||||
except IOError:
|
except OSError:
|
||||||
log.warning('Unable to find translation (.mo) to set language: %s', lang)
|
log.warning('Unable to find translation (.mo) to set language: %s', lang)
|
||||||
else:
|
else:
|
||||||
translation.install()
|
translation.install()
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2007 Andrew Resch <andrewresch@gmail.com>
|
# Copyright (C) 2007 Andrew Resch <andrewresch@gmail.com>
|
||||||
# Copyright (C) 2010 Pedro Algarvio <pedro@algarvio.me>
|
# Copyright (C) 2010 Pedro Algarvio <pedro@algarvio.me>
|
||||||
|
@ -37,7 +36,7 @@ MAX_LOGGER_NAME_LENGTH = 10
|
||||||
|
|
||||||
class Logging(LoggingLoggerClass):
|
class Logging(LoggingLoggerClass):
|
||||||
def __init__(self, logger_name):
|
def __init__(self, logger_name):
|
||||||
super(Logging, self).__init__(logger_name)
|
super().__init__(logger_name)
|
||||||
|
|
||||||
# This makes module name padding increase to the biggest module name
|
# This makes module name padding increase to the biggest module name
|
||||||
# so that logs keep readability.
|
# so that logs keep readability.
|
||||||
|
@ -238,7 +237,7 @@ def tweak_logging_levels():
|
||||||
log.warning(
|
log.warning(
|
||||||
'logging.conf found! tweaking logging levels from %s', logging_config_file
|
'logging.conf found! tweaking logging levels from %s', logging_config_file
|
||||||
)
|
)
|
||||||
with open(logging_config_file, 'r') as _file:
|
with open(logging_config_file) as _file:
|
||||||
for line in _file:
|
for line in _file:
|
||||||
if line.strip().startswith('#'):
|
if line.strip().startswith('#'):
|
||||||
continue
|
continue
|
||||||
|
@ -309,7 +308,7 @@ Triggering code:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
class _BackwardsCompatibleLOG(object):
|
class _BackwardsCompatibleLOG:
|
||||||
def __getattribute__(self, name):
|
def __getattribute__(self, name):
|
||||||
import warnings
|
import warnings
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
|
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
|
||||||
#
|
#
|
||||||
|
@ -30,7 +29,7 @@ class InvalidPieceSize(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class TorrentMetadata(object):
|
class TorrentMetadata:
|
||||||
"""This class is used to create .torrent files.
|
"""This class is used to create .torrent files.
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Original file from BitTorrent-5.3-GPL.tar.gz
|
# Original file from BitTorrent-5.3-GPL.tar.gz
|
||||||
# Copyright (C) Bram Cohen
|
# Copyright (C) Bram Cohen
|
||||||
|
@ -42,7 +41,7 @@ def dummy(*v):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class RemoteFileProgress(object):
|
class RemoteFileProgress:
|
||||||
def __init__(self, session_id):
|
def __init__(self, session_id):
|
||||||
self.session_id = session_id
|
self.session_id = session_id
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2013 Bro <bro.development@gmail.com>
|
# Copyright (C) 2013 Bro <bro.development@gmail.com>
|
||||||
#
|
#
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2007 Andrew Resch <andrewresch@gmail.com>
|
# Copyright (C) 2007 Andrew Resch <andrewresch@gmail.com>
|
||||||
#
|
#
|
||||||
|
@ -45,7 +44,7 @@ git repository to have an idea of what needs to be changed.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
class PluginManagerBase(object):
|
class PluginManagerBase:
|
||||||
"""PluginManagerBase is a base class for PluginManagers to inherit"""
|
"""PluginManagerBase is a base class for PluginManagers to inherit"""
|
||||||
|
|
||||||
def __init__(self, config_file, entry_name):
|
def __init__(self, config_file, entry_name):
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2009 GazpachoKing <chase.sterling@gmail.com>
|
# Copyright (C) 2009 GazpachoKing <chase.sterling@gmail.com>
|
||||||
#
|
#
|
||||||
|
@ -20,7 +19,7 @@ class CorePlugin(PluginInitBase):
|
||||||
from .core import Core as _pluginCls
|
from .core import Core as _pluginCls
|
||||||
|
|
||||||
self._plugin_cls = _pluginCls
|
self._plugin_cls = _pluginCls
|
||||||
super(CorePlugin, self).__init__(plugin_name)
|
super().__init__(plugin_name)
|
||||||
|
|
||||||
|
|
||||||
class Gtk3UIPlugin(PluginInitBase):
|
class Gtk3UIPlugin(PluginInitBase):
|
||||||
|
@ -28,7 +27,7 @@ class Gtk3UIPlugin(PluginInitBase):
|
||||||
from .gtkui import GtkUI as _pluginCls
|
from .gtkui import GtkUI as _pluginCls
|
||||||
|
|
||||||
self._plugin_cls = _pluginCls
|
self._plugin_cls = _pluginCls
|
||||||
super(Gtk3UIPlugin, self).__init__(plugin_name)
|
super().__init__(plugin_name)
|
||||||
|
|
||||||
|
|
||||||
class WebUIPlugin(PluginInitBase):
|
class WebUIPlugin(PluginInitBase):
|
||||||
|
@ -36,4 +35,4 @@ class WebUIPlugin(PluginInitBase):
|
||||||
from .webui import WebUI as _pluginCls
|
from .webui import WebUI as _pluginCls
|
||||||
|
|
||||||
self._plugin_cls = _pluginCls
|
self._plugin_cls = _pluginCls
|
||||||
super(WebUIPlugin, self).__init__(plugin_name)
|
super().__init__(plugin_name)
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Basic plugin template created by:
|
# Basic plugin template created by:
|
||||||
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2009 GazpachoKing <chase.sterling@gmail.com>
|
# Copyright (C) 2009 GazpachoKing <chase.sterling@gmail.com>
|
||||||
# Copyright (C) 2011 Pedro Algarvio <pedro@algarvio.me>
|
# Copyright (C) 2011 Pedro Algarvio <pedro@algarvio.me>
|
||||||
|
@ -150,7 +149,7 @@ class Core(CorePluginBase):
|
||||||
try:
|
try:
|
||||||
with open(filename, file_mode) as _file:
|
with open(filename, file_mode) as _file:
|
||||||
filedump = _file.read()
|
filedump = _file.read()
|
||||||
except IOError as ex:
|
except OSError as ex:
|
||||||
log.warning('Unable to open %s: %s', filename, ex)
|
log.warning('Unable to open %s: %s', filename, ex)
|
||||||
raise ex
|
raise ex
|
||||||
|
|
||||||
|
@ -167,9 +166,9 @@ class Core(CorePluginBase):
|
||||||
log.debug('Attempting to open %s for splitting magnets.', filename)
|
log.debug('Attempting to open %s for splitting magnets.', filename)
|
||||||
magnets = []
|
magnets = []
|
||||||
try:
|
try:
|
||||||
with open(filename, 'r') as _file:
|
with open(filename) as _file:
|
||||||
magnets = list(filter(len, _file.read().splitlines()))
|
magnets = list(filter(len, _file.read().splitlines()))
|
||||||
except IOError as ex:
|
except OSError as ex:
|
||||||
log.warning('Unable to open %s: %s', filename, ex)
|
log.warning('Unable to open %s: %s', filename, ex)
|
||||||
|
|
||||||
if len(magnets) < 2:
|
if len(magnets) < 2:
|
||||||
|
@ -194,7 +193,7 @@ class Core(CorePluginBase):
|
||||||
try:
|
try:
|
||||||
with open(mname, 'w') as _mfile:
|
with open(mname, 'w') as _mfile:
|
||||||
_mfile.write(magnet)
|
_mfile.write(magnet)
|
||||||
except IOError as ex:
|
except OSError as ex:
|
||||||
log.warning('Unable to open %s: %s', mname, ex)
|
log.warning('Unable to open %s: %s', mname, ex)
|
||||||
return magnets
|
return magnets
|
||||||
|
|
||||||
|
@ -269,7 +268,7 @@ class Core(CorePluginBase):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
filedump = self.load_torrent(filepath, magnet)
|
filedump = self.load_torrent(filepath, magnet)
|
||||||
except (IOError, EOFError) as ex:
|
except (OSError, EOFError) as ex:
|
||||||
# If torrent is invalid, keep track of it so can try again on the next pass.
|
# If torrent is invalid, keep track of it so can try again on the next pass.
|
||||||
# This catches torrent files that may not be fully saved to disk at load time.
|
# This catches torrent files that may not be fully saved to disk at load time.
|
||||||
log.debug('Torrent is invalid: %s', ex)
|
log.debug('Torrent is invalid: %s', ex)
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2009 GazpachoKing <chase.sterling@gmail.com>
|
# Copyright (C) 2009 GazpachoKing <chase.sterling@gmail.com>
|
||||||
#
|
#
|
||||||
|
@ -39,7 +38,7 @@ class IncompatibleOption(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class OptionsDialog(object):
|
class OptionsDialog:
|
||||||
spin_ids = ['max_download_speed', 'max_upload_speed', 'stop_ratio']
|
spin_ids = ['max_download_speed', 'max_upload_speed', 'stop_ratio']
|
||||||
spin_int_ids = ['max_upload_slots', 'max_connections']
|
spin_int_ids = ['max_upload_slots', 'max_connections']
|
||||||
chk_ids = [
|
chk_ids = [
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2009 GazpachoKing <chase.sterling@gmail.com>
|
# Copyright (C) 2009 GazpachoKing <chase.sterling@gmail.com>
|
||||||
#
|
#
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2009 GazpachoKing <chase.sterling@gmail.com>
|
# Copyright (C) 2009 GazpachoKing <chase.sterling@gmail.com>
|
||||||
# Copyright (C) 2011 Pedro Algarvio <pedro@algarvio.me>
|
# Copyright (C) 2011 Pedro Algarvio <pedro@algarvio.me>
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2007-2009 Andrew Resch <andrewresch@gmail.com>
|
# Copyright (C) 2007-2009 Andrew Resch <andrewresch@gmail.com>
|
||||||
#
|
#
|
||||||
|
@ -15,7 +14,7 @@ class CorePlugin(PluginInitBase):
|
||||||
from .core import Core as _pluginCls
|
from .core import Core as _pluginCls
|
||||||
|
|
||||||
self._plugin_cls = _pluginCls
|
self._plugin_cls = _pluginCls
|
||||||
super(CorePlugin, self).__init__(plugin_name)
|
super().__init__(plugin_name)
|
||||||
|
|
||||||
|
|
||||||
class GtkUIPlugin(PluginInitBase):
|
class GtkUIPlugin(PluginInitBase):
|
||||||
|
@ -23,7 +22,7 @@ class GtkUIPlugin(PluginInitBase):
|
||||||
from .gtkui import GtkUI as _pluginCls
|
from .gtkui import GtkUI as _pluginCls
|
||||||
|
|
||||||
self._plugin_cls = _pluginCls
|
self._plugin_cls = _pluginCls
|
||||||
super(GtkUIPlugin, self).__init__(plugin_name)
|
super().__init__(plugin_name)
|
||||||
|
|
||||||
|
|
||||||
class WebUIPlugin(PluginInitBase):
|
class WebUIPlugin(PluginInitBase):
|
||||||
|
@ -31,4 +30,4 @@ class WebUIPlugin(PluginInitBase):
|
||||||
from .webui import WebUI as _pluginCls
|
from .webui import WebUI as _pluginCls
|
||||||
|
|
||||||
self._plugin_cls = _pluginCls
|
self._plugin_cls = _pluginCls
|
||||||
super(WebUIPlugin, self).__init__(plugin_name)
|
super().__init__(plugin_name)
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Basic plugin template created by:
|
# Basic plugin template created by:
|
||||||
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
||||||
|
@ -71,7 +70,7 @@ class BadIP(Exception):
|
||||||
_message = None
|
_message = None
|
||||||
|
|
||||||
def __init__(self, message):
|
def __init__(self, message):
|
||||||
super(BadIP, self).__init__(message)
|
super().__init__(message)
|
||||||
|
|
||||||
def __set_message(self, message):
|
def __set_message(self, message):
|
||||||
self._message = message
|
self._message = message
|
||||||
|
@ -83,7 +82,7 @@ class BadIP(Exception):
|
||||||
del __get_message, __set_message
|
del __get_message, __set_message
|
||||||
|
|
||||||
|
|
||||||
class IP(object):
|
class IP:
|
||||||
__slots__ = ('q1', 'q2', 'q3', 'q4', '_long')
|
__slots__ = ('q1', 'q2', 'q3', 'q4', '_long')
|
||||||
|
|
||||||
def __init__(self, q1, q2, q3, q4):
|
def __init__(self, q1, q2, q3, q4):
|
||||||
|
@ -106,7 +105,7 @@ class IP(object):
|
||||||
@classmethod
|
@classmethod
|
||||||
def parse(cls, ip):
|
def parse(cls, ip):
|
||||||
try:
|
try:
|
||||||
q1, q2, q3, q4 = [int(q) for q in ip.split('.')]
|
q1, q2, q3, q4 = (int(q) for q in ip.split('.'))
|
||||||
except ValueError:
|
except ValueError:
|
||||||
raise BadIP(_('The IP address "%s" is badly formed' % ip))
|
raise BadIP(_('The IP address "%s" is badly formed' % ip))
|
||||||
if q1 < 0 or q2 < 0 or q3 < 0 or q4 < 0:
|
if q1 < 0 or q2 < 0 or q3 < 0 or q4 < 0:
|
||||||
|
@ -166,7 +165,7 @@ class IP(object):
|
||||||
return self.long == other.long
|
return self.long == other.long
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return '<%s long=%s address="%s">' % (
|
return '<{} long={} address="{}">'.format(
|
||||||
self.__class__.__name__,
|
self.__class__.__name__,
|
||||||
self.long,
|
self.long,
|
||||||
self.address,
|
self.address,
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2008 Andrew Resch <andrewresch@gmail.com>
|
# Copyright (C) 2008 Andrew Resch <andrewresch@gmail.com>
|
||||||
# Copyright (C) 2009-2010 John Garland <johnnybg+deluge@gmail.com>
|
# Copyright (C) 2009-2010 John Garland <johnnybg+deluge@gmail.com>
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2009-2010 John Garland <johnnybg+deluge@gmail.com>
|
# Copyright (C) 2009-2010 John Garland <johnnybg+deluge@gmail.com>
|
||||||
#
|
#
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2009-2010 John Garland <johnnybg+deluge@gmail.com>
|
# Copyright (C) 2009-2010 John Garland <johnnybg+deluge@gmail.com>
|
||||||
#
|
#
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2008 Andrew Resch <andrewresch@gmail.com>
|
# Copyright (C) 2008 Andrew Resch <andrewresch@gmail.com>
|
||||||
#
|
#
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2007 Steve 'Tarka' Smith (tarka@internode.on.net)
|
# Copyright (C) 2007 Steve 'Tarka' Smith (tarka@internode.on.net)
|
||||||
#
|
#
|
||||||
|
@ -21,14 +20,14 @@ class PGException(Exception):
|
||||||
|
|
||||||
# Incrementally reads PeerGuardian blocklists v1 and v2.
|
# Incrementally reads PeerGuardian blocklists v1 and v2.
|
||||||
# See http://wiki.phoenixlabs.org/wiki/P2B_Format
|
# See http://wiki.phoenixlabs.org/wiki/P2B_Format
|
||||||
class PGReader(object):
|
class PGReader:
|
||||||
def __init__(self, filename):
|
def __init__(self, filename):
|
||||||
log.debug('PGReader loading: %s', filename)
|
log.debug('PGReader loading: %s', filename)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with gzip.open(filename, 'rb') as _file:
|
with gzip.open(filename, 'rb') as _file:
|
||||||
self.fd = _file
|
self.fd = _file
|
||||||
except IOError:
|
except OSError:
|
||||||
log.debug('Blocklist: PGReader: Incorrect file type or list is corrupt')
|
log.debug('Blocklist: PGReader: Incorrect file type or list is corrupt')
|
||||||
|
|
||||||
# 4 bytes, should be 0xffffffff
|
# 4 bytes, should be 0xffffffff
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2009-2010 John Garland <johnnybg+deluge@gmail.com>
|
# Copyright (C) 2009-2010 John Garland <johnnybg+deluge@gmail.com>
|
||||||
#
|
#
|
||||||
|
@ -21,7 +20,7 @@ class ReaderParseError(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class BaseReader(object):
|
class BaseReader:
|
||||||
"""Base reader for blocklist files"""
|
"""Base reader for blocklist files"""
|
||||||
|
|
||||||
def __init__(self, _file):
|
def __init__(self, _file):
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
||||||
#
|
#
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
|
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
|
||||||
#
|
#
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2009 Damien Churchill <damoxc@gmail.com>
|
# Copyright (C) 2009 Damien Churchill <damoxc@gmail.com>
|
||||||
#
|
#
|
||||||
|
@ -15,7 +14,7 @@ class CorePlugin(PluginInitBase):
|
||||||
from .core import Core as _pluginCls
|
from .core import Core as _pluginCls
|
||||||
|
|
||||||
self._plugin_cls = _pluginCls
|
self._plugin_cls = _pluginCls
|
||||||
super(CorePlugin, self).__init__(plugin_name)
|
super().__init__(plugin_name)
|
||||||
|
|
||||||
|
|
||||||
class GtkUIPlugin(PluginInitBase):
|
class GtkUIPlugin(PluginInitBase):
|
||||||
|
@ -23,7 +22,7 @@ class GtkUIPlugin(PluginInitBase):
|
||||||
from .gtkui import GtkUI as _pluginCls
|
from .gtkui import GtkUI as _pluginCls
|
||||||
|
|
||||||
self._plugin_cls = _pluginCls
|
self._plugin_cls = _pluginCls
|
||||||
super(GtkUIPlugin, self).__init__(plugin_name)
|
super().__init__(plugin_name)
|
||||||
|
|
||||||
|
|
||||||
class WebUIPlugin(PluginInitBase):
|
class WebUIPlugin(PluginInitBase):
|
||||||
|
@ -31,4 +30,4 @@ class WebUIPlugin(PluginInitBase):
|
||||||
from .webui import WebUI as _pluginCls
|
from .webui import WebUI as _pluginCls
|
||||||
|
|
||||||
self._plugin_cls = _pluginCls
|
self._plugin_cls = _pluginCls
|
||||||
super(WebUIPlugin, self).__init__(plugin_name)
|
super().__init__(plugin_name)
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Basic plugin template created by:
|
# Basic plugin template created by:
|
||||||
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
|
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
|
||||||
#
|
#
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2009 Damien Churchill <damoxc@gmail.com>
|
# Copyright (C) 2009 Damien Churchill <damoxc@gmail.com>
|
||||||
#
|
#
|
||||||
|
@ -39,7 +38,7 @@ EVENT_MAP = {
|
||||||
EVENTS = ['complete', 'added', 'removed']
|
EVENTS = ['complete', 'added', 'removed']
|
||||||
|
|
||||||
|
|
||||||
class ExecutePreferences(object):
|
class ExecutePreferences:
|
||||||
def __init__(self, plugin):
|
def __init__(self, plugin):
|
||||||
self.plugin = plugin
|
self.plugin = plugin
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2009 Damien Churchill <damoxc@gmail.com>
|
# Copyright (C) 2009 Damien Churchill <damoxc@gmail.com>
|
||||||
#
|
#
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2009 Damien Churchill <damoxc@gmail.com>
|
# Copyright (C) 2009 Damien Churchill <damoxc@gmail.com>
|
||||||
#
|
#
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
|
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
|
||||||
#
|
#
|
||||||
|
@ -19,7 +18,7 @@ class CorePlugin(PluginInitBase):
|
||||||
from .core import Core as _pluginCls
|
from .core import Core as _pluginCls
|
||||||
|
|
||||||
self._plugin_cls = _pluginCls
|
self._plugin_cls = _pluginCls
|
||||||
super(CorePlugin, self).__init__(plugin_name)
|
super().__init__(plugin_name)
|
||||||
|
|
||||||
|
|
||||||
class GtkUIPlugin(PluginInitBase):
|
class GtkUIPlugin(PluginInitBase):
|
||||||
|
@ -27,7 +26,7 @@ class GtkUIPlugin(PluginInitBase):
|
||||||
from .gtkui import GtkUI as _pluginCls
|
from .gtkui import GtkUI as _pluginCls
|
||||||
|
|
||||||
self._plugin_cls = _pluginCls
|
self._plugin_cls = _pluginCls
|
||||||
super(GtkUIPlugin, self).__init__(plugin_name)
|
super().__init__(plugin_name)
|
||||||
|
|
||||||
|
|
||||||
class WebUIPlugin(PluginInitBase):
|
class WebUIPlugin(PluginInitBase):
|
||||||
|
@ -35,4 +34,4 @@ class WebUIPlugin(PluginInitBase):
|
||||||
from .webui import WebUI as _pluginCls
|
from .webui import WebUI as _pluginCls
|
||||||
|
|
||||||
self._plugin_cls = _pluginCls
|
self._plugin_cls = _pluginCls
|
||||||
super(WebUIPlugin, self).__init__(plugin_name)
|
super().__init__(plugin_name)
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Basic plugin template created by:
|
# Basic plugin template created by:
|
||||||
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
|
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
|
||||||
#
|
#
|
||||||
|
@ -39,7 +38,7 @@ if windows_check():
|
||||||
|
|
||||||
try:
|
try:
|
||||||
hkey = winreg.OpenKey(winreg.HKEY_CURRENT_USER, 'Software\\7-Zip')
|
hkey = winreg.OpenKey(winreg.HKEY_CURRENT_USER, 'Software\\7-Zip')
|
||||||
except WindowsError:
|
except OSError:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
win_7z_path = os.path.join(winreg.QueryValueEx(hkey, 'Path')[0], '7z.exe')
|
win_7z_path = os.path.join(winreg.QueryValueEx(hkey, 'Path')[0], '7z.exe')
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
|
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
|
||||||
#
|
#
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
|
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
|
||||||
#
|
#
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
|
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
|
||||||
#
|
#
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
||||||
#
|
#
|
||||||
|
@ -19,7 +18,7 @@ class CorePlugin(PluginInitBase):
|
||||||
from .core import Core as _pluginCls
|
from .core import Core as _pluginCls
|
||||||
|
|
||||||
self._plugin_cls = _pluginCls
|
self._plugin_cls = _pluginCls
|
||||||
super(CorePlugin, self).__init__(plugin_name)
|
super().__init__(plugin_name)
|
||||||
|
|
||||||
|
|
||||||
class GtkUIPlugin(PluginInitBase):
|
class GtkUIPlugin(PluginInitBase):
|
||||||
|
@ -27,7 +26,7 @@ class GtkUIPlugin(PluginInitBase):
|
||||||
from .gtkui import GtkUI as _pluginCls
|
from .gtkui import GtkUI as _pluginCls
|
||||||
|
|
||||||
self._plugin_cls = _pluginCls
|
self._plugin_cls = _pluginCls
|
||||||
super(GtkUIPlugin, self).__init__(plugin_name)
|
super().__init__(plugin_name)
|
||||||
|
|
||||||
|
|
||||||
class WebUIPlugin(PluginInitBase):
|
class WebUIPlugin(PluginInitBase):
|
||||||
|
@ -35,4 +34,4 @@ class WebUIPlugin(PluginInitBase):
|
||||||
from .webui import WebUI as _pluginCls
|
from .webui import WebUI as _pluginCls
|
||||||
|
|
||||||
self._plugin_cls = _pluginCls
|
self._plugin_cls = _pluginCls
|
||||||
super(WebUIPlugin, self).__init__(plugin_name)
|
super().__init__(plugin_name)
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Basic plugin template created by:
|
# Basic plugin template created by:
|
||||||
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
||||||
#
|
#
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
||||||
#
|
#
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
||||||
#
|
#
|
||||||
|
@ -18,7 +17,7 @@ from ..common import get_resource
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class LabelConfig(object):
|
class LabelConfig:
|
||||||
"""
|
"""
|
||||||
there used to be some options here...
|
there used to be some options here...
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
||||||
# Copyright (C) 2007 Andrew Resch <andrewresch@gmail.com>
|
# Copyright (C) 2007 Andrew Resch <andrewresch@gmail.com>
|
||||||
|
@ -30,7 +29,7 @@ NO_LABEL = 'No Label'
|
||||||
|
|
||||||
|
|
||||||
# menu
|
# menu
|
||||||
class LabelSidebarMenu(object):
|
class LabelSidebarMenu:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|
||||||
self.treeview = component.get('FilterTreeView')
|
self.treeview = component.get('FilterTreeView')
|
||||||
|
@ -105,7 +104,7 @@ class LabelSidebarMenu(object):
|
||||||
|
|
||||||
|
|
||||||
# dialogs:
|
# dialogs:
|
||||||
class AddDialog(object):
|
class AddDialog:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -127,7 +126,7 @@ class AddDialog(object):
|
||||||
self.dialog.destroy()
|
self.dialog.destroy()
|
||||||
|
|
||||||
|
|
||||||
class OptionsDialog(object):
|
class OptionsDialog:
|
||||||
spin_ids = ['max_download_speed', 'max_upload_speed', 'stop_ratio']
|
spin_ids = ['max_download_speed', 'max_upload_speed', 'stop_ratio']
|
||||||
spin_int_ids = ['max_upload_slots', 'max_connections']
|
spin_int_ids = ['max_upload_slots', 'max_connections']
|
||||||
chk_ids = [
|
chk_ids = [
|
||||||
|
@ -172,7 +171,7 @@ class OptionsDialog(object):
|
||||||
self.builder.connect_signals(self)
|
self.builder.connect_signals(self)
|
||||||
# Show the label name in the header label
|
# Show the label name in the header label
|
||||||
self.builder.get_object('label_header').set_markup(
|
self.builder.get_object('label_header').set_markup(
|
||||||
'<b>%s:</b> %s' % (_('Label Options'), self.label)
|
'<b>{}:</b> {}'.format(_('Label Options'), self.label)
|
||||||
)
|
)
|
||||||
|
|
||||||
for chk_id, group in self.sensitive_groups:
|
for chk_id, group in self.sensitive_groups:
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
||||||
#
|
#
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
#
|
#
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
||||||
#
|
#
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
||||||
#
|
#
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2009-2010 Pedro Algarvio <pedro@algarvio.me>
|
# Copyright (C) 2009-2010 Pedro Algarvio <pedro@algarvio.me>
|
||||||
#
|
#
|
||||||
|
@ -20,7 +19,7 @@ class CorePlugin(PluginInitBase):
|
||||||
from .core import Core as _pluginCls
|
from .core import Core as _pluginCls
|
||||||
|
|
||||||
self._plugin_cls = _pluginCls
|
self._plugin_cls = _pluginCls
|
||||||
super(CorePlugin, self).__init__(plugin_name)
|
super().__init__(plugin_name)
|
||||||
|
|
||||||
|
|
||||||
class GtkUIPlugin(PluginInitBase):
|
class GtkUIPlugin(PluginInitBase):
|
||||||
|
@ -28,7 +27,7 @@ class GtkUIPlugin(PluginInitBase):
|
||||||
from .gtkui import GtkUI as _pluginCls
|
from .gtkui import GtkUI as _pluginCls
|
||||||
|
|
||||||
self._plugin_cls = _pluginCls
|
self._plugin_cls = _pluginCls
|
||||||
super(GtkUIPlugin, self).__init__(plugin_name)
|
super().__init__(plugin_name)
|
||||||
|
|
||||||
|
|
||||||
class WebUIPlugin(PluginInitBase):
|
class WebUIPlugin(PluginInitBase):
|
||||||
|
@ -36,4 +35,4 @@ class WebUIPlugin(PluginInitBase):
|
||||||
from .webui import WebUI as _pluginCls
|
from .webui import WebUI as _pluginCls
|
||||||
|
|
||||||
self._plugin_cls = _pluginCls
|
self._plugin_cls = _pluginCls
|
||||||
super(WebUIPlugin, self).__init__(plugin_name)
|
super().__init__(plugin_name)
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2009-2010 Pedro Algarvio <pedro@algarvio.me>
|
# Copyright (C) 2009-2010 Pedro Algarvio <pedro@algarvio.me>
|
||||||
#
|
#
|
||||||
|
@ -28,7 +27,7 @@ def get_resource(filename):
|
||||||
return resource_filename(__package__, os.path.join('data', filename))
|
return resource_filename(__package__, os.path.join('data', filename))
|
||||||
|
|
||||||
|
|
||||||
class CustomNotifications(object):
|
class CustomNotifications:
|
||||||
def __init__(self, plugin_name=None):
|
def __init__(self, plugin_name=None):
|
||||||
self.custom_notifications = {'email': {}, 'popup': {}, 'blink': {}, 'sound': {}}
|
self.custom_notifications = {'email': {}, 'popup': {}, 'blink': {}, 'sound': {}}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2009-2010 Pedro Algarvio <pedro@algarvio.me>
|
# Copyright (C) 2009-2010 Pedro Algarvio <pedro@algarvio.me>
|
||||||
#
|
#
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2009-2010 Pedro Algarvio <pedro@algarvio.me>
|
# Copyright (C) 2009-2010 Pedro Algarvio <pedro@algarvio.me>
|
||||||
#
|
#
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
# vim: sw=4 ts=4 fenc=utf-8 et
|
# vim: sw=4 ts=4 fenc=utf-8 et
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
# Copyright © 2009-2010 UfSoft.org - Pedro Algarvio <pedro@algarvio.me>
|
# Copyright © 2009-2010 UfSoft.org - Pedro Algarvio <pedro@algarvio.me>
|
||||||
|
@ -68,14 +67,14 @@ class TestEmailNotifications(component.Component):
|
||||||
|
|
||||||
def custom_email_message_provider(self, *evt_args, **evt_kwargs):
|
def custom_email_message_provider(self, *evt_args, **evt_kwargs):
|
||||||
log.debug('Running custom email message provider: %s %s', evt_args, evt_kwargs)
|
log.debug('Running custom email message provider: %s %s', evt_args, evt_kwargs)
|
||||||
subject = '%s Email Subject: %s' % (self.events[0].__class__.__name__, self.n)
|
subject = f'{self.events[0].__class__.__name__} Email Subject: {self.n}'
|
||||||
message = '%s Email Message: %s' % (self.events[0].__class__.__name__, self.n)
|
message = f'{self.events[0].__class__.__name__} Email Message: {self.n}'
|
||||||
return subject, message
|
return subject, message
|
||||||
|
|
||||||
def custom_popup_message_provider(self, *evt_args, **evt_kwargs):
|
def custom_popup_message_provider(self, *evt_args, **evt_kwargs):
|
||||||
log.debug('Running custom popup message provider: %s %s', evt_args, evt_kwargs)
|
log.debug('Running custom popup message provider: %s %s', evt_args, evt_kwargs)
|
||||||
title = '%s Popup Title: %s' % (self.events[0].__class__.__name__, self.n)
|
title = f'{self.events[0].__class__.__name__} Popup Title: {self.n}'
|
||||||
message = '%s Popup Message: %s' % (self.events[0].__class__.__name__, self.n)
|
message = f'{self.events[0].__class__.__name__} Popup Message: {self.n}'
|
||||||
return title, message
|
return title, message
|
||||||
|
|
||||||
def custom_blink_message_provider(self, *evt_args, **evt_kwargs):
|
def custom_blink_message_provider(self, *evt_args, **evt_kwargs):
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2009-2010 Pedro Algarvio <pedro@algarvio.me>
|
# Copyright (C) 2009-2010 Pedro Algarvio <pedro@algarvio.me>
|
||||||
#
|
#
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2009-2010 Pedro Algarvio <pedro@algarvio.me>
|
# Copyright (C) 2009-2010 Pedro Algarvio <pedro@algarvio.me>
|
||||||
#
|
#
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
|
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
|
||||||
#
|
#
|
||||||
|
@ -19,7 +18,7 @@ class CorePlugin(PluginInitBase):
|
||||||
from .core import Core as _pluginCls
|
from .core import Core as _pluginCls
|
||||||
|
|
||||||
self._plugin_cls = _pluginCls
|
self._plugin_cls = _pluginCls
|
||||||
super(CorePlugin, self).__init__(plugin_name)
|
super().__init__(plugin_name)
|
||||||
|
|
||||||
|
|
||||||
class GtkUIPlugin(PluginInitBase):
|
class GtkUIPlugin(PluginInitBase):
|
||||||
|
@ -27,7 +26,7 @@ class GtkUIPlugin(PluginInitBase):
|
||||||
from .gtkui import GtkUI as _pluginCls
|
from .gtkui import GtkUI as _pluginCls
|
||||||
|
|
||||||
self._plugin_cls = _pluginCls
|
self._plugin_cls = _pluginCls
|
||||||
super(GtkUIPlugin, self).__init__(plugin_name)
|
super().__init__(plugin_name)
|
||||||
|
|
||||||
|
|
||||||
class WebUIPlugin(PluginInitBase):
|
class WebUIPlugin(PluginInitBase):
|
||||||
|
@ -35,4 +34,4 @@ class WebUIPlugin(PluginInitBase):
|
||||||
from .webui import WebUI as _pluginCls
|
from .webui import WebUI as _pluginCls
|
||||||
|
|
||||||
self._plugin_cls = _pluginCls
|
self._plugin_cls = _pluginCls
|
||||||
super(WebUIPlugin, self).__init__(plugin_name)
|
super().__init__(plugin_name)
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Basic plugin template created by:
|
# Basic plugin template created by:
|
||||||
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
|
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
|
||||||
#
|
#
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
|
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
|
||||||
#
|
#
|
||||||
|
@ -28,7 +27,7 @@ DAYS = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
|
||||||
|
|
||||||
class SchedulerSelectWidget(Gtk.DrawingArea):
|
class SchedulerSelectWidget(Gtk.DrawingArea):
|
||||||
def __init__(self, hover):
|
def __init__(self, hover):
|
||||||
super(SchedulerSelectWidget, self).__init__()
|
super().__init__()
|
||||||
self.set_events(
|
self.set_events(
|
||||||
Gdk.EventMask.BUTTON_PRESS_MASK
|
Gdk.EventMask.BUTTON_PRESS_MASK
|
||||||
| Gdk.EventMask.BUTTON_RELEASE_MASK
|
| Gdk.EventMask.BUTTON_RELEASE_MASK
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
|
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
|
||||||
#
|
#
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
|
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
|
||||||
#
|
#
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
||||||
#
|
#
|
||||||
|
@ -19,7 +18,7 @@ class CorePlugin(PluginInitBase):
|
||||||
from .core import Core as _pluginCls
|
from .core import Core as _pluginCls
|
||||||
|
|
||||||
self._plugin_cls = _pluginCls
|
self._plugin_cls = _pluginCls
|
||||||
super(CorePlugin, self).__init__(plugin_name)
|
super().__init__(plugin_name)
|
||||||
|
|
||||||
|
|
||||||
class GtkUIPlugin(PluginInitBase):
|
class GtkUIPlugin(PluginInitBase):
|
||||||
|
@ -27,7 +26,7 @@ class GtkUIPlugin(PluginInitBase):
|
||||||
from .gtkui import GtkUI as _pluginCls
|
from .gtkui import GtkUI as _pluginCls
|
||||||
|
|
||||||
self._plugin_cls = _pluginCls
|
self._plugin_cls = _pluginCls
|
||||||
super(GtkUIPlugin, self).__init__(plugin_name)
|
super().__init__(plugin_name)
|
||||||
|
|
||||||
|
|
||||||
class WebUIPlugin(PluginInitBase):
|
class WebUIPlugin(PluginInitBase):
|
||||||
|
@ -35,4 +34,4 @@ class WebUIPlugin(PluginInitBase):
|
||||||
from .webui import WebUI as _pluginCls
|
from .webui import WebUI as _pluginCls
|
||||||
|
|
||||||
self._plugin_cls = _pluginCls
|
self._plugin_cls = _pluginCls
|
||||||
super(WebUIPlugin, self).__init__(plugin_name)
|
super().__init__(plugin_name)
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Basic plugin template created by:
|
# Basic plugin template created by:
|
||||||
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2009 Ian Martin <ianmartin@cantab.net>
|
# Copyright (C) 2009 Ian Martin <ianmartin@cantab.net>
|
||||||
# Copyright (C) 2008 Damien Churchill <damoxc@gmail.com>
|
# Copyright (C) 2008 Damien Churchill <damoxc@gmail.com>
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2009 Ian Martin <ianmartin@cantab.net>
|
# Copyright (C) 2009 Ian Martin <ianmartin@cantab.net>
|
||||||
# Copyright (C) 2008 Damien Churchill <damoxc@gmail.com>
|
# Copyright (C) 2008 Damien Churchill <damoxc@gmail.com>
|
||||||
|
@ -60,7 +59,7 @@ def change_opacity(color, opactiy):
|
||||||
return tuple(color)
|
return tuple(color)
|
||||||
|
|
||||||
|
|
||||||
class Graph(object):
|
class Graph:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.width = 100
|
self.width = 100
|
||||||
self.height = 100
|
self.height = 100
|
||||||
|
@ -176,7 +175,7 @@ class Graph(object):
|
||||||
te = self.ctx.text_extents(text)
|
te = self.ctx.text_extents(text)
|
||||||
return math.ceil(te[4] - te[0])
|
return math.ceil(te[4] - te[0])
|
||||||
|
|
||||||
y_tick_width = max((space_required(text) for text in y_tick_text))
|
y_tick_width = max(space_required(text) for text in y_tick_text)
|
||||||
|
|
||||||
top = font_extents[2] / 2
|
top = font_extents[2] / 2
|
||||||
# bounds(left, top, right, bottom)
|
# bounds(left, top, right, bottom)
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2009 Ian Martin <ianmartin@cantab.net>
|
# Copyright (C) 2009 Ian Martin <ianmartin@cantab.net>
|
||||||
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
||||||
|
@ -83,7 +82,7 @@ def text_to_rgba(color):
|
||||||
|
|
||||||
class GraphsTab(Tab):
|
class GraphsTab(Tab):
|
||||||
def __init__(self, colors):
|
def __init__(self, colors):
|
||||||
super(GraphsTab, self).__init__()
|
super().__init__()
|
||||||
|
|
||||||
builder = Gtk.Builder()
|
builder = Gtk.Builder()
|
||||||
builder.add_from_file(get_resource('tabs.ui'))
|
builder.add_from_file(get_resource('tabs.ui'))
|
||||||
|
@ -268,7 +267,7 @@ class GtkUI(Gtk3PluginBase):
|
||||||
for graph, colors in self.config['colors'].items():
|
for graph, colors in self.config['colors'].items():
|
||||||
gtkconf[graph] = {}
|
gtkconf[graph] = {}
|
||||||
for value, color in colors.items():
|
for value, color in colors.items():
|
||||||
color_btn = self.builder.get_object('%s_%s_color' % (graph, value))
|
color_btn = self.builder.get_object(f'{graph}_{value}_color')
|
||||||
try:
|
try:
|
||||||
gtkconf[graph][value] = color_btn.get_color().to_string()
|
gtkconf[graph][value] = color_btn.get_color().to_string()
|
||||||
except Exception:
|
except Exception:
|
||||||
|
@ -283,7 +282,7 @@ class GtkUI(Gtk3PluginBase):
|
||||||
for graph, colors in self.config['colors'].items():
|
for graph, colors in self.config['colors'].items():
|
||||||
for value, color in colors.items():
|
for value, color in colors.items():
|
||||||
try:
|
try:
|
||||||
color_btn = self.builder.get_object('%s_%s_color' % (graph, value))
|
color_btn = self.builder.get_object(f'{graph}_{value}_color')
|
||||||
color_btn.set_rgba(text_to_rgba(color))
|
color_btn.set_rgba(text_to_rgba(color))
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
log.debug('Unable to set %s %s %s: %s', graph, value, color, ex)
|
log.debug('Unable to set %s %s %s: %s', graph, value, color, ex)
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# This file is part of Deluge and is licensed under GNU General Public License 3.0, or later, with
|
# This file is part of Deluge and is licensed under GNU General Public License 3.0, or later, with
|
||||||
# the additional special exception to link portions of this program with the OpenSSL library.
|
# the additional special exception to link portions of this program with the OpenSSL library.
|
||||||
|
@ -88,7 +87,7 @@ class StatsTestCase(BaseTestCase):
|
||||||
TorrentDetails()
|
TorrentDetails()
|
||||||
Preferences()
|
Preferences()
|
||||||
|
|
||||||
class FakeFile(object):
|
class FakeFile:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.data = []
|
self.data = []
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
||||||
#
|
#
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2009 Ian Martin <ianmartin@cantab.net>
|
# Copyright (C) 2009 Ian Martin <ianmartin@cantab.net>
|
||||||
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2010 John Garland <johnnybg+deluge@gmail.com>
|
# Copyright (C) 2010 John Garland <johnnybg+deluge@gmail.com>
|
||||||
#
|
#
|
||||||
|
@ -20,7 +19,7 @@ class CorePlugin(PluginInitBase):
|
||||||
from .core import Core as _pluginCls
|
from .core import Core as _pluginCls
|
||||||
|
|
||||||
self._plugin_cls = _pluginCls
|
self._plugin_cls = _pluginCls
|
||||||
super(CorePlugin, self).__init__(plugin_name)
|
super().__init__(plugin_name)
|
||||||
|
|
||||||
|
|
||||||
class GtkUIPlugin(PluginInitBase):
|
class GtkUIPlugin(PluginInitBase):
|
||||||
|
@ -28,7 +27,7 @@ class GtkUIPlugin(PluginInitBase):
|
||||||
from .gtkui import GtkUI as _pluginCls
|
from .gtkui import GtkUI as _pluginCls
|
||||||
|
|
||||||
self._plugin_cls = _pluginCls
|
self._plugin_cls = _pluginCls
|
||||||
super(GtkUIPlugin, self).__init__(plugin_name)
|
super().__init__(plugin_name)
|
||||||
|
|
||||||
|
|
||||||
class WebUIPlugin(PluginInitBase):
|
class WebUIPlugin(PluginInitBase):
|
||||||
|
@ -36,4 +35,4 @@ class WebUIPlugin(PluginInitBase):
|
||||||
from .webui import WebUI as _pluginCls
|
from .webui import WebUI as _pluginCls
|
||||||
|
|
||||||
self._plugin_cls = _pluginCls
|
self._plugin_cls = _pluginCls
|
||||||
super(WebUIPlugin, self).__init__(plugin_name)
|
super().__init__(plugin_name)
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Basic plugin template created by:
|
# Basic plugin template created by:
|
||||||
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2010 John Garland <johnnybg+deluge@gmail.com>
|
# Copyright (C) 2010 John Garland <johnnybg+deluge@gmail.com>
|
||||||
#
|
#
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2010 John Garland <johnnybg+deluge@gmail.com>
|
# Copyright (C) 2010 John Garland <johnnybg+deluge@gmail.com>
|
||||||
#
|
#
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2010 John Garland <johnnybg+deluge@gmail.com>
|
# Copyright (C) 2010 John Garland <johnnybg+deluge@gmail.com>
|
||||||
#
|
#
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2010 John Garland <johnnybg+deluge@gmail.com>
|
# Copyright (C) 2010 John Garland <johnnybg+deluge@gmail.com>
|
||||||
#
|
#
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2009 Damien Churchill <damoxc@gmail.com>
|
# Copyright (C) 2009 Damien Churchill <damoxc@gmail.com>
|
||||||
#
|
#
|
||||||
|
@ -19,7 +18,7 @@ class CorePlugin(PluginInitBase):
|
||||||
from .core import Core as _pluginCls
|
from .core import Core as _pluginCls
|
||||||
|
|
||||||
self._plugin_cls = _pluginCls
|
self._plugin_cls = _pluginCls
|
||||||
super(CorePlugin, self).__init__(plugin_name)
|
super().__init__(plugin_name)
|
||||||
|
|
||||||
|
|
||||||
class GtkUIPlugin(PluginInitBase):
|
class GtkUIPlugin(PluginInitBase):
|
||||||
|
@ -27,7 +26,7 @@ class GtkUIPlugin(PluginInitBase):
|
||||||
from .gtkui import GtkUI as _pluginCls
|
from .gtkui import GtkUI as _pluginCls
|
||||||
|
|
||||||
self._plugin_cls = _pluginCls
|
self._plugin_cls = _pluginCls
|
||||||
super(GtkUIPlugin, self).__init__(plugin_name)
|
super().__init__(plugin_name)
|
||||||
|
|
||||||
|
|
||||||
class WebUIPlugin(PluginInitBase):
|
class WebUIPlugin(PluginInitBase):
|
||||||
|
@ -35,4 +34,4 @@ class WebUIPlugin(PluginInitBase):
|
||||||
from webui import WebUI as _pluginCls
|
from webui import WebUI as _pluginCls
|
||||||
|
|
||||||
self._plugin_cls = _pluginCls
|
self._plugin_cls = _pluginCls
|
||||||
super(WebUIPlugin, self).__init__(plugin_name)
|
super().__init__(plugin_name)
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
#
|
||||||
# Basic plugin template created by:
|
# Basic plugin template created by:
|
||||||
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue