Flake8'd core files
This commit is contained in:
parent
ef7605f9ec
commit
c3477ace9b
@ -50,6 +50,7 @@ from deluge.common import decode_string
|
|||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class AlertManager(component.Component):
|
class AlertManager(component.Component):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
log.debug("AlertManager initialized..")
|
log.debug("AlertManager initialized..")
|
||||||
|
|||||||
@ -35,8 +35,6 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import random
|
|
||||||
import stat
|
|
||||||
import shutil
|
import shutil
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
@ -62,8 +60,10 @@ AUTH_LEVELS_MAPPING_REVERSE = {}
|
|||||||
for key, value in AUTH_LEVELS_MAPPING.iteritems():
|
for key, value in AUTH_LEVELS_MAPPING.iteritems():
|
||||||
AUTH_LEVELS_MAPPING_REVERSE[value] = key
|
AUTH_LEVELS_MAPPING_REVERSE[value] = key
|
||||||
|
|
||||||
|
|
||||||
class Account(object):
|
class Account(object):
|
||||||
__slots__ = ('username', 'password', 'authlevel')
|
__slots__ = ('username', 'password', 'authlevel')
|
||||||
|
|
||||||
def __init__(self, username, password, authlevel):
|
def __init__(self, username, password, authlevel):
|
||||||
self.username = username
|
self.username = username
|
||||||
self.password = password
|
self.password = password
|
||||||
@ -297,9 +297,7 @@ class AuthManager(component.Component):
|
|||||||
create_localclient_account(True)
|
create_localclient_account(True)
|
||||||
return self.__load_auth_file()
|
return self.__load_auth_file()
|
||||||
|
|
||||||
|
|
||||||
if save_and_reload:
|
if save_and_reload:
|
||||||
log.info("Re-writing auth file (upgrade)")
|
log.info("Re-writing auth file (upgrade)")
|
||||||
self.write_auth_file()
|
self.write_auth_file()
|
||||||
self.__auth_modification_time = auth_file_modification_time
|
self.__auth_modification_time = auth_file_modification_time
|
||||||
|
|
||||||
|
|||||||
@ -54,8 +54,8 @@ from deluge import path_chooser_common
|
|||||||
from deluge.configmanager import ConfigManager, get_config_dir
|
from deluge.configmanager import ConfigManager, get_config_dir
|
||||||
import deluge.common
|
import deluge.common
|
||||||
import deluge.component as component
|
import deluge.component as component
|
||||||
from deluge.event import *
|
from deluge.event import NewVersionAvailableEvent, SessionResumedEvent, TorrentQueueChangedEvent
|
||||||
from deluge.error import *
|
from deluge.error import DelugeError, InvalidTorrentError, InvalidPathError
|
||||||
from deluge.core.authmanager import AUTH_LEVEL_ADMIN, AUTH_LEVEL_NONE
|
from deluge.core.authmanager import AUTH_LEVEL_ADMIN, AUTH_LEVEL_NONE
|
||||||
from deluge.core.authmanager import AUTH_LEVELS_MAPPING, AUTH_LEVELS_MAPPING_REVERSE
|
from deluge.core.authmanager import AUTH_LEVELS_MAPPING, AUTH_LEVELS_MAPPING_REVERSE
|
||||||
from deluge.core.torrentmanager import TorrentManager
|
from deluge.core.torrentmanager import TorrentManager
|
||||||
|
|||||||
@ -38,6 +38,7 @@ import deluge.component as component
|
|||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class EventManager(component.Component):
|
class EventManager(component.Component):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
component.Component.__init__(self, "EventManager")
|
component.Component.__init__(self, "EventManager")
|
||||||
|
|||||||
@ -41,17 +41,18 @@ STATE_SORT = ["All", "Downloading", "Seeding", "Active", "Paused", "Queued"]
|
|||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
# Special purpose filters:
|
# Special purpose filters:
|
||||||
def filter_keywords(torrent_ids, values):
|
def filter_keywords(torrent_ids, values):
|
||||||
# Cleanup
|
# Cleanup
|
||||||
keywords = ",".join([v.lower() for v in values])
|
keywords = ",".join([v.lower() for v in values])
|
||||||
keywords = keywords.split(",")
|
keywords = keywords.split(",")
|
||||||
|
|
||||||
|
|
||||||
for keyword in keywords:
|
for keyword in keywords:
|
||||||
torrent_ids = filter_one_keyword(torrent_ids, keyword)
|
torrent_ids = filter_one_keyword(torrent_ids, keyword)
|
||||||
return torrent_ids
|
return torrent_ids
|
||||||
|
|
||||||
|
|
||||||
def filter_one_keyword(torrent_ids, keyword):
|
def filter_one_keyword(torrent_ids, keyword):
|
||||||
"""
|
"""
|
||||||
search torrent on keyword.
|
search torrent on keyword.
|
||||||
@ -59,7 +60,6 @@ def filter_one_keyword(torrent_ids, keyword):
|
|||||||
"""
|
"""
|
||||||
all_torrents = component.get("TorrentManager").torrents
|
all_torrents = component.get("TorrentManager").torrents
|
||||||
|
|
||||||
found = False
|
|
||||||
for torrent_id in torrent_ids:
|
for torrent_id in torrent_ids:
|
||||||
torrent = all_torrents[torrent_id]
|
torrent = all_torrents[torrent_id]
|
||||||
if keyword in torrent.filename.lower():
|
if keyword in torrent.filename.lower():
|
||||||
@ -79,6 +79,7 @@ def filter_one_keyword(torrent_ids, keyword):
|
|||||||
yield torrent_id
|
yield torrent_id
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
||||||
def filter_by_name(torrent_ids, search_string):
|
def filter_by_name(torrent_ids, search_string):
|
||||||
all_torrents = component.get("TorrentManager").torrents
|
all_torrents = component.get("TorrentManager").torrents
|
||||||
try:
|
try:
|
||||||
@ -100,6 +101,7 @@ def filter_by_name(torrent_ids, search_string):
|
|||||||
if search_string in torrent_name:
|
if search_string in torrent_name:
|
||||||
yield torrent_id
|
yield torrent_id
|
||||||
|
|
||||||
|
|
||||||
def tracker_error_filter(torrent_ids, values):
|
def tracker_error_filter(torrent_ids, values):
|
||||||
filtered_torrent_ids = []
|
filtered_torrent_ids = []
|
||||||
tm = component.get("TorrentManager")
|
tm = component.get("TorrentManager")
|
||||||
@ -117,6 +119,7 @@ def tracker_error_filter(torrent_ids, values):
|
|||||||
filtered_torrent_ids.append(torrent_id)
|
filtered_torrent_ids.append(torrent_id)
|
||||||
return filtered_torrent_ids
|
return filtered_torrent_ids
|
||||||
|
|
||||||
|
|
||||||
class FilterManager(component.Component):
|
class FilterManager(component.Component):
|
||||||
"""FilterManager
|
"""FilterManager
|
||||||
|
|
||||||
@ -134,6 +137,7 @@ class FilterManager(component.Component):
|
|||||||
self.filter_tree_items = None
|
self.filter_tree_items = None
|
||||||
|
|
||||||
self.register_tree_field("state", self._init_state_tree)
|
self.register_tree_field("state", self._init_state_tree)
|
||||||
|
|
||||||
def _init_tracker_tree():
|
def _init_tracker_tree():
|
||||||
return {"Error": 0}
|
return {"Error": 0}
|
||||||
self.register_tree_field("tracker_host", _init_tracker_tree)
|
self.register_tree_field("tracker_host", _init_tracker_tree)
|
||||||
|
|||||||
@ -44,8 +44,8 @@ import deluge.component as component
|
|||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
class PluginManager(deluge.pluginmanagerbase.PluginManagerBase,
|
|
||||||
component.Component):
|
class PluginManager(deluge.pluginmanagerbase.PluginManagerBase, component.Component):
|
||||||
"""PluginManager handles the loading of plugins and provides plugins with
|
"""PluginManager handles the loading of plugins and provides plugins with
|
||||||
functions to access parts of the core."""
|
functions to access parts of the core."""
|
||||||
|
|
||||||
|
|||||||
@ -41,7 +41,7 @@ from twisted.internet.task import LoopingCall
|
|||||||
|
|
||||||
from deluge._libtorrent import lt
|
from deluge._libtorrent import lt
|
||||||
|
|
||||||
from deluge.event import *
|
from deluge.event import ConfigValueChangedEvent
|
||||||
import deluge.configmanager
|
import deluge.configmanager
|
||||||
import deluge.common
|
import deluge.common
|
||||||
import deluge.component as component
|
import deluge.component as component
|
||||||
|
|||||||
@ -36,23 +36,17 @@
|
|||||||
"""RPCServer Module"""
|
"""RPCServer Module"""
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import zlib
|
|
||||||
import os
|
import os
|
||||||
import stat
|
import stat
|
||||||
import logging
|
import logging
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
from twisted.internet.protocol import Factory, Protocol
|
from twisted.internet.protocol import Factory
|
||||||
from twisted.internet import reactor, defer
|
from twisted.internet import reactor, defer
|
||||||
|
|
||||||
from OpenSSL import crypto, SSL
|
from OpenSSL import crypto, SSL
|
||||||
from types import FunctionType
|
from types import FunctionType
|
||||||
|
|
||||||
try:
|
|
||||||
import rencode
|
|
||||||
except ImportError:
|
|
||||||
import deluge.rencode as rencode
|
|
||||||
|
|
||||||
import deluge.component as component
|
import deluge.component as component
|
||||||
import deluge.configmanager
|
import deluge.configmanager
|
||||||
from deluge.core.authmanager import (AUTH_LEVEL_NONE, AUTH_LEVEL_DEFAULT,
|
from deluge.core.authmanager import (AUTH_LEVEL_NONE, AUTH_LEVEL_DEFAULT,
|
||||||
@ -68,6 +62,7 @@ RPC_EVENT = 3
|
|||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def export(auth_level=AUTH_LEVEL_DEFAULT):
|
def export(auth_level=AUTH_LEVEL_DEFAULT):
|
||||||
"""
|
"""
|
||||||
Decorator function to register an object's method as an RPC. The object
|
Decorator function to register an object's method as an RPC. The object
|
||||||
@ -122,6 +117,7 @@ def format_request(call):
|
|||||||
else:
|
else:
|
||||||
return s
|
return s
|
||||||
|
|
||||||
|
|
||||||
class ServerContextFactory(object):
|
class ServerContextFactory(object):
|
||||||
def getContext(self):
|
def getContext(self):
|
||||||
"""
|
"""
|
||||||
@ -136,6 +132,7 @@ class ServerContextFactory(object):
|
|||||||
ctx.use_privatekey_file(os.path.join(ssl_dir, "daemon.pkey"))
|
ctx.use_privatekey_file(os.path.join(ssl_dir, "daemon.pkey"))
|
||||||
return ctx
|
return ctx
|
||||||
|
|
||||||
|
|
||||||
class DelugeRPCProtocol(DelugeTransferProtocol):
|
class DelugeRPCProtocol(DelugeTransferProtocol):
|
||||||
|
|
||||||
def message_received(self, request):
|
def message_received(self, request):
|
||||||
@ -323,7 +320,7 @@ class DelugeRPCProtocol(DelugeTransferProtocol):
|
|||||||
def on_fail(failure):
|
def on_fail(failure):
|
||||||
try:
|
try:
|
||||||
failure.raiseException()
|
failure.raiseException()
|
||||||
except Exception, e:
|
except Exception:
|
||||||
sendError()
|
sendError()
|
||||||
return failure
|
return failure
|
||||||
|
|
||||||
@ -331,6 +328,7 @@ class DelugeRPCProtocol(DelugeTransferProtocol):
|
|||||||
else:
|
else:
|
||||||
self.sendData((RPC_RESPONSE, request_id, ret))
|
self.sendData((RPC_RESPONSE, request_id, ret))
|
||||||
|
|
||||||
|
|
||||||
class RPCServer(component.Component):
|
class RPCServer(component.Component):
|
||||||
"""
|
"""
|
||||||
This class is used to handle rpc requests from the client. Objects are
|
This class is used to handle rpc requests from the client. Objects are
|
||||||
@ -531,7 +529,8 @@ class RPCServer(component.Component):
|
|||||||
log.debug("Session ID %s is not valid. Not sending event \"%s\".", session_id, event.name)
|
log.debug("Session ID %s is not valid. Not sending event \"%s\".", session_id, event.name)
|
||||||
return
|
return
|
||||||
if session_id not in self.factory.interested_events:
|
if session_id not in self.factory.interested_events:
|
||||||
log.debug("Session ID %s is not interested in any events. Not sending event \"%s\".", session_id, event.name)
|
log.debug("Session ID %s is not interested in any events. Not sending event \"%s\".",
|
||||||
|
session_id, event.name)
|
||||||
return
|
return
|
||||||
if event.name not in self.factory.interested_events[session_id]:
|
if event.name not in self.factory.interested_events[session_id]:
|
||||||
log.debug("Session ID %s is not interested in event \"%s\". Not sending it.", session_id, event.name)
|
log.debug("Session ID %s is not interested in event \"%s\". Not sending it.", session_id, event.name)
|
||||||
@ -556,6 +555,7 @@ def check_ssl_keys():
|
|||||||
generate_ssl_keys()
|
generate_ssl_keys()
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
||||||
def generate_ssl_keys():
|
def generate_ssl_keys():
|
||||||
"""
|
"""
|
||||||
This method generates a new SSL key/cert.
|
This method generates a new SSL key/cert.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user