diff --git a/deluge/configmanager.py b/deluge/configmanager.py index 1fef1c873..ad5f58112 100644 --- a/deluge/configmanager.py +++ b/deluge/configmanager.py @@ -99,7 +99,7 @@ class _ConfigManager(object): _configmanager = _ConfigManager() -def ConfigManager(config, defaults=None, file_version=1): # NOQA +def ConfigManager(config, defaults=None, file_version=1): # NOQA: N802 return _configmanager.get_config(config, defaults=defaults, file_version=file_version) diff --git a/deluge/core/rpcserver.py b/deluge/core/rpcserver.py index 81b12054b..a204722ca 100644 --- a/deluge/core/rpcserver.py +++ b/deluge/core/rpcserver.py @@ -90,7 +90,7 @@ def format_request(call): class ServerContextFactory(object): - def getContext(self): # NOQA + def getContext(self): # NOQA: N802 """ Create an SSL context. @@ -133,7 +133,7 @@ class DelugeRPCProtocol(DelugeTransferProtocol): # log.debug("RPCRequest: %s", format_request(call)) reactor.callLater(0, self.dispatch, *call) - def sendData(self, data): # NOQA + def sendData(self, data): # NOQA: N802 """ Sends the data to the client. @@ -149,7 +149,7 @@ class DelugeRPCProtocol(DelugeTransferProtocol): log.exception(ex) raise - def connectionMade(self): # NOQA + def connectionMade(self): # NOQA: N802 """ This method is called when a new client connects. """ @@ -159,7 +159,7 @@ class DelugeRPCProtocol(DelugeTransferProtocol): # Set the initial auth level of this session to AUTH_LEVEL_NONE self.factory.authorized_sessions[self.transport.sessionno] = AUTH_LEVEL_NONE - def connectionLost(self, reason=connectionDone): # NOQA + def connectionLost(self, reason=connectionDone): # NOQA: N802 """ This method is called when the client is disconnected. diff --git a/deluge/httpdownloader.py b/deluge/httpdownloader.py index 5492100b9..fd272e29e 100644 --- a/deluge/httpdownloader.py +++ b/deluge/httpdownloader.py @@ -52,11 +52,11 @@ class HTTPDownloader(client.HTTPDownloader): agent = 'Deluge/%s (http://deluge-torrent.org)' % get_version() client.HTTPDownloader.__init__(self, url, filename, headers=headers, agent=agent) - def gotStatus(self, version, status, message): # NOQA + def gotStatus(self, version, status, message): # NOQA: N802 self.code = int(status) client.HTTPDownloader.gotStatus(self, version, status, message) - def gotHeaders(self, headers): # NOQA + def gotHeaders(self, headers): # NOQA: N802 if self.code == http.OK: if 'content-length' in headers: self.total_length = int(headers['content-length'][0]) @@ -92,7 +92,7 @@ class HTTPDownloader(client.HTTPDownloader): return client.HTTPDownloader.gotHeaders(self, headers) - def pagePart(self, data): # NOQA + def pagePart(self, data): # NOQA: N802 if self.code == http.OK: self.current_length += len(data) if self.decoder: @@ -102,7 +102,7 @@ class HTTPDownloader(client.HTTPDownloader): return client.HTTPDownloader.pagePart(self, data) - def pageEnd(self): # NOQA + def pageEnd(self): # NOQA: N802 if self.decoder: data = self.decoder.flush() self.current_length -= len(data) @@ -202,7 +202,7 @@ def _download_file(url, filename, callback=None, headers=None, force_filename=Fa """ A custom context factory to add a server name for TLS connections. """ - def getContext(self): # NOQA + def getContext(self): # NOQA: N802 ctx = ssl.ClientContextFactory.getContext(self) ClientTLSOptions(host, ctx) return ctx diff --git a/deluge/log.py b/deluge/log.py index 5f088f88a..aa532a0f6 100644 --- a/deluge/log.py +++ b/deluge/log.py @@ -81,7 +81,7 @@ class Logging(LoggingLoggerClass): def exception(self, msg, *args, **kwargs): yield LoggingLoggerClass.exception(self, msg, *args, **kwargs) - def findCaller(self): # NOQA + def findCaller(self): # NOQA: N802 f = logging.currentframe().f_back rv = '(unknown file)', 0, '(unknown function)' while hasattr(f, 'f_code'): diff --git a/deluge/plugins/Blocklist/deluge/plugins/blocklist/decompressers.py b/deluge/plugins/Blocklist/deluge/plugins/blocklist/decompressers.py index 2e4fe73ad..a9f48ba50 100644 --- a/deluge/plugins/Blocklist/deluge/plugins/blocklist/decompressers.py +++ b/deluge/plugins/Blocklist/deluge/plugins/blocklist/decompressers.py @@ -13,7 +13,7 @@ import gzip import zipfile -def Zipped(reader): # NOQA +def Zipped(reader): # NOQA: N802 """Blocklist reader for zipped blocklists""" def open(self): z = zipfile.ZipFile(self.file) @@ -28,7 +28,7 @@ def Zipped(reader): # NOQA return reader -def GZipped(reader): # NOQA +def GZipped(reader): # NOQA: N802 """Blocklist reader for gzipped blocklists""" def open(self): return gzip.open(self.file) @@ -36,7 +36,7 @@ def GZipped(reader): # NOQA return reader -def BZipped2(reader): # NOQA +def BZipped2(reader): # NOQA: N802 """Blocklist reader for bzipped2 blocklists""" def open(self): return bz2.BZ2File(self.file) diff --git a/deluge/plugins/WebUi/deluge/plugins/webui/core.py b/deluge/plugins/WebUi/deluge/plugins/webui/core.py index 0435d249d..598058d27 100644 --- a/deluge/plugins/WebUi/deluge/plugins/webui/core.py +++ b/deluge/plugins/WebUi/deluge/plugins/webui/core.py @@ -21,6 +21,11 @@ from deluge import configmanager from deluge.core.rpcserver import export from deluge.plugins.pluginbase import CorePluginBase +try: + from deluge.ui.web import server +except ImportError: + server = False + log = logging.getLogger(__name__) DEFAULT_PREFS = { @@ -49,17 +54,20 @@ class Core(CorePluginBase): @export def got_deluge_web(self): - try: - from deluge.ui.web import server # noqa pylint: disable=unused-import - return True - except ImportError: - return False + """Status of deluge-web module installation. + + Check if deluge.ui.web.server modulge is installed and has been successfully imported. + + Returns: + bool: True is deluge-web is installed and available, otherwise False. + + """ + + return bool(server) def start_server(self): if not self.server: - try: - from deluge.ui.web import server - except ImportError: + if not self.got_deluge_web(): return False try: diff --git a/deluge/tests/basetest.py b/deluge/tests/basetest.py index 11da5ef5a..0ccf4513e 100644 --- a/deluge/tests/basetest.py +++ b/deluge/tests/basetest.py @@ -13,7 +13,7 @@ class BaseTestCase(unittest.TestCase): have finished. """ - def setUp(self): # NOQA + def setUp(self): # NOQA: N803 if len(component._ComponentRegistry.components) != 0: warnings.warn('The component._ComponentRegistry.components is not empty on test setup.\n' @@ -27,7 +27,7 @@ class BaseTestCase(unittest.TestCase): return d.addErrback(on_setup_error) - def tearDown(self): # NOQA + def tearDown(self): # NOQA: N803 d = maybeDeferred(self.tear_down) def on_teardown_failed(error): diff --git a/deluge/tests/common.py b/deluge/tests/common.py index 30e71fe1f..c800a39f8 100644 --- a/deluge/tests/common.py +++ b/deluge/tests/common.py @@ -97,7 +97,7 @@ class ReactorOverride(object): def _stop(self): pass - def addReader(self, arg): # NOQA + def addReader(self, arg): # NOQA: N802 pass @@ -123,11 +123,11 @@ class ProcessOutputHandler(protocol.ProcessProtocol): self.killed = False self.watchdogs = [] - def connectionMade(self): # NOQA + def connectionMade(self): # NOQA: N802 self.transport.write(self.script) self.transport.closeStdin() - def outConnectionLost(self): # NOQA + def outConnectionLost(self): # NOQA: N802 if not self.logfile: return with open(self.logfile, 'w') as f: @@ -154,7 +154,7 @@ class ProcessOutputHandler(protocol.ProcessProtocol): if not w.called and not w.cancelled: w.cancel() - def processEnded(self, status): # NOQA + def processEnded(self, status): # NOQA: N802 self.transport.loseConnection() if self.quit_d is None: return @@ -183,7 +183,7 @@ class ProcessOutputHandler(protocol.ProcessProtocol): c['deferred'].callback(val) return ret - def outReceived(self, data): # NOQA + def outReceived(self, data): # NOQA: N802 """Process output from stdout""" self.log_output += data if self.check_callbacks(data): @@ -191,7 +191,7 @@ class ProcessOutputHandler(protocol.ProcessProtocol): elif '[ERROR' in data: print(data, end=' ') - def errReceived(self, data): # NOQA + def errReceived(self, data): # NOQA: N802 """Process output from stderr""" self.log_output += data self.stderr_out += data diff --git a/deluge/tests/test_config.py b/deluge/tests/test_config.py index c38c1c0bf..b3f34de0a 100644 --- a/deluge/tests/test_config.py +++ b/deluge/tests/test_config.py @@ -14,7 +14,7 @@ DEFAULTS = {'string': 'foobar', 'int': 1, 'float': 0.435, 'bool': True, 'unicode class ConfigTestCase(unittest.TestCase): - def setUp(self): # NOQA + def setUp(self): # NOQA: N803 self.config_dir = set_tmp_config_dir() def test_init(self): diff --git a/deluge/tests/test_error.py b/deluge/tests/test_error.py index 9bac1c689..6917101ae 100644 --- a/deluge/tests/test_error.py +++ b/deluge/tests/test_error.py @@ -4,10 +4,10 @@ import deluge.error class ErrorTestCase(unittest.TestCase): - def setUp(self): # NOQA + def setUp(self): # NOQA: N803 pass - def tearDown(self): # NOQA + def tearDown(self): # NOQA: N803 pass def test_deluge_error(self): diff --git a/deluge/tests/test_httpdownloader.py b/deluge/tests/test_httpdownloader.py index a8acd9f47..058cafbee 100644 --- a/deluge/tests/test_httpdownloader.py +++ b/deluge/tests/test_httpdownloader.py @@ -92,7 +92,7 @@ class TopLevelResource(Resource): self.putChild('rename', RenameResource()) self.putChild('partial', PartialDownloadResource()) - def getChild(self, path, request): # NOQA + def getChild(self, path, request): # NOQA: N803 if path == '': return self else: diff --git a/deluge/tests/test_transfer.py b/deluge/tests/test_transfer.py index 0dca6f86c..f39c6240d 100644 --- a/deluge/tests/test_transfer.py +++ b/deluge/tests/test_transfer.py @@ -106,7 +106,7 @@ class TransferTestClass(DelugeTransferProtocol): class DelugeTransferProtocolTestCase(unittest.TestCase): - def setUp(self): # NOQA + def setUp(self): # NOQA: N803 """ The expected messages corresponds to the test messages (msg1, msg2) after they've been processed by DelugeTransferProtocol.send, which means that they've first been encoded with pickle, diff --git a/deluge/tests/test_ui_common.py b/deluge/tests/test_ui_common.py index eff972527..0af5dfc9c 100644 --- a/deluge/tests/test_ui_common.py +++ b/deluge/tests/test_ui_common.py @@ -15,10 +15,10 @@ from . import common class UICommonTestCase(unittest.TestCase): - def setUp(self): # NOQA + def setUp(self): # NOQA: N803 pass - def tearDown(self): # NOQA + def tearDown(self): # NOQA: N803 pass def test_utf8_encoded_paths(self): diff --git a/deluge/tests/test_ui_console_fields.py b/deluge/tests/test_ui_console_fields.py index 53520060f..99a3a0605 100644 --- a/deluge/tests/test_ui_console_fields.py +++ b/deluge/tests/test_ui_console_fields.py @@ -14,10 +14,10 @@ class Parent(object): class UICommonTestCase(unittest.TestCase): - def setUp(self): # NOQA + def setUp(self): # NOQA: N803 self.parent = Parent() - def tearDown(self): # NOQA + def tearDown(self): # NOQA: N803 pass def test_text_input(self): diff --git a/deluge/tests/twisted/plugins/delugereporter.py b/deluge/tests/twisted/plugins/delugereporter.py index ae1959215..fcb4e2911 100644 --- a/deluge/tests/twisted/plugins/delugereporter.py +++ b/deluge/tests/twisted/plugins/delugereporter.py @@ -10,7 +10,7 @@ from zope.interface import implements class _Reporter(object): implements(IPlugin, IReporter) - def __init__(self, name, module, description, longOpt, shortOpt, klass): # NOQA + def __init__(self, name, module, description, longOpt, shortOpt, klass): # NOQA: N803 self.name = name self.module = module self.description = description @@ -32,6 +32,6 @@ class DelugeReporter(TreeReporter): os.environ['DELUGE_REPORTER'] = 'true' TreeReporter.__init__(self, *args, **kwargs) - def addExpectedFailure(self, *args): # NOQA + def addExpectedFailure(self, *args): # NOQA: N802 # super(TreeReporter, self).addExpectedFailure(*args) self.endLine('[TODO]', self.TODO) diff --git a/deluge/transfer.py b/deluge/transfer.py index 67cae7e54..711745489 100644 --- a/deluge/transfer.py +++ b/deluge/transfer.py @@ -56,7 +56,7 @@ class DelugeTransferProtocol(Protocol, object): self.transport.write(header) self.transport.write(compressed) - def dataReceived(self, data): # NOQA + def dataReceived(self, data): # NOQA: N802 """ This method is called whenever data is received. diff --git a/deluge/ui/client.py b/deluge/ui/client.py index 1bcfbdd4a..3f72dbcdf 100644 --- a/deluge/ui/client.py +++ b/deluge/ui/client.py @@ -73,7 +73,7 @@ class DelugeRPCRequest(object): class DelugeRPCProtocol(DelugeTransferProtocol): - def connectionMade(self): # NOQA + def connectionMade(self): # NOQA: N802 self.__rpc_requests = {} # Set the protocol in the daemon so it can send data self.factory.daemon.protocol = self @@ -192,16 +192,16 @@ class DelugeRPCClientFactory(ClientFactory): self.daemon = daemon self.event_handlers = event_handlers - def startedConnecting(self, connector): # NOQA + def startedConnecting(self, connector): # NOQA: N802 log.debug('Connecting to daemon at "%s:%s"...', connector.host, connector.port) - def clientConnectionFailed(self, connector, reason): # NOQA + def clientConnectionFailed(self, connector, reason): # NOQA: N802 log.debug('Connection to daemon at "%s:%s" failed: %s', connector.host, connector.port, reason.value) self.daemon.connect_deferred.errback(reason) - def clientConnectionLost(self, connector, reason): # NOQA + def clientConnectionLost(self, connector, reason): # NOQA: N802 log.debug('Connection lost to daemon at "%s:%s" reason: %s', connector.host, connector.port, reason.value) self.daemon.host = None diff --git a/deluge/ui/console/cmdline/commands/__init__.py b/deluge/ui/console/cmdline/commands/__init__.py index 9c003700e..39dbefe2a 100644 --- a/deluge/ui/console/cmdline/commands/__init__.py +++ b/deluge/ui/console/cmdline/commands/__init__.py @@ -1 +1,3 @@ -from deluge.ui.console.cmdline.command import BaseCommand # NOQA +from deluge.ui.console.cmdline.command import BaseCommand + +__all__ = ['BaseCommand'] diff --git a/deluge/ui/console/modes/basemode.py b/deluge/ui/console/modes/basemode.py index dffb980a2..fe189a5ce 100644 --- a/deluge/ui/console/modes/basemode.py +++ b/deluge/ui/console/modes/basemode.py @@ -86,11 +86,11 @@ class CursesStdIO(object): """ We want to select on FD 0 """ return 0 - def doRead(self): # NOQA + def doRead(self): # NOQA: N802 """called when input is ready""" pass - def logPrefix(self): # NOQA + def logPrefix(self): # NOQA: N802 return 'CursesClient' @@ -143,7 +143,7 @@ class BaseMode(CursesStdIO, component.Component): def on_resize(self, rows, cols): self.rows, self.cols = rows, cols - def connectionLost(self, reason): # NOQA + def connectionLost(self, reason): # NOQA: N802 self.close() def add_string(self, row, string, scr=None, **kwargs): @@ -194,7 +194,7 @@ class BaseMode(CursesStdIO, component.Component): self.stdscr.redrawwin() self.stdscr.refresh() - def doRead(self): # NOQA + def doRead(self): # NOQA: N802 """ Called when there is data to be read, ie, input from the keyboard. """ diff --git a/deluge/ui/console/modes/preferences/__init__.py b/deluge/ui/console/modes/preferences/__init__.py index 7963d0366..e827d91a3 100644 --- a/deluge/ui/console/modes/preferences/__init__.py +++ b/deluge/ui/console/modes/preferences/__init__.py @@ -1 +1,3 @@ -from deluge.ui.console.modes.preferences.preferences import Preferences # NOQA +from deluge.ui.console.modes.preferences.preferences import Preferences + +__all__ = ['Preferences'] diff --git a/deluge/ui/console/widgets/__init__.py b/deluge/ui/console/widgets/__init__.py index 6aac1c410..bc88a3b6b 100644 --- a/deluge/ui/console/widgets/__init__.py +++ b/deluge/ui/console/widgets/__init__.py @@ -1,3 +1,5 @@ -from deluge.ui.console.widgets.inputpane import BaseInputPane # NOQA -from deluge.ui.console.widgets.statusbars import StatusBars # NOQA -from deluge.ui.console.widgets.window import BaseWindow # NOQA +from deluge.ui.console.widgets.inputpane import BaseInputPane +from deluge.ui.console.widgets.statusbars import StatusBars +from deluge.ui.console.widgets.window import BaseWindow + +__all__ = ['BaseInputPane', 'StatusBars', 'BaseWindow'] diff --git a/deluge/ui/gtkui/ipcinterface.py b/deluge/ui/gtkui/ipcinterface.py index ba83c5682..eaf666e84 100644 --- a/deluge/ui/gtkui/ipcinterface.py +++ b/deluge/ui/gtkui/ipcinterface.py @@ -38,7 +38,7 @@ class IPCProtocolServer(Protocol): def __init__(self): pass - def dataReceived(self, data): # NOQA + def dataReceived(self, data): # NOQA: N802 config = ConfigManager('gtkui.conf') data = rencode.loads(data, decode_utf8=True) if not data or config['focus_main_window_on_add']: @@ -51,11 +51,11 @@ class IPCProtocolClient(Protocol): def __init__(self): pass - def connectionMade(self): # NOQA + def connectionMade(self): # NOQA: N802 self.transport.write(rencode.dumps(self.factory.args)) self.transport.loseConnection() - def connectionLost(self, reason=connectionDone): # NOQA + def connectionLost(self, reason=connectionDone): # NOQA: N802 reactor.stop() self.factory.stop = True @@ -66,7 +66,7 @@ class IPCClientFactory(ClientFactory): def __init__(self): self.stop = False - def clientConnectionFailed(self, connector, reason): # NOQA + def clientConnectionFailed(self, connector, reason): # NOQA: N802 log.warning('Connection to running instance failed.') reactor.stop() diff --git a/deluge/ui/gtkui/preferences.py b/deluge/ui/gtkui/preferences.py index 6b6891637..2969c7149 100644 --- a/deluge/ui/gtkui/preferences.py +++ b/deluge/ui/gtkui/preferences.py @@ -25,6 +25,11 @@ from deluge.ui.gtkui.dialogs import AccountDialog, ErrorDialog, InformationDialo from deluge.ui.gtkui.path_chooser import PathChooser from deluge.ui.util import lang +try: + import appindicator +except ImportError: + appindicator = False + pygtk.require('2.0') @@ -148,13 +153,8 @@ class Preferences(component.Component): 'on_checkbutton_language_toggled': self._on_checkbutton_language_toggled, }) - if not deluge.common.osx_check() and not deluge.common.windows_check(): - try: - import appindicator # noqa pylint: disable=unused-import - except ImportError: - pass - else: - self.builder.get_object('alignment_tray_type').set_visible(True) + # Radio buttons to choose between systray and appindicator + self.builder.get_object('alignment_tray_type').set_visible(appindicator) from deluge.ui.gtkui.gtkui import DEFAULT_PREFS self.COLOR_DEFAULTS = {} diff --git a/deluge/ui/tracker_icons.py b/deluge/ui/tracker_icons.py index aff27f25c..a890113c2 100644 --- a/deluge/ui/tracker_icons.py +++ b/deluge/ui/tracker_icons.py @@ -27,7 +27,7 @@ try: except ImportError: PIL_INSTALLED = False else: - import deluge.ui.Win32IconImagePlugin # noqa pylint: disable=unused-import, ungrouped-imports + import deluge.ui.Win32IconImagePlugin # NOQA pylint: disable=unused-import, ungrouped-imports PIL_INSTALLED = True log = logging.getLogger(__name__) diff --git a/deluge/ui/web/server.py b/deluge/ui/web/server.py index 26a20e268..78c913b6e 100644 --- a/deluge/ui/web/server.py +++ b/deluge/ui/web/server.py @@ -124,7 +124,7 @@ class Upload(resource.Resource): class Render(resource.Resource): - def getChild(self, path, request): # NOQA + def getChild(self, path, request): # NOQA: N802 request.render_file = path return self @@ -149,7 +149,7 @@ class Tracker(resource.Resource): except KeyError: self.tracker_icons = TrackerIcons() - def getChild(self, path, request): # NOQA + def getChild(self, path, request): # NOQA: N802 request.tracker_name = path return self @@ -172,7 +172,7 @@ class Tracker(resource.Resource): class Flag(resource.Resource): - def getChild(self, path, request): # NOQA + def getChild(self, path, request): # NOQA: N802 request.country = path return self @@ -211,7 +211,7 @@ class LookupResource(resource.Resource, component.Component): log.debug('Removing directory `%s`', directory) self.__paths[path].remove(directory) - def getChild(self, path, request): # NOQA + def getChild(self, path, request): # NOQA: N802 if hasattr(request, 'lookup_path'): request.lookup_path = os.path.join(request.lookup_path, path) else: @@ -365,7 +365,7 @@ class ScriptResource(resource.Resource, component.Component): scripts.append('js/' + path) return scripts - def getChild(self, path, request): # NOQA + def getChild(self, path, request): # NOQA: N802 if hasattr(request, 'lookup_path'): request.lookup_path += '/' + path else: @@ -477,13 +477,13 @@ class TopLevel(resource.Resource): self.__scripts.remove(script) self.__debug_scripts.remove(script) - def getChild(self, path, request): # NOQA + def getChild(self, path, request): # NOQA: N802 if path == '': return self else: return resource.Resource.getChild(self, path, request) - def getChildWithDefault(self, path, request): # NOQA + def getChildWithDefault(self, path, request): # NOQA: N802 # Calculate the request base header = request.getHeader('x-deluge-base') base = header if header else component.get('DelugeWeb').base