mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-21 01:28:53 +00:00
[Lint] Update pre-commit hook and isort versions
* Fixed black hook requiring Py3.6 to installed locally. Will now assume Py3.6+ in installed. * Added isort traceback in pre-commit flake8 hook fails * Updated versions of Black, Prettier and isort * Keep Flake8 at 3.7.9 due to E402 issue: https://gitlab.com/pycqa/flake8/-/issues/638 * New pyproject config for isort v5 with fixes for Python 2 imports. * Fixed travis config to run Python 3.6 for lint run. Replaced the virtualenv with_system_site_packages config with Travis specific Python config value so lint run doesn't attempt to append with_system_site_packages to Python 3.6 command.
This commit is contained in:
parent
23a48dd01c
commit
610a1bb313
114 changed files with 955 additions and 1034 deletions
|
@ -6,28 +6,29 @@ exclude: >
|
||||||
)$
|
)$
|
||||||
repos:
|
repos:
|
||||||
- repo: https://github.com/ambv/black
|
- repo: https://github.com/ambv/black
|
||||||
rev: 19.10b0
|
rev: 20.8b1
|
||||||
hooks:
|
hooks:
|
||||||
- id: black
|
- id: black
|
||||||
name: Fmt Black
|
name: Fmt Black
|
||||||
language_version: python3.6
|
- repo: https://github.com/pre-commit/mirrors-prettier
|
||||||
- repo: https://github.com/prettier/prettier
|
rev: v2.2.1
|
||||||
rev: 1.19.1
|
|
||||||
hooks:
|
hooks:
|
||||||
- id: prettier
|
- id: prettier
|
||||||
name: Fmt Prettier
|
name: Fmt Prettier
|
||||||
# Workaround to list modified files only.
|
# Workaround to list modified files only.
|
||||||
args: [--list-different]
|
args: [--list-different]
|
||||||
- repo: https://gitlab.com/pycqa/flake8
|
- repo: https://gitlab.com/pycqa/flake8
|
||||||
|
# v3.7.9 due to E402 issue: https://gitlab.com/pycqa/flake8/-/issues/638
|
||||||
rev: 3.7.9
|
rev: 3.7.9
|
||||||
hooks:
|
hooks:
|
||||||
- id: flake8
|
- id: flake8
|
||||||
name: Chk Flake8
|
name: Chk Flake8
|
||||||
additional_dependencies:
|
additional_dependencies:
|
||||||
- flake8-isort==2.7
|
- flake8-isort==4.0.0
|
||||||
- pep8-naming==0.8.2
|
- pep8-naming==0.11.1
|
||||||
|
args: [--isort-show-traceback]
|
||||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||||
rev: v2.4.0
|
rev: v3.4.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: double-quote-string-fixer
|
- id: double-quote-string-fixer
|
||||||
name: Fix Double-quotes
|
name: Fix Double-quotes
|
||||||
|
|
23
.travis.yml
23
.travis.yml
|
@ -4,10 +4,8 @@ dist: xenial
|
||||||
language: python
|
language: python
|
||||||
python:
|
python:
|
||||||
# Travis Xenial Python to support system_site_packages
|
# Travis Xenial Python to support system_site_packages
|
||||||
- 3.5
|
- 3.5_with_system_site_packages
|
||||||
cache: pip
|
cache: pip
|
||||||
virtualenv:
|
|
||||||
system_site_packages: true
|
|
||||||
|
|
||||||
env:
|
env:
|
||||||
global:
|
global:
|
||||||
|
@ -21,19 +19,20 @@ jobs:
|
||||||
include:
|
include:
|
||||||
- name: Unit tests
|
- name: Unit tests
|
||||||
env: TOX_ENV=py3
|
env: TOX_ENV=py3
|
||||||
- name: Unit tests - libtorrent 1.2
|
#~ - name: Unit tests - libtorrent 1.2
|
||||||
env: TOX_ENV=py3
|
#~ env: TOX_ENV=py3
|
||||||
addons:
|
#~ addons:
|
||||||
apt:
|
#~ apt:
|
||||||
sources: [sourceline: "ppa:libtorrent.org/1.2-daily"]
|
#~ sources: [sourceline: "ppa:libtorrent.org/1.2-daily"]
|
||||||
packages: [python3-libtorrent, python3-venv]
|
#~ packages: [python3-libtorrent, python3-venv]
|
||||||
- name: Unit tests - Python 2
|
- name: Unit tests - Python 2
|
||||||
env: TOX_ENV=py27
|
env: TOX_ENV=py27
|
||||||
python: 2.7
|
python: 2.7_with_system_site_packages
|
||||||
- if: commit_message =~ SECURITY_TEST
|
- if: commit_message =~ SECURITY_TEST
|
||||||
env: TOX_ENV=security
|
env: TOX_ENV=security
|
||||||
- name: Code linting
|
- name: Code linting
|
||||||
env: TOX_ENV=lint
|
env: TOX_ENV=lint
|
||||||
|
python: 3.6
|
||||||
- name: Docs build
|
- name: Docs build
|
||||||
env: TOX_ENV=docs
|
env: TOX_ENV=docs
|
||||||
- name: GTK unit tests
|
- name: GTK unit tests
|
||||||
|
@ -73,7 +72,9 @@ install:
|
||||||
before_script:
|
before_script:
|
||||||
- export PYTHONPATH=$PYTHONPATH:$PWD
|
- export PYTHONPATH=$PYTHONPATH:$PWD
|
||||||
# Verify libtorrent installed and version
|
# Verify libtorrent installed and version
|
||||||
- python -c "import libtorrent as lt; print(lt.__version__)"
|
- "if [ $TOX_ENV != 'lint' ]; then
|
||||||
|
python -c 'import libtorrent as lt; print(lt.__version__)';
|
||||||
|
fi"
|
||||||
# Start xvfb for the GTKUI tests
|
# Start xvfb for the GTKUI tests
|
||||||
- "if [ $TOX_ENV == 'gtkui' ]; then
|
- "if [ $TOX_ENV == 'gtkui' ]; then
|
||||||
/sbin/start-stop-daemon --start --quiet --background \
|
/sbin/start-stop-daemon --start --quiet --background \
|
||||||
|
|
|
@ -43,8 +43,8 @@ try:
|
||||||
from urllib.request import pathname2url
|
from urllib.request import pathname2url
|
||||||
except ImportError:
|
except ImportError:
|
||||||
# PY2 fallback
|
# PY2 fallback
|
||||||
from urlparse import urljoin # pylint: disable=ungrouped-imports
|
|
||||||
from urllib import pathname2url, unquote_plus # pylint: disable=ungrouped-imports
|
from urllib import pathname2url, unquote_plus # pylint: disable=ungrouped-imports
|
||||||
|
from urlparse import urljoin # pylint: disable=ungrouped-imports
|
||||||
|
|
||||||
# Windows workaround for HTTPS requests requiring certificate authority bundle.
|
# Windows workaround for HTTPS requests requiring certificate authority bundle.
|
||||||
# see: https://twistedmatrix.com/trac/ticket/9209
|
# see: https://twistedmatrix.com/trac/ticket/9209
|
||||||
|
@ -1013,9 +1013,9 @@ def decode_bytes(byte_str, encoding='utf8'):
|
||||||
if encoding.lower() not in ['utf8', 'utf-8']:
|
if encoding.lower() not in ['utf8', 'utf-8']:
|
||||||
encodings.insert(0, lambda: (encoding, 'strict'))
|
encodings.insert(0, lambda: (encoding, 'strict'))
|
||||||
|
|
||||||
for l in encodings:
|
for enc in encodings:
|
||||||
try:
|
try:
|
||||||
return byte_str.decode(*l())
|
return byte_str.decode(*enc())
|
||||||
except UnicodeDecodeError:
|
except UnicodeDecodeError:
|
||||||
pass
|
pass
|
||||||
return ''
|
return ''
|
||||||
|
@ -1144,6 +1144,7 @@ AUTH_LEVEL_DEFAULT = AUTH_LEVEL_NORMAL
|
||||||
|
|
||||||
def create_auth_file():
|
def create_auth_file():
|
||||||
import stat
|
import stat
|
||||||
|
|
||||||
import deluge.configmanager
|
import deluge.configmanager
|
||||||
|
|
||||||
auth_file = deluge.configmanager.get_config_dir('auth')
|
auth_file = deluge.configmanager.get_config_dir('auth')
|
||||||
|
@ -1159,6 +1160,7 @@ def create_auth_file():
|
||||||
def create_localclient_account(append=False):
|
def create_localclient_account(append=False):
|
||||||
import random
|
import random
|
||||||
from hashlib import sha1 as sha
|
from hashlib import sha1 as sha
|
||||||
|
|
||||||
import deluge.configmanager
|
import deluge.configmanager
|
||||||
|
|
||||||
auth_file = deluge.configmanager.get_config_dir('auth')
|
auth_file = deluge.configmanager.get_config_dir('auth')
|
||||||
|
@ -1244,8 +1246,7 @@ def set_env_variable(name, value):
|
||||||
os.environ[name] = value.encode('utf8')
|
os.environ[name] = value.encode('utf8')
|
||||||
|
|
||||||
if windows_check():
|
if windows_check():
|
||||||
from ctypes import windll
|
from ctypes import cdll, windll
|
||||||
from ctypes import cdll
|
|
||||||
|
|
||||||
# Update the copy maintained by Windows (so SysInternals Process Explorer sees it)
|
# Update the copy maintained by Windows (so SysInternals Process Explorer sees it)
|
||||||
result = windll.kernel32.SetEnvironmentVariableW(name, value)
|
result = windll.kernel32.SetEnvironmentVariableW(name, value)
|
||||||
|
@ -1274,7 +1275,7 @@ def unicode_argv():
|
||||||
# Versions 2.x of Python don't support Unicode in sys.argv on
|
# Versions 2.x of Python don't support Unicode in sys.argv on
|
||||||
# Windows, with the underlying Windows API instead replacing multi-byte
|
# Windows, with the underlying Windows API instead replacing multi-byte
|
||||||
# characters with '?'.
|
# characters with '?'.
|
||||||
from ctypes import POINTER, byref, cdll, c_int, windll
|
from ctypes import POINTER, byref, c_int, cdll, windll
|
||||||
from ctypes.wintypes import LPCWSTR, LPWSTR
|
from ctypes.wintypes import LPCWSTR, LPWSTR
|
||||||
|
|
||||||
get_cmd_linew = cdll.kernel32.GetCommandLineW
|
get_cmd_linew = cdll.kernel32.GetCommandLineW
|
||||||
|
|
|
@ -204,9 +204,9 @@ class Config(object):
|
||||||
global callLater
|
global callLater
|
||||||
if callLater is None:
|
if callLater is None:
|
||||||
# Must import here and not at the top or it will throw ReactorAlreadyInstalledError
|
# Must import here and not at the top or it will throw ReactorAlreadyInstalledError
|
||||||
from twisted.internet.reactor import (
|
from twisted.internet.reactor import ( # pylint: disable=redefined-outer-name
|
||||||
callLater,
|
callLater,
|
||||||
) # pylint: disable=redefined-outer-name
|
)
|
||||||
# Run the set_function for this key if any
|
# Run the set_function for this key if any
|
||||||
try:
|
try:
|
||||||
for func in self.__set_functions[key]:
|
for func in self.__set_functions[key]:
|
||||||
|
@ -304,9 +304,9 @@ class Config(object):
|
||||||
global callLater
|
global callLater
|
||||||
if callLater is None:
|
if callLater is None:
|
||||||
# Must import here and not at the top or it will throw ReactorAlreadyInstalledError
|
# Must import here and not at the top or it will throw ReactorAlreadyInstalledError
|
||||||
from twisted.internet.reactor import (
|
from twisted.internet.reactor import ( # pylint: disable=redefined-outer-name
|
||||||
callLater,
|
callLater,
|
||||||
) # pylint: disable=redefined-outer-name
|
)
|
||||||
|
|
||||||
# We set the save_timer for 5 seconds if not already set
|
# We set the save_timer for 5 seconds if not already set
|
||||||
if not self._save_timer or not self._save_timer.active():
|
if not self._save_timer or not self._save_timer.active():
|
||||||
|
|
|
@ -57,10 +57,10 @@ from deluge.event import (
|
||||||
from deluge.httpdownloader import download_file
|
from deluge.httpdownloader import download_file
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from urllib.request import urlopen, URLError
|
from urllib.request import URLError, urlopen
|
||||||
except ImportError:
|
except ImportError:
|
||||||
# PY2 fallback
|
# PY2 fallback
|
||||||
from urllib2 import urlopen, URLError
|
from urllib2 import URLError, urlopen
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
|
@ -200,6 +200,7 @@ class Daemon(object):
|
||||||
if rpc not in self.get_method_list():
|
if rpc not in self.get_method_list():
|
||||||
return False
|
return False
|
||||||
|
|
||||||
return self.rpcserver.get_session_auth_level() >= self.rpcserver.get_rpc_auth_level(
|
return (
|
||||||
rpc
|
self.rpcserver.get_session_auth_level()
|
||||||
|
>= self.rpcserver.get_rpc_auth_level(rpc)
|
||||||
)
|
)
|
||||||
|
|
|
@ -100,9 +100,7 @@ def tracker_error_filter(torrent_ids, values):
|
||||||
|
|
||||||
|
|
||||||
class FilterManager(component.Component):
|
class FilterManager(component.Component):
|
||||||
"""FilterManager
|
"""FilterManager"""
|
||||||
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __init__(self, core):
|
def __init__(self, core):
|
||||||
component.Component.__init__(self, 'FilterManager')
|
component.Component.__init__(self, 'FilterManager')
|
||||||
|
|
|
@ -190,23 +190,11 @@ Deluge.ux.preferences.AutoAddPage = Ext.extend(Ext.Panel, {
|
||||||
|
|
||||||
onSelectionChange: function (dv, selections) {
|
onSelectionChange: function (dv, selections) {
|
||||||
if (selections.length) {
|
if (selections.length) {
|
||||||
this.panel
|
this.panel.getBottomToolbar().items.get(1).enable();
|
||||||
.getBottomToolbar()
|
this.panel.getBottomToolbar().items.get(3).enable();
|
||||||
.items.get(1)
|
|
||||||
.enable();
|
|
||||||
this.panel
|
|
||||||
.getBottomToolbar()
|
|
||||||
.items.get(3)
|
|
||||||
.enable();
|
|
||||||
} else {
|
} else {
|
||||||
this.panel
|
this.panel.getBottomToolbar().items.get(1).disable();
|
||||||
.getBottomToolbar()
|
this.panel.getBottomToolbar().items.get(3).disable();
|
||||||
.items.get(1)
|
|
||||||
.disable();
|
|
||||||
this.panel
|
|
||||||
.getBottomToolbar()
|
|
||||||
.items.get(3)
|
|
||||||
.disable();
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -324,18 +324,14 @@ Deluge.ux.AutoAdd.AutoAddWindowBase = Ext.extend(Ext.Window, {
|
||||||
accounts[index] = [accounts[index]['username']];
|
accounts[index] = [accounts[index]['username']];
|
||||||
}
|
}
|
||||||
me.accounts.loadData(accounts, false);
|
me.accounts.loadData(accounts, false);
|
||||||
Ext.getCmp('owner')
|
Ext.getCmp('owner').setValue(owner).enable();
|
||||||
.setValue(owner)
|
|
||||||
.enable();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function on_accounts_failure(failure) {
|
function on_accounts_failure(failure) {
|
||||||
deluge.client.autoadd.get_auth_user({
|
deluge.client.autoadd.get_auth_user({
|
||||||
success: function (user) {
|
success: function (user) {
|
||||||
me.accounts.loadData([[user]], false);
|
me.accounts.loadData([[user]], false);
|
||||||
Ext.getCmp('owner')
|
Ext.getCmp('owner').setValue(user).disable(true);
|
||||||
.setValue(user)
|
|
||||||
.disable(true);
|
|
||||||
},
|
},
|
||||||
scope: this,
|
scope: this,
|
||||||
});
|
});
|
||||||
|
|
|
@ -275,23 +275,11 @@ Deluge.ux.preferences.ExecutePage = Ext.extend(Ext.Panel, {
|
||||||
|
|
||||||
onSelectionChange: function (dv, selections) {
|
onSelectionChange: function (dv, selections) {
|
||||||
if (selections.length) {
|
if (selections.length) {
|
||||||
this.panel
|
this.panel.getBottomToolbar().items.get(1).enable();
|
||||||
.getBottomToolbar()
|
this.panel.getBottomToolbar().items.get(3).enable();
|
||||||
.items.get(1)
|
|
||||||
.enable();
|
|
||||||
this.panel
|
|
||||||
.getBottomToolbar()
|
|
||||||
.items.get(3)
|
|
||||||
.enable();
|
|
||||||
} else {
|
} else {
|
||||||
this.panel
|
this.panel.getBottomToolbar().items.get(1).disable();
|
||||||
.getBottomToolbar()
|
this.panel.getBottomToolbar().items.get(3).disable();
|
||||||
.items.get(1)
|
|
||||||
.disable();
|
|
||||||
this.panel
|
|
||||||
.getBottomToolbar()
|
|
||||||
.items.get(3)
|
|
||||||
.disable();
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -110,10 +110,7 @@ Deluge.ux.AddLabelWindow = Ext.extend(Ext.Window, {
|
||||||
|
|
||||||
onShow: function (comp) {
|
onShow: function (comp) {
|
||||||
Deluge.ux.AddLabelWindow.superclass.onShow.call(this, comp);
|
Deluge.ux.AddLabelWindow.superclass.onShow.call(this, comp);
|
||||||
this.form
|
this.form.getForm().findField('name').focus(false, 150);
|
||||||
.getForm()
|
|
||||||
.findField('name')
|
|
||||||
.focus(false, 150);
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ except ImportError:
|
||||||
|
|
||||||
try:
|
try:
|
||||||
require_version('Notify', '0.7')
|
require_version('Notify', '0.7')
|
||||||
from gi.repository import Notify, GLib
|
from gi.repository import GLib, Notify
|
||||||
except (ValueError, ImportError):
|
except (ValueError, ImportError):
|
||||||
POPUP_AVAILABLE = False
|
POPUP_AVAILABLE = False
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -72,14 +72,15 @@ class StatsTestCase(BaseTestCase):
|
||||||
|
|
||||||
Not strictly a unit test, but tests if calls do not fail...
|
Not strictly a unit test, but tests if calls do not fail...
|
||||||
"""
|
"""
|
||||||
from deluge.ui.gtkui.gtkui import DEFAULT_PREFS
|
from deluge_stats import graph, gtkui
|
||||||
from deluge.ui.gtkui.preferences import Preferences
|
|
||||||
from deluge.ui.gtkui.mainwindow import MainWindow
|
|
||||||
from deluge.configmanager import ConfigManager
|
from deluge.configmanager import ConfigManager
|
||||||
|
from deluge.ui.gtkui.gtkui import DEFAULT_PREFS
|
||||||
|
from deluge.ui.gtkui.mainwindow import MainWindow
|
||||||
from deluge.ui.gtkui.pluginmanager import PluginManager
|
from deluge.ui.gtkui.pluginmanager import PluginManager
|
||||||
|
from deluge.ui.gtkui.preferences import Preferences
|
||||||
from deluge.ui.gtkui.torrentdetails import TorrentDetails
|
from deluge.ui.gtkui.torrentdetails import TorrentDetails
|
||||||
from deluge.ui.gtkui.torrentview import TorrentView
|
from deluge.ui.gtkui.torrentview import TorrentView
|
||||||
from deluge_stats import graph, gtkui
|
|
||||||
|
|
||||||
ConfigManager('gtkui.conf', defaults=DEFAULT_PREFS)
|
ConfigManager('gtkui.conf', defaults=DEFAULT_PREFS)
|
||||||
|
|
||||||
|
|
|
@ -26,8 +26,8 @@ try:
|
||||||
from urllib.request import url2pathname
|
from urllib.request import url2pathname
|
||||||
except ImportError:
|
except ImportError:
|
||||||
# PY2 fallback
|
# PY2 fallback
|
||||||
from urlparse import urlparse # pylint: disable=ungrouped-imports
|
|
||||||
from urllib import url2pathname # pylint: disable=ungrouped-imports
|
from urllib import url2pathname # pylint: disable=ungrouped-imports
|
||||||
|
from urlparse import urlparse # pylint: disable=ungrouped-imports
|
||||||
|
|
||||||
|
|
||||||
class Command(BaseCommand):
|
class Command(BaseCommand):
|
||||||
|
|
|
@ -106,8 +106,8 @@ class Command(BaseCommand):
|
||||||
|
|
||||||
elif options.install:
|
elif options.install:
|
||||||
import os.path
|
import os.path
|
||||||
from base64 import b64encode
|
|
||||||
import shutil
|
import shutil
|
||||||
|
from base64 import b64encode
|
||||||
|
|
||||||
filepath = options.install
|
filepath = options.install
|
||||||
|
|
||||||
|
|
|
@ -112,9 +112,9 @@ class Console(UI):
|
||||||
)
|
)
|
||||||
# To properly print help message for the console commands ( e.g. deluge-console info -h),
|
# To properly print help message for the console commands ( e.g. deluge-console info -h),
|
||||||
# we add a subparser for each command which will trigger the help/usage when given
|
# we add a subparser for each command which will trigger the help/usage when given
|
||||||
from deluge.ui.console.parser import (
|
from deluge.ui.console.parser import ( # import here because (see top)
|
||||||
ConsoleCommandParser,
|
ConsoleCommandParser,
|
||||||
) # import here because (see top)
|
)
|
||||||
|
|
||||||
self.console_parser = ConsoleCommandParser(
|
self.console_parser = ConsoleCommandParser(
|
||||||
parents=[self.parser],
|
parents=[self.parser],
|
||||||
|
|
|
@ -26,9 +26,9 @@ except ImportError:
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import signal
|
import signal
|
||||||
from fcntl import ioctl
|
|
||||||
import termios
|
|
||||||
import struct
|
import struct
|
||||||
|
import termios
|
||||||
|
from fcntl import ioctl
|
||||||
except ImportError:
|
except ImportError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
@ -1061,9 +1061,9 @@ class ComboInput(InputField):
|
||||||
# No match, so start at beginning
|
# No match, so start at beginning
|
||||||
select_in_range(0, selected)
|
select_in_range(0, selected)
|
||||||
|
|
||||||
from deluge.ui.console.widgets.popup import (
|
from deluge.ui.console.widgets.popup import ( # Must import here
|
||||||
SelectablePopup,
|
SelectablePopup,
|
||||||
) # Must import here
|
)
|
||||||
|
|
||||||
select_popup = SelectablePopup(
|
select_popup = SelectablePopup(
|
||||||
self.parent,
|
self.parent,
|
||||||
|
|
|
@ -40,9 +40,10 @@ class Gtk(UI):
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
super(Gtk, self).start()
|
super(Gtk, self).start()
|
||||||
from .gtkui import GtkUI
|
|
||||||
import deluge.common
|
import deluge.common
|
||||||
|
|
||||||
|
from .gtkui import GtkUI
|
||||||
|
|
||||||
def run(options):
|
def run(options):
|
||||||
try:
|
try:
|
||||||
gtkui = GtkUI(options)
|
gtkui = GtkUI(options)
|
||||||
|
|
|
@ -159,8 +159,8 @@ class ErrorDialog(BaseDialog):
|
||||||
)
|
)
|
||||||
|
|
||||||
if traceback:
|
if traceback:
|
||||||
import traceback
|
|
||||||
import sys
|
import sys
|
||||||
|
import traceback
|
||||||
|
|
||||||
tb = sys.exc_info()
|
tb = sys.exc_info()
|
||||||
tb = traceback.format_exc(tb[2])
|
tb = traceback.format_exc(tb[2])
|
||||||
|
|
|
@ -75,7 +75,7 @@ set_prgname('deluge')
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from setproctitle import setproctitle, getproctitle
|
from setproctitle import getproctitle, setproctitle
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
|
||||||
def setproctitle(title):
|
def setproctitle(title):
|
||||||
|
|
|
@ -31,8 +31,8 @@ try:
|
||||||
from urllib.request import url2pathname
|
from urllib.request import url2pathname
|
||||||
except ImportError:
|
except ImportError:
|
||||||
# PY2 fallback
|
# PY2 fallback
|
||||||
from urlparse import urlparse # pylint: disable=ungrouped-imports
|
|
||||||
from urllib import url2pathname # pylint: disable=ungrouped-imports
|
from urllib import url2pathname # pylint: disable=ungrouped-imports
|
||||||
|
from urlparse import urlparse # pylint: disable=ungrouped-imports
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -84,8 +84,8 @@ class IPCInterface(component.Component):
|
||||||
if windows_check():
|
if windows_check():
|
||||||
# If we're on windows we need to check the global mutex to see if deluge is
|
# If we're on windows we need to check the global mutex to see if deluge is
|
||||||
# already running.
|
# already running.
|
||||||
import win32event
|
|
||||||
import win32api
|
import win32api
|
||||||
|
import win32event
|
||||||
import winerror
|
import winerror
|
||||||
|
|
||||||
self.mutex = win32event.CreateMutex(None, False, 'deluge')
|
self.mutex = win32event.CreateMutex(None, False, 'deluge')
|
||||||
|
|
|
@ -627,8 +627,7 @@ class ListView(object):
|
||||||
unique=False,
|
unique=False,
|
||||||
default_sort=False,
|
default_sort=False,
|
||||||
):
|
):
|
||||||
"""Add a text column to the listview. Only the header name is required.
|
"""Add a text column to the listview. Only the header name is required."""
|
||||||
"""
|
|
||||||
render = Gtk.CellRendererText()
|
render = Gtk.CellRendererText()
|
||||||
self.add_column(
|
self.add_column(
|
||||||
header,
|
header,
|
||||||
|
|
|
@ -305,8 +305,8 @@ class PeersTab(Tab):
|
||||||
peer_ip = peer['ip']
|
peer_ip = peer['ip']
|
||||||
else:
|
else:
|
||||||
# This is an IPv6 address
|
# This is an IPv6 address
|
||||||
import socket
|
|
||||||
import binascii
|
import binascii
|
||||||
|
import socket
|
||||||
|
|
||||||
# Split out the :port
|
# Split out the :port
|
||||||
ip = ':'.join(peer['ip'].split(':')[:-1])
|
ip = ':'.join(peer['ip'].split(':')[:-1])
|
||||||
|
|
|
@ -1180,8 +1180,8 @@ class Preferences(component.Component):
|
||||||
chooser.destroy()
|
chooser.destroy()
|
||||||
return
|
return
|
||||||
|
|
||||||
from base64 import b64encode
|
|
||||||
import shutil
|
import shutil
|
||||||
|
from base64 import b64encode
|
||||||
|
|
||||||
filename = os.path.split(filepath)[1]
|
filename = os.path.split(filepath)[1]
|
||||||
shutil.copyfile(filepath, os.path.join(get_config_dir(), 'plugins', filename))
|
shutil.copyfile(filepath, os.path.join(get_config_dir(), 'plugins', filename))
|
||||||
|
|
|
@ -112,11 +112,11 @@ class TorrentDetails(component.Component):
|
||||||
self.tabs = {}
|
self.tabs = {}
|
||||||
|
|
||||||
# Add the default tabs
|
# Add the default tabs
|
||||||
from .status_tab import StatusTab
|
|
||||||
from .details_tab import DetailsTab
|
from .details_tab import DetailsTab
|
||||||
from .files_tab import FilesTab
|
from .files_tab import FilesTab
|
||||||
from .peers_tab import PeersTab
|
|
||||||
from .options_tab import OptionsTab
|
from .options_tab import OptionsTab
|
||||||
|
from .peers_tab import PeersTab
|
||||||
|
from .status_tab import StatusTab
|
||||||
from .trackers_tab import TrackersTab
|
from .trackers_tab import TrackersTab
|
||||||
|
|
||||||
default_tabs = {
|
default_tabs = {
|
||||||
|
|
|
@ -60,10 +60,7 @@ Deluge.AddTrackerWindow = Ext.extend(Ext.Window, {
|
||||||
},
|
},
|
||||||
|
|
||||||
onAddClick: function () {
|
onAddClick: function () {
|
||||||
var trackers = this.form
|
var trackers = this.form.getForm().findField('trackers').getValue();
|
||||||
.getForm()
|
|
||||||
.findField('trackers')
|
|
||||||
.getValue();
|
|
||||||
trackers = trackers.split('\n');
|
trackers = trackers.split('\n');
|
||||||
|
|
||||||
var cleaned = [];
|
var cleaned = [];
|
||||||
|
@ -78,17 +75,11 @@ Deluge.AddTrackerWindow = Ext.extend(Ext.Window, {
|
||||||
);
|
);
|
||||||
this.fireEvent('add', cleaned);
|
this.fireEvent('add', cleaned);
|
||||||
this.hide();
|
this.hide();
|
||||||
this.form
|
this.form.getForm().findField('trackers').setValue('');
|
||||||
.getForm()
|
|
||||||
.findField('trackers')
|
|
||||||
.setValue('');
|
|
||||||
},
|
},
|
||||||
|
|
||||||
onCancelClick: function () {
|
onCancelClick: function () {
|
||||||
this.form
|
this.form.getForm().findField('trackers').setValue('');
|
||||||
.getForm()
|
|
||||||
.findField('trackers')
|
|
||||||
.setValue('');
|
|
||||||
this.hide();
|
this.hide();
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -26,9 +26,7 @@ Ext.state.Manager.setProvider(
|
||||||
// configurable parameters
|
// configurable parameters
|
||||||
Ext.apply(Ext, {
|
Ext.apply(Ext, {
|
||||||
escapeHTML: function (text) {
|
escapeHTML: function (text) {
|
||||||
text = String(text)
|
text = String(text).replace('<', '<').replace('>', '>');
|
||||||
.replace('<', '<')
|
|
||||||
.replace('>', '>');
|
|
||||||
return text.replace('&', '&');
|
return text.replace('&', '&');
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -83,14 +83,8 @@ Deluge.EditConnectionWindow = Ext.extend(Ext.Window, {
|
||||||
show: function (connection) {
|
show: function (connection) {
|
||||||
Deluge.EditConnectionWindow.superclass.show.call(this);
|
Deluge.EditConnectionWindow.superclass.show.call(this);
|
||||||
|
|
||||||
this.form
|
this.form.getForm().findField('host').setValue(connection.get('host'));
|
||||||
.getForm()
|
this.form.getForm().findField('port').setValue(connection.get('port'));
|
||||||
.findField('host')
|
|
||||||
.setValue(connection.get('host'));
|
|
||||||
this.form
|
|
||||||
.getForm()
|
|
||||||
.findField('port')
|
|
||||||
.setValue(connection.get('port'));
|
|
||||||
this.form
|
this.form
|
||||||
.getForm()
|
.getForm()
|
||||||
.findField('username')
|
.findField('username')
|
||||||
|
|
|
@ -54,10 +54,7 @@ Deluge.EditTrackerWindow = Ext.extend(Ext.Window, {
|
||||||
Deluge.EditTrackerWindow.superclass.show.call(this);
|
Deluge.EditTrackerWindow.superclass.show.call(this);
|
||||||
|
|
||||||
this.record = record;
|
this.record = record;
|
||||||
this.form
|
this.form.getForm().findField('tracker').setValue(record.data['url']);
|
||||||
.getForm()
|
|
||||||
.findField('tracker')
|
|
||||||
.setValue(record.data['url']);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
onCancelClick: function () {
|
onCancelClick: function () {
|
||||||
|
@ -65,17 +62,11 @@ Deluge.EditTrackerWindow = Ext.extend(Ext.Window, {
|
||||||
},
|
},
|
||||||
|
|
||||||
onHide: function () {
|
onHide: function () {
|
||||||
this.form
|
this.form.getForm().findField('tracker').setValue('');
|
||||||
.getForm()
|
|
||||||
.findField('tracker')
|
|
||||||
.setValue('');
|
|
||||||
},
|
},
|
||||||
|
|
||||||
onSaveClick: function () {
|
onSaveClick: function () {
|
||||||
var url = this.form
|
var url = this.form.getForm().findField('tracker').getValue();
|
||||||
.getForm()
|
|
||||||
.findField('tracker')
|
|
||||||
.getValue();
|
|
||||||
this.record.set('url', url);
|
this.record.set('url', url);
|
||||||
this.record.commit();
|
this.record.commit();
|
||||||
this.hide();
|
this.hide();
|
||||||
|
|
|
@ -194,18 +194,12 @@ Deluge.EditTrackersWindow = Ext.extend(Ext.Window, {
|
||||||
|
|
||||||
onSelect: function (list) {
|
onSelect: function (list) {
|
||||||
if (list.getSelectionCount()) {
|
if (list.getSelectionCount()) {
|
||||||
this.panel
|
this.panel.getBottomToolbar().items.get(4).enable();
|
||||||
.getBottomToolbar()
|
|
||||||
.items.get(4)
|
|
||||||
.enable();
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onShow: function () {
|
onShow: function () {
|
||||||
this.panel
|
this.panel.getBottomToolbar().items.get(4).disable();
|
||||||
.getBottomToolbar()
|
|
||||||
.items.get(4)
|
|
||||||
.disable();
|
|
||||||
var r = deluge.torrents.getSelected();
|
var r = deluge.torrents.getSelected();
|
||||||
this.torrentId = r.id;
|
this.torrentId = r.id;
|
||||||
deluge.client.core.get_torrent_status(r.id, ['trackers'], {
|
deluge.client.core.get_torrent_status(r.id, ['trackers'], {
|
||||||
|
|
|
@ -74,9 +74,6 @@ Deluge.OtherLimitWindow = Ext.extend(Ext.Window, {
|
||||||
},
|
},
|
||||||
|
|
||||||
doFocusField: function () {
|
doFocusField: function () {
|
||||||
this.form
|
this.form.getForm().findField('limit').focus(true, 10);
|
||||||
.getForm()
|
|
||||||
.findField('limit')
|
|
||||||
.focus(true, 10);
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -50,10 +50,7 @@ Ext.ux.form.ToggleField = Ext.extend(Ext.form.Field, {
|
||||||
this.panel.add(this.input);
|
this.panel.add(this.input);
|
||||||
this.panel.doLayout();
|
this.panel.doLayout();
|
||||||
|
|
||||||
this.toggle
|
this.toggle.getEl().parent().setStyle('padding-right', '10px');
|
||||||
.getEl()
|
|
||||||
.parent()
|
|
||||||
.setStyle('padding-right', '10px');
|
|
||||||
}
|
}
|
||||||
Ext.ux.form.ToggleField.superclass.onRender.call(this, ct, position);
|
Ext.ux.form.ToggleField.superclass.onRender.call(this, ct, position);
|
||||||
},
|
},
|
||||||
|
|
|
@ -6,3 +6,8 @@ requires = [
|
||||||
|
|
||||||
[tool.black]
|
[tool.black]
|
||||||
skip-string-normalization = true
|
skip-string-normalization = true
|
||||||
|
|
||||||
|
[tool.isort]
|
||||||
|
profile = "black"
|
||||||
|
# Python 2 stdlib
|
||||||
|
extra_standard_library = ["urlparse", "HTMLParser", "urllib2"]
|
||||||
|
|
|
@ -3,7 +3,7 @@ pytest-twisted
|
||||||
pytest-cov
|
pytest-cov
|
||||||
mock
|
mock
|
||||||
pre-commit
|
pre-commit
|
||||||
flake8
|
flake8<=3.7.9
|
||||||
flake8-quotes
|
flake8-quotes
|
||||||
flake8-isort
|
flake8-isort
|
||||||
pep8-naming
|
pep8-naming
|
||||||
|
|
18
setup.cfg
18
setup.cfg
|
@ -24,24 +24,6 @@ includes = glib, gio, cairo, pango, pangocairo, atk, gobject, gtk.keysyms,
|
||||||
HTMLParser
|
HTMLParser
|
||||||
frameworks = CoreFoundation, Foundation, AppKit
|
frameworks = CoreFoundation, Foundation, AppKit
|
||||||
|
|
||||||
[isort]
|
|
||||||
known_standard_library = future_builtins
|
|
||||||
known_third_party =
|
|
||||||
# Ignore gtk modules, primarily for tox testing.
|
|
||||||
cairo, gi,
|
|
||||||
# Ignore other module dependencies for pre-commit isort.
|
|
||||||
twisted, OpenSSL, pytest, recommonmark, chardet, pkg_resources, zope, mock,
|
|
||||||
sphinx, rencode, six, mako
|
|
||||||
known_first_party = msgfmt, deluge
|
|
||||||
order_by_type = true
|
|
||||||
not_skip = __init__.py
|
|
||||||
# Black compatible settings
|
|
||||||
multi_line_output=3
|
|
||||||
include_trailing_comma=True
|
|
||||||
force_grid_wrap=0
|
|
||||||
line_length=88
|
|
||||||
use_parentheses=True
|
|
||||||
|
|
||||||
[flake8]
|
[flake8]
|
||||||
max-line-length = 120
|
max-line-length = 120
|
||||||
builtins = _,_n,__request__
|
builtins = _,_n,__request__
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue