Flake8 core and common files
* Added N802 to flake8 ignore as certain inherited funcs cannot be changed to lowercase and this unresolved warning hides other errors/warnings. * Include new header
This commit is contained in:
parent
5d88504c34
commit
5167e93d12
|
@ -1,3 +1,12 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2009 Damien Churchill <damoxc@gmail.com>
|
||||
#
|
||||
# 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.
|
||||
# See LICENSE for more details.
|
||||
#
|
||||
|
||||
from new import classobj
|
||||
|
||||
from deluge.core.core import Core
|
||||
|
@ -7,6 +16,7 @@ from deluge.core.daemon import Daemon
|
|||
class RpcApi:
|
||||
pass
|
||||
|
||||
|
||||
def scan_for_methods(obj):
|
||||
methods = {
|
||||
'__doc__': 'Methods available in %s' % obj.__name__.lower()
|
||||
|
|
|
@ -1,36 +1,10 @@
|
|||
#
|
||||
# _libtorrent.py
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
|
||||
#
|
||||
# Deluge is free software.
|
||||
#
|
||||
# You may redistribute it and/or modify it under the terms of the
|
||||
# GNU General Public License, as published by the Free Software
|
||||
# Foundation; either version 3 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# deluge is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with deluge. If not, write to:
|
||||
# The Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# In addition, as a special exception, the copyright holders give
|
||||
# permission to link the code of portions of this program with the OpenSSL
|
||||
# library.
|
||||
# You must obey the GNU General Public License in all respects for all of
|
||||
# the code used other than OpenSSL. If you modify file(s) with this
|
||||
# exception, you may extend this exception to your version of the file(s),
|
||||
# but you are not obligated to do so. If you do not wish to do so, delete
|
||||
# this exception statement from your version. If you delete this exception
|
||||
# statement from all source files in the program, then also delete it here.
|
||||
#
|
||||
# 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.
|
||||
# See LICENSE for more details.
|
||||
#
|
||||
|
||||
"""
|
||||
|
@ -47,6 +21,7 @@ supports.
|
|||
|
||||
REQUIRED_VERSION = "0.16.7.0"
|
||||
|
||||
|
||||
def check_version(lt):
|
||||
from deluge.common import VersionSplit
|
||||
if VersionSplit(lt.version) < VersionSplit(REQUIRED_VERSION):
|
||||
|
|
|
@ -183,7 +183,7 @@ def resource_filename(module, path):
|
|||
# enough.
|
||||
# This is a work-around that.
|
||||
return pkg_resources.require("Deluge>=%s" % get_version())[0].get_resource_filename(
|
||||
pkg_resources._manager, os.path.join(*(module.split('.')+[path]))
|
||||
pkg_resources._manager, os.path.join(*(module.split(".") + [path]))
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -1,36 +1,10 @@
|
|||
#
|
||||
# component.py
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2007-2010 Andrew Resch <andrewresch@gmail.com>
|
||||
#
|
||||
# Deluge is free software.
|
||||
#
|
||||
# You may redistribute it and/or modify it under the terms of the
|
||||
# GNU General Public License, as published by the Free Software
|
||||
# Foundation; either version 3 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# deluge is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with deluge. If not, write to:
|
||||
# The Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# In addition, as a special exception, the copyright holders give
|
||||
# permission to link the code of portions of this program with the OpenSSL
|
||||
# library.
|
||||
# You must obey the GNU General Public License in all respects for all of
|
||||
# the code used other than OpenSSL. If you modify file(s) with this
|
||||
# exception, you may extend this exception to your version of the file(s),
|
||||
# but you are not obligated to do so. If you do not wish to do so, delete
|
||||
# this exception statement from your version. If you delete this exception
|
||||
# statement from all source files in the program, then also delete it here.
|
||||
#
|
||||
# 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.
|
||||
# See LICENSE for more details.
|
||||
#
|
||||
|
||||
import logging
|
||||
|
@ -41,9 +15,11 @@ from twisted.internet.task import LoopingCall
|
|||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class ComponentAlreadyRegistered(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class Component(object):
|
||||
"""
|
||||
Component objects are singletons managed by the :class:`ComponentRegistry`.
|
||||
|
@ -219,6 +195,7 @@ class Component(object):
|
|||
def shutdown(self):
|
||||
pass
|
||||
|
||||
|
||||
class ComponentRegistry(object):
|
||||
"""
|
||||
The ComponentRegistry holds a list of currently registered
|
||||
|
@ -264,6 +241,7 @@ class ComponentRegistry(object):
|
|||
if obj in self.components.values():
|
||||
log.debug("Deregistering Component: %s", obj._component_name)
|
||||
d = self.stop([obj._component_name])
|
||||
|
||||
def on_stop(result, name):
|
||||
del self.components[name]
|
||||
return d.addCallback(on_stop, obj._component_name)
|
||||
|
@ -430,6 +408,7 @@ resume = _ComponentRegistry.resume
|
|||
update = _ComponentRegistry.update
|
||||
shutdown = _ComponentRegistry.shutdown
|
||||
|
||||
|
||||
def get(name):
|
||||
"""
|
||||
Return a reference to a component.
|
||||
|
|
|
@ -1,38 +1,11 @@
|
|||
#
|
||||
# config.py
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2008 Andrew Resch <andrewresch@gmail.com>
|
||||
#
|
||||
# Deluge is free software.
|
||||
# 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.
|
||||
# See LICENSE for more details.
|
||||
#
|
||||
# You may redistribute it and/or modify it under the terms of the
|
||||
# GNU General Public License, as published by the Free Software
|
||||
# Foundation; either version 3 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# deluge is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with deluge. If not, write to:
|
||||
# The Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# In addition, as a special exception, the copyright holders give
|
||||
# permission to link the code of portions of this program with the OpenSSL
|
||||
# library.
|
||||
# You must obey the GNU General Public License in all respects for all of
|
||||
# the code used other than OpenSSL. If you modify file(s) with this
|
||||
# exception, you may extend this exception to your version of the file(s),
|
||||
# but you are not obligated to do so. If you do not wish to do so, delete
|
||||
# this exception statement from your version. If you delete this exception
|
||||
# statement from all source files in the program, then also delete it here.
|
||||
#
|
||||
#
|
||||
|
||||
|
||||
"""
|
||||
Deluge Config Module
|
||||
|
@ -208,7 +181,7 @@ what is currently in the config and it could not convert the value
|
|||
# Do not allow the type to change unless it is None
|
||||
oldtype, newtype = type(self.__config[key]), type(value)
|
||||
|
||||
if value is not None and oldtype != type(None) and oldtype != newtype:
|
||||
if value is not None and not isinstance(oldtype, type(None)) and not isinstance(oldtype, newtype):
|
||||
try:
|
||||
if oldtype == unicode:
|
||||
value = oldtype(value, "utf8")
|
||||
|
@ -542,7 +515,7 @@ what is currently in the config and it could not convert the value
|
|||
log.exception(ex)
|
||||
log.error("There was an exception try to convert config file %s %s to %s",
|
||||
self.__config_file, self.__version["file"], output_version)
|
||||
raise e
|
||||
raise ex
|
||||
else:
|
||||
self.__version["file"] = output_version
|
||||
self.save()
|
||||
|
|
|
@ -1,36 +1,10 @@
|
|||
#
|
||||
# configmanager.py
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2007 Andrew Resch <andrewresch@gmail.com>
|
||||
#
|
||||
# Deluge is free software.
|
||||
#
|
||||
# You may redistribute it and/or modify it under the terms of the
|
||||
# GNU General Public License, as published by the Free Software
|
||||
# Foundation; either version 3 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# deluge is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with deluge. If not, write to:
|
||||
# The Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# In addition, as a special exception, the copyright holders give
|
||||
# permission to link the code of portions of this program with the OpenSSL
|
||||
# library.
|
||||
# You must obey the GNU General Public License in all respects for all of
|
||||
# the code used other than OpenSSL. If you modify file(s) with this
|
||||
# exception, you may extend this exception to your version of the file(s),
|
||||
# but you are not obligated to do so. If you do not wish to do so, delete
|
||||
# this exception statement from your version. If you delete this exception
|
||||
# statement from all source files in the program, then also delete it here.
|
||||
#
|
||||
# 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.
|
||||
# See LICENSE for more details.
|
||||
#
|
||||
|
||||
import logging
|
||||
|
@ -42,6 +16,7 @@ from deluge.config import Config
|
|||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class _ConfigManager:
|
||||
def __init__(self):
|
||||
log.debug("ConfigManager started..")
|
||||
|
@ -121,18 +96,22 @@ class _ConfigManager:
|
|||
# Singleton functions
|
||||
_configmanager = _ConfigManager()
|
||||
|
||||
|
||||
def ConfigManager(config, defaults=None):
|
||||
return _configmanager.get_config(config, defaults)
|
||||
|
||||
|
||||
def set_config_dir(directory):
|
||||
"""Sets the config directory, else just uses default"""
|
||||
return _configmanager.set_config_dir(directory)
|
||||
|
||||
|
||||
def get_config_dir(filename=None):
|
||||
if filename != None:
|
||||
if filename is not None:
|
||||
return os.path.join(_configmanager.get_config_dir(), filename)
|
||||
else:
|
||||
return _configmanager.get_config_dir()
|
||||
|
||||
|
||||
def close(config):
|
||||
return _configmanager.close(config)
|
||||
|
|
|
@ -1,36 +1,10 @@
|
|||
#
|
||||
# decorators.py
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2010 John Garland <johnnybg+deluge@gmail.com>
|
||||
#
|
||||
# Deluge is free software.
|
||||
#
|
||||
# You may redistribute it and/or modify it under the terms of the
|
||||
# GNU General Public License, as published by the Free Software
|
||||
# Foundation; either version 3 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# deluge is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with deluge. If not, write to:
|
||||
# The Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# In addition, as a special exception, the copyright holders give
|
||||
# permission to link the code of portions of this program with the OpenSSL
|
||||
# library.
|
||||
# You must obey the GNU General Public License in all respects for all of
|
||||
# the code used other than OpenSSL. If you modify file(s) with this
|
||||
# exception, you may extend this exception to your version of the file(s),
|
||||
# but you are not obligated to do so. If you do not wish to do so, delete
|
||||
# this exception statement from your version. If you delete this exception
|
||||
# statement from all source files in the program, then also delete it here.
|
||||
#
|
||||
# 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.
|
||||
# See LICENSE for more details.
|
||||
#
|
||||
|
||||
from functools import wraps
|
||||
|
|
|
@ -1,37 +1,11 @@
|
|||
#
|
||||
# error.py
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2008 Andrew Resch <andrewresch@gmail.com>
|
||||
# Copyright (C) 2011 Pedro Algarvio <pedro@algarvio.me>
|
||||
#
|
||||
# Deluge is free software.
|
||||
#
|
||||
# You may redistribute it and/or modify it under the terms of the
|
||||
# GNU General Public License, as published by the Free Software
|
||||
# Foundation; either version 3 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# deluge is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with deluge. If not, write to:
|
||||
# The Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# In addition, as a special exception, the copyright holders give
|
||||
# permission to link the code of portions of this program with the OpenSSL
|
||||
# library.
|
||||
# You must obey the GNU General Public License in all respects for all of
|
||||
# the code used other than OpenSSL. If you modify file(s) with this
|
||||
# exception, you may extend this exception to your version of the file(s),
|
||||
# but you are not obligated to do so. If you do not wish to do so, delete
|
||||
# this exception statement from your version. If you delete this exception
|
||||
# statement from all source files in the program, then also delete it here.
|
||||
#
|
||||
# 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.
|
||||
# See LICENSE for more details.
|
||||
#
|
||||
|
||||
|
||||
|
|
|
@ -1,36 +1,10 @@
|
|||
#
|
||||
# event.py
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
|
||||
#
|
||||
# Deluge is free software.
|
||||
#
|
||||
# You may redistribute it and/or modify it under the terms of the
|
||||
# GNU General Public License, as published by the Free Software
|
||||
# Foundation; either version 3 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# deluge is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with deluge. If not, write to:
|
||||
# The Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# In addition, as a special exception, the copyright holders give
|
||||
# permission to link the code of portions of this program with the OpenSSL
|
||||
# library.
|
||||
# You must obey the GNU General Public License in all respects for all of
|
||||
# the code used other than OpenSSL. If you modify file(s) with this
|
||||
# exception, you may extend this exception to your version of the file(s),
|
||||
# but you are not obligated to do so. If you do not wish to do so, delete
|
||||
# this exception statement from your version. If you delete this exception
|
||||
# statement from all source files in the program, then also delete it here.
|
||||
#
|
||||
# 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.
|
||||
# See LICENSE for more details.
|
||||
#
|
||||
|
||||
"""
|
||||
|
@ -48,10 +22,10 @@ class DelugeEventMetaClass(type):
|
|||
"""
|
||||
This metaclass simply keeps a list of all events classes created.
|
||||
"""
|
||||
def __init__(cls, name, bases, dct):
|
||||
super(DelugeEventMetaClass, cls).__init__(name, bases, dct)
|
||||
def __init__(self, name, bases, dct):
|
||||
super(DelugeEventMetaClass, self).__init__(name, bases, dct)
|
||||
if name != "DelugeEvent":
|
||||
known_events[name] = cls
|
||||
known_events[name] = self
|
||||
|
||||
|
||||
class DelugeEvent(object):
|
||||
|
|
|
@ -1,35 +1,10 @@
|
|||
#
|
||||
# httpdownloader.py
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
|
||||
#
|
||||
# Deluge is free software.
|
||||
#
|
||||
# You may redistribute it and/or modify it under the terms of the
|
||||
# GNU General Public License, as published by the Free Software
|
||||
# Foundation; either version 3 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# deluge is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with deluge. If not, write to:
|
||||
# The Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# In addition, as a special exception, the copyright holders give
|
||||
# permission to link the code of portions of this program with the OpenSSL
|
||||
# library.
|
||||
# You must obey the GNU General Public License in all respects for all of
|
||||
# the code used other than OpenSSL. If you modify file(s) with this
|
||||
# exception, you may extend this exception to your version of the file(s),
|
||||
# but you are not obligated to do so. If you do not wish to do so, delete
|
||||
# this exception statement from your version. If you delete this exception
|
||||
# statement from all source files in the program, then also delete it here.
|
||||
# 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.
|
||||
# See LICENSE for more details.
|
||||
#
|
||||
|
||||
import logging
|
||||
|
@ -45,6 +20,7 @@ from common import get_version
|
|||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class HTTPDownloader(client.HTTPDownloader):
|
||||
"""
|
||||
Factory class for downloading files and keeping track of progress.
|
||||
|
@ -132,6 +108,7 @@ class HTTPDownloader(client.HTTPDownloader):
|
|||
|
||||
return client.HTTPDownloader.pageEnd(self)
|
||||
|
||||
|
||||
def sanitise_filename(filename):
|
||||
"""
|
||||
Sanitises a filename to use as a download destination file.
|
||||
|
@ -159,8 +136,8 @@ def sanitise_filename(filename):
|
|||
|
||||
return filename
|
||||
|
||||
def download_file(url, filename, callback=None, headers=None,
|
||||
force_filename=False, allow_compression=True):
|
||||
|
||||
def download_file(url, filename, callback=None, headers=None, force_filename=False, allow_compression=True):
|
||||
"""
|
||||
Downloads a file from a specific URL and returns a Deferred. You can also
|
||||
specify a callback function to be called as parts are received.
|
||||
|
@ -207,7 +184,6 @@ def download_file(url, filename, callback=None, headers=None,
|
|||
scheme = uri.scheme
|
||||
host = uri.host
|
||||
port = uri.port
|
||||
path = uri.path
|
||||
|
||||
factory = HTTPDownloader(url, filename, callback, headers, force_filename, allow_compression)
|
||||
if scheme == "https":
|
||||
|
|
|
@ -1,37 +1,11 @@
|
|||
#
|
||||
# log.py
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2007 Andrew Resch <andrewresch@gmail.com>
|
||||
# Copyright (C) 2010 Pedro Algarvio <pedro@algarvio.me>
|
||||
#
|
||||
# Deluge is free software.
|
||||
#
|
||||
# You may redistribute it and/or modify it under the terms of the
|
||||
# GNU General Public License, as published by the Free Software
|
||||
# Foundation; either version 3 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# deluge is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with deluge. If not, write to:
|
||||
# The Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# In addition, as a special exception, the copyright holders give
|
||||
# permission to link the code of portions of this program with the OpenSSL
|
||||
# library.
|
||||
# You must obey the GNU General Public License in all respects for all of
|
||||
# the code used other than OpenSSL. If you modify file(s) with this
|
||||
# exception, you may extend this exception to your version of the file(s),
|
||||
# but you are not obligated to do so. If you do not wish to do so, delete
|
||||
# this exception statement from your version. If you delete this exception
|
||||
# statement from all source files in the program, then also delete it here.
|
||||
#
|
||||
# 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.
|
||||
# See LICENSE for more details.
|
||||
#
|
||||
|
||||
"""Logging functions"""
|
||||
|
@ -49,12 +23,13 @@ __all__ = ["setupLogger", "setLoggerLevel", "getPluginLogger", "LOG"]
|
|||
|
||||
LoggingLoggerClass = logging.getLoggerClass()
|
||||
|
||||
if 'dev' in common.get_version():
|
||||
if "dev" in common.get_version():
|
||||
DEFAULT_LOGGING_FORMAT = "%%(asctime)s.%%(msecs)03.0f [%%(levelname)-8s][%%(name)-%ds:%%(lineno)-4d] %%(message)s"
|
||||
else:
|
||||
DEFAULT_LOGGING_FORMAT = "%%(asctime)s [%%(levelname)-8s][%%(name)-%ds] %%(message)s"
|
||||
MAX_LOGGER_NAME_LENGTH = 10
|
||||
|
||||
|
||||
class Logging(LoggingLoggerClass):
|
||||
def __init__(self, logger_name):
|
||||
LoggingLoggerClass.__init__(self, logger_name)
|
||||
|
@ -110,8 +85,8 @@ class Logging(LoggingLoggerClass):
|
|||
while hasattr(f, "f_code"):
|
||||
co = f.f_code
|
||||
filename = os.path.normcase(co.co_filename)
|
||||
if filename in (__file__.replace('.pyc', '.py'),
|
||||
defer.__file__.replace('.pyc', '.py')):
|
||||
if filename in (__file__.replace(".pyc", ".py"),
|
||||
defer.__file__.replace(".pyc", ".py")):
|
||||
f = f.f_back
|
||||
continue
|
||||
rv = (filename, f.f_lineno, co.co_name)
|
||||
|
@ -143,27 +118,27 @@ def setupLogger(level="error", filename=None, filemode="w"):
|
|||
|
||||
if logging.getLoggerClass() is not Logging:
|
||||
logging.setLoggerClass(Logging)
|
||||
logging.addLevelName(5, 'TRACE')
|
||||
logging.addLevelName(1, 'GARBAGE')
|
||||
logging.addLevelName(5, "TRACE")
|
||||
logging.addLevelName(1, "GARBAGE")
|
||||
|
||||
level = levels.get(level, logging.ERROR)
|
||||
|
||||
rootLogger = logging.getLogger()
|
||||
root_logger = logging.getLogger()
|
||||
|
||||
if filename and filemode=='a':
|
||||
if filename and filemode == "a":
|
||||
import logging.handlers
|
||||
handler = logging.handlers.RotatingFileHandler(
|
||||
filename, filemode,
|
||||
maxBytes=50 * 1024 * 1024, # 50 Mb
|
||||
backupCount=3,
|
||||
encoding='utf-8',
|
||||
encoding="utf-8",
|
||||
delay=0
|
||||
)
|
||||
elif filename and filemode=='w':
|
||||
elif filename and filemode == "w":
|
||||
import logging.handlers
|
||||
handler = getattr(
|
||||
logging.handlers, 'WatchedFileHandler', logging.FileHandler)(
|
||||
filename, filemode, 'utf-8', delay=0
|
||||
logging.handlers, "WatchedFileHandler", logging.FileHandler)(
|
||||
filename, filemode, "utf-8", delay=0
|
||||
)
|
||||
else:
|
||||
handler = logging.StreamHandler()
|
||||
|
@ -176,13 +151,14 @@ def setupLogger(level="error", filename=None, filemode="w"):
|
|||
)
|
||||
|
||||
handler.setFormatter(formatter)
|
||||
rootLogger.addHandler(handler)
|
||||
rootLogger.setLevel(level)
|
||||
root_logger.addHandler(handler)
|
||||
root_logger.setLevel(level)
|
||||
|
||||
twisted_logging = PythonLoggingObserver('twisted')
|
||||
twisted_logging = PythonLoggingObserver("twisted")
|
||||
twisted_logging.start()
|
||||
logging.getLogger("twisted").setLevel(level)
|
||||
|
||||
|
||||
def tweak_logging_levels():
|
||||
"""This function allows tweaking the logging levels for all or some loggers.
|
||||
This is mostly usefull for developing purposes hence the contents of the
|
||||
|
@ -202,17 +178,16 @@ def tweak_logging_levels():
|
|||
the command line.
|
||||
"""
|
||||
from deluge import configmanager
|
||||
logging_config_file = os.path.join(configmanager.get_config_dir(),
|
||||
'logging.conf')
|
||||
logging_config_file = os.path.join(configmanager.get_config_dir(), "logging.conf")
|
||||
if not os.path.isfile(logging_config_file):
|
||||
return
|
||||
log = logging.getLogger(__name__)
|
||||
log.warn("logging.conf found! tweaking logging levels from %s",
|
||||
logging_config_file)
|
||||
for line in open(logging_config_file, 'r').readlines():
|
||||
for line in open(logging_config_file, "r").readlines():
|
||||
if line.strip().startswith("#"):
|
||||
continue
|
||||
name, level = line.strip().split(':')
|
||||
name, level = line.strip().split(":")
|
||||
if level not in levels:
|
||||
continue
|
||||
|
||||
|
@ -240,12 +215,12 @@ def getPluginLogger(logger_name):
|
|||
module_stack = stack.pop(0) # The module that called the log function
|
||||
caller_module = inspect.getmodule(module_stack[0])
|
||||
# In some weird cases caller_module might be None, try to continue
|
||||
caller_module_name = getattr(caller_module, '__name__', '')
|
||||
caller_module_name = getattr(caller_module, "__name__", "")
|
||||
warnings.warn_explicit(DEPRECATION_WARNING, DeprecationWarning,
|
||||
module_stack[1], module_stack[2],
|
||||
caller_module_name)
|
||||
|
||||
if 'deluge.plugins.' in logger_name:
|
||||
if "deluge.plugins." in logger_name:
|
||||
return logging.getLogger(logger_name)
|
||||
return logging.getLogger("deluge.plugin.%s" % logger_name)
|
||||
|
||||
|
@ -272,16 +247,17 @@ The above will result in, regarding the "Label" plugin for example a log message
|
|||
|
||||
Triggering code:"""
|
||||
|
||||
class __BackwardsCompatibleLOG(object):
|
||||
|
||||
class _BackwardsCompatibleLOG(object):
|
||||
def __getattribute__(self, name):
|
||||
import warnings
|
||||
logger_name = 'deluge'
|
||||
logger_name = "deluge"
|
||||
stack = inspect.stack()
|
||||
stack.pop(0) # The logging call from this module
|
||||
module_stack = stack.pop(0) # The module that called the log function
|
||||
caller_module = inspect.getmodule(module_stack[0])
|
||||
# In some weird cases caller_module might be None, try to continue
|
||||
caller_module_name = getattr(caller_module, '__name__', '')
|
||||
caller_module_name = getattr(caller_module, "__name__", "")
|
||||
warnings.warn_explicit(DEPRECATION_WARNING, DeprecationWarning,
|
||||
module_stack[1], module_stack[2],
|
||||
caller_module_name)
|
||||
|
@ -290,9 +266,9 @@ class __BackwardsCompatibleLOG(object):
|
|||
module = inspect.getmodule(member[0])
|
||||
if not module:
|
||||
continue
|
||||
if module.__name__ in ('deluge.plugins.pluginbase',
|
||||
'deluge.plugins.init'):
|
||||
logger_name += '.plugin.%s' % caller_module_name
|
||||
if module.__name__ in ("deluge.plugins.pluginbase",
|
||||
"deluge.plugins.init"):
|
||||
logger_name += ".plugin.%s" % caller_module_name
|
||||
# Monkey Patch The Plugin Module
|
||||
caller_module.log = logging.getLogger(logger_name)
|
||||
break
|
||||
|
@ -303,4 +279,4 @@ class __BackwardsCompatibleLOG(object):
|
|||
)
|
||||
return getattr(logging.getLogger(logger_name), name)
|
||||
|
||||
LOG = __BackwardsCompatibleLOG()
|
||||
LOG = _BackwardsCompatibleLOG()
|
||||
|
|
|
@ -1,37 +1,11 @@
|
|||
#
|
||||
# main.py
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2007 Andrew Resch <andrewresch@gmail.com>
|
||||
# Copyright (C) 2010 Pedro Algarvio <pedro@algarvio.me>
|
||||
#
|
||||
# Deluge is free software.
|
||||
#
|
||||
# You may redistribute it and/or modify it under the terms of the
|
||||
# GNU General Public License, as published by the Free Software
|
||||
# Foundation; either version 3 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# deluge is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with deluge. If not, write to:
|
||||
# The Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# In addition, as a special exception, the copyright holders give
|
||||
# permission to link the code of portions of this program with the OpenSSL
|
||||
# library.
|
||||
# You must obey the GNU General Public License in all respects for all of
|
||||
# the code used other than OpenSSL. If you modify file(s) with this
|
||||
# exception, you may extend this exception to your version of the file(s),
|
||||
# but you are not obligated to do so. If you do not wish to do so, delete
|
||||
# this exception statement from your version. If you delete this exception
|
||||
# statement from all source files in the program, then also delete it here.
|
||||
#
|
||||
# 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.
|
||||
# See LICENSE for more details.
|
||||
#
|
||||
|
||||
|
||||
|
@ -73,19 +47,19 @@ def start_ui():
|
|||
help="""The UI that you wish to launch. The UI choices are:\n
|
||||
\t gtk -- A GTK-based graphical user interface (default)\n
|
||||
\t web -- A web-based interface (http://localhost:8112)\n
|
||||
\t console -- A console or command-line interface""", action="store", type="str")
|
||||
\t console -- A console or command-line interface""")
|
||||
parser.add_option("-s", "--set-default-ui", dest="default_ui",
|
||||
help="Sets the default UI to be run when no UI is specified", action="store", type="str")
|
||||
help="Sets the default UI to be run when no UI is specified")
|
||||
parser.add_option("-a", "--args", dest="args",
|
||||
help="Arguments to pass to UI, -a '--option args'", action="store", type="str")
|
||||
help="Arguments to pass to UI, -a '--option args'")
|
||||
parser.add_option("-c", "--config", dest="config",
|
||||
help="Set the config folder location", action="store", type="str")
|
||||
help="Set the config folder location")
|
||||
parser.add_option("-l", "--logfile", dest="logfile",
|
||||
help="Output to designated logfile instead of stdout", action="store", type="str")
|
||||
help="Output to designated logfile instead of stdout")
|
||||
parser.add_option("-L", "--loglevel", dest="loglevel",
|
||||
help="Set the log level: none, info, warning, error, critical, debug", action="store", type="str")
|
||||
parser.add_option("-q", "--quiet", dest="quiet",
|
||||
help="Sets the log level to 'none', this is the same as `-L none`", action="store_true", default=False)
|
||||
help="Set the log level: none, info, warning, error, critical, debug")
|
||||
parser.add_option("-q", "--quiet", dest="quiet", action="store_true", default=False,
|
||||
help="Sets the log level to 'none', this is the same as `-L none`")
|
||||
parser.add_option("-r", "--rotate-logs",
|
||||
help="Rotate logfiles.", action="store_true", default=False)
|
||||
|
||||
|
@ -152,36 +126,27 @@ def start_daemon():
|
|||
parser.add_option("-v", "--version", action="callback", callback=version_callback,
|
||||
help="Show program's version number and exit")
|
||||
parser.add_option("-p", "--port", dest="port",
|
||||
help="Port daemon will listen on", action="store", type="int")
|
||||
help="Port daemon will listen on", type="int")
|
||||
parser.add_option("-i", "--interface", dest="listen_interface",
|
||||
help="Interface daemon will listen for bittorrent connections on, \
|
||||
this should be an IP address", metavar="IFACE",
|
||||
action="store", type="str")
|
||||
parser.add_option("-u", "--ui-interface", dest="ui_interface",
|
||||
help="Interface daemon will listen for UI connections on, this should be\
|
||||
an IP address", metavar="IFACE", action="store", type="str")
|
||||
help="Interface daemon will listen for bittorrent connections on,"
|
||||
"this should be an IP address", metavar="IFACE")
|
||||
parser.add_option("-u", "--ui-interface", dest="ui_interface", metavar="IFACE",
|
||||
help="Interface daemon will listen for UI connections on, this should be an IP address")
|
||||
if not (deluge.common.windows_check() or deluge.common.osx_check()):
|
||||
parser.add_option("-d", "--do-not-daemonize", dest="donot",
|
||||
help="Do not daemonize", action="store_true", default=False)
|
||||
parser.add_option("-c", "--config", dest="config",
|
||||
help="Set the config location", action="store", type="str")
|
||||
parser.add_option("-P", "--pidfile", dest="pidfile",
|
||||
help="Use pidfile to store process id", action="store", type="str")
|
||||
parser.add_option("-c", "--config", dest="config", help="Set the config location")
|
||||
parser.add_option("-P", "--pidfile", dest="pidfile", help="Use pidfile to store process id")
|
||||
if not deluge.common.windows_check():
|
||||
parser.add_option("-U", "--user", dest="user",
|
||||
help="User to switch to. Only use it when starting as root", action="store", type="str")
|
||||
parser.add_option("-g", "--group", dest="group",
|
||||
help="Group to switch to. Only use it when starting as root", action="store", type="str")
|
||||
parser.add_option("-l", "--logfile", dest="logfile",
|
||||
help="Set the logfile location", action="store", type="str")
|
||||
parser.add_option("-U", "--user", dest="user", help="User to switch to. Only use it when starting as root")
|
||||
parser.add_option("-g", "--group", dest="group", help="Group to switch to. Only use it when starting as root")
|
||||
parser.add_option("-l", "--logfile", dest="logfile", help="Set the logfile location")
|
||||
parser.add_option("-L", "--loglevel", dest="loglevel",
|
||||
help="Set the log level: none, info, warning, error, critical, debug", action="store", type="str")
|
||||
parser.add_option("-q", "--quiet", dest="quiet",
|
||||
help="Sets the log level to 'none', this is the same as `-L none`", action="store_true", default=False)
|
||||
parser.add_option("-r", "--rotate-logs",
|
||||
help="Rotate logfiles.", action="store_true", default=False)
|
||||
parser.add_option("--profile", dest="profile", action="store_true", default=False,
|
||||
help="Profiles the daemon")
|
||||
help="Set the log level: none, info, warning, error, critical, debug")
|
||||
parser.add_option("-q", "--quiet", dest="quiet", action="store_true", default=False,
|
||||
help="Sets the log level to 'none', this is the same as `-L none`")
|
||||
parser.add_option("-r", "--rotate-logs", help="Rotate logfiles.", action="store_true", default=False)
|
||||
parser.add_option("--profile", dest="profile", action="store_true", default=False, help="Profiles the daemon")
|
||||
|
||||
# Get the options and args from the OptionParser
|
||||
(options, args) = parser.parse_args()
|
||||
|
|
|
@ -1,36 +1,10 @@
|
|||
#
|
||||
# maketorrent.py
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
|
||||
#
|
||||
# Deluge is free software.
|
||||
#
|
||||
# You may redistribute it and/or modify it under the terms of the
|
||||
# GNU General Public License, as published by the Free Software
|
||||
# Foundation; either version 3 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# deluge is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with deluge. If not, write to:
|
||||
# The Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# In addition, as a special exception, the copyright holders give
|
||||
# permission to link the code of portions of this program with the OpenSSL
|
||||
# library.
|
||||
# You must obey the GNU General Public License in all respects for all of
|
||||
# the code used other than OpenSSL. If you modify file(s) with this
|
||||
# exception, you may extend this exception to your version of the file(s),
|
||||
# but you are not obligated to do so. If you do not wish to do so, delete
|
||||
# this exception statement from your version. If you delete this exception
|
||||
# statement from all source files in the program, then also delete it here.
|
||||
#
|
||||
# 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.
|
||||
# See LICENSE for more details.
|
||||
#
|
||||
|
||||
import os
|
||||
|
@ -47,6 +21,7 @@ class InvalidPath(Exception):
|
|||
"""
|
||||
pass
|
||||
|
||||
|
||||
class InvalidPieceSize(Exception):
|
||||
"""
|
||||
Raised when an invalid piece size is set. Piece sizes must be multiples of
|
||||
|
@ -54,6 +29,7 @@ class InvalidPieceSize(Exception):
|
|||
"""
|
||||
pass
|
||||
|
||||
|
||||
class TorrentMetadata(object):
|
||||
"""
|
||||
This class is used to create .torrent files.
|
||||
|
@ -125,7 +101,7 @@ class TorrentMetadata(object):
|
|||
datasize = get_path_size(self.data_path)
|
||||
|
||||
if self.piece_size:
|
||||
piece_size = piece_size * 1024
|
||||
piece_size = self.piece_size * 1024
|
||||
else:
|
||||
# We need to calculate a piece size
|
||||
piece_size = 16384
|
||||
|
|
|
@ -38,15 +38,18 @@ for i in xrange(0xFDD0, 0xFDF0):
|
|||
for i in (0xFFFE, 0xFFFF):
|
||||
noncharacter_translate[i] = ord('-')
|
||||
|
||||
|
||||
def gmtime():
|
||||
return time.mktime(time.gmtime())
|
||||
|
||||
|
||||
def get_filesystem_encoding():
|
||||
return sys.getfilesystemencoding()
|
||||
|
||||
|
||||
def decode_from_filesystem(path):
|
||||
encoding = get_filesystem_encoding()
|
||||
if encoding == None:
|
||||
if encoding is None:
|
||||
assert isinstance(path, unicode), "Path should be unicode not %s" % type(path)
|
||||
decoded_path = path
|
||||
else:
|
||||
|
@ -55,9 +58,11 @@ def decode_from_filesystem(path):
|
|||
|
||||
return decoded_path
|
||||
|
||||
|
||||
def dummy(*v):
|
||||
pass
|
||||
|
||||
|
||||
class RemoteFileProgress(object):
|
||||
def __init__(self, session_id):
|
||||
self.session_id = session_id
|
||||
|
@ -67,6 +72,7 @@ class RemoteFileProgress(object):
|
|||
self.session_id, CreateTorrentProgressEvent(piece_count, num_pieces)
|
||||
)
|
||||
|
||||
|
||||
def make_meta_file(path, url, piece_length, progress=None, title=None, comment=None,
|
||||
safe=None, content_type=None, target=None, webseeds=None, name=None,
|
||||
private=False, created_by=None, trackers=None):
|
||||
|
@ -127,15 +133,16 @@ def make_meta_file(path, url, piece_length, progress=None, title=None, comment=N
|
|||
h.write(bencode(data))
|
||||
h.close()
|
||||
|
||||
|
||||
def calcsize(path):
|
||||
total = 0
|
||||
for s in subfiles(os.path.abspath(path)):
|
||||
total += os.path.getsize(s[1])
|
||||
return total
|
||||
|
||||
def makeinfo(path, piece_length, progress, name = None,
|
||||
content_type = None, private=False): # HEREDAVE. If path is directory,
|
||||
# how do we assign content type?
|
||||
|
||||
def makeinfo(path, piece_length, progress, name=None, content_type=None, private=False):
|
||||
# HEREDAVE. If path is directory, how do we assign content type?
|
||||
def to_utf8(name):
|
||||
if isinstance(name, unicode):
|
||||
u = name
|
||||
|
@ -208,7 +215,8 @@ def makeinfo(path, piece_length, progress, name = None,
|
|||
name = to_utf8(os.path.split(path)[1])
|
||||
|
||||
return {'pieces': ''.join(pieces),
|
||||
'piece length': piece_length, 'files': fs,
|
||||
'piece length': piece_length,
|
||||
'files': fs,
|
||||
'name': name,
|
||||
'private': private}
|
||||
else:
|
||||
|
@ -241,6 +249,7 @@ def makeinfo(path, piece_length, progress, name = None,
|
|||
'name': to_utf8(os.path.split(path)[1]),
|
||||
'private': private}
|
||||
|
||||
|
||||
def subfiles(d):
|
||||
r = []
|
||||
stack = [([], d)]
|
||||
|
|
|
@ -1,37 +1,11 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# path_chooser_common.py
|
||||
#
|
||||
# Copyright (C) 2013 Bro <bro.development@gmail.com>
|
||||
#
|
||||
# Deluge is free software.
|
||||
#
|
||||
# You may redistribute it and/or modify it under the terms of the
|
||||
# GNU General Public License, as published by the Free Software
|
||||
# Foundation; either version 3 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# deluge is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with deluge. If not, write to:
|
||||
# The Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# In addition, as a special exception, the copyright holders give
|
||||
# permission to link the code of portions of this program with the OpenSSL
|
||||
# library.
|
||||
# You must obey the GNU General Public License in all respects for all of
|
||||
# the code used other than OpenSSL. If you modify file(s) with this
|
||||
# exception, you may extend this exception to your version of the file(s),
|
||||
# but you are not obligated to do so. If you do not wish to do so, delete
|
||||
# this exception statement from your version. If you delete this exception
|
||||
# statement from all source files in the program, then also delete it here.
|
||||
# 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.
|
||||
# See LICENSE for more details.
|
||||
#
|
||||
|
||||
import os
|
||||
|
@ -41,9 +15,11 @@ def get_resource(filename):
|
|||
import deluge
|
||||
return deluge.common.resource_filename("deluge.ui.gtkui", os.path.join("glade", filename))
|
||||
|
||||
|
||||
def is_hidden(filepath):
|
||||
def has_hidden_attribute(filepath):
|
||||
import win32api, win32con
|
||||
import win32api
|
||||
import win32con
|
||||
try:
|
||||
attribute = win32api.GetFileAttributes(filepath)
|
||||
return attribute & (win32con.FILE_ATTRIBUTE_HIDDEN | win32con.FILE_ATTRIBUTE_SYSTEM)
|
||||
|
@ -56,6 +32,7 @@ def is_hidden(filepath):
|
|||
return has_hidden_attribute(filepath)
|
||||
return name.startswith('.')
|
||||
|
||||
|
||||
def get_completion_paths(args):
|
||||
"""
|
||||
Takes a path value and returns the available completions.
|
||||
|
|
|
@ -1,36 +1,10 @@
|
|||
#
|
||||
# pluginmanagerbase.py
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2007 Andrew Resch <andrewresch@gmail.com>
|
||||
#
|
||||
# Deluge is free software.
|
||||
#
|
||||
# You may redistribute it and/or modify it under the terms of the
|
||||
# GNU General Public License, as published by the Free Software
|
||||
# Foundation; either version 3 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# deluge is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with deluge. If not, write to:
|
||||
# The Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# In addition, as a special exception, the copyright holders give
|
||||
# permission to link the code of portions of this program with the OpenSSL
|
||||
# library.
|
||||
# You must obey the GNU General Public License in all respects for all of
|
||||
# the code used other than OpenSSL. If you modify file(s) with this
|
||||
# exception, you may extend this exception to your version of the file(s),
|
||||
# but you are not obligated to do so. If you do not wish to do so, delete
|
||||
# this exception statement from your version. If you delete this exception
|
||||
# statement from all source files in the program, then also delete it here.
|
||||
#
|
||||
# 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.
|
||||
# See LICENSE for more details.
|
||||
#
|
||||
|
||||
|
||||
|
@ -69,6 +43,7 @@ If you're the developer, please take a look at the plugins hosted on deluge's
|
|||
git repository to have an idea of what needs to be changed.
|
||||
"""
|
||||
|
||||
|
||||
class PluginManagerBase:
|
||||
"""PluginManagerBase is a base class for PluginManagers to inherit"""
|
||||
|
||||
|
@ -170,8 +145,7 @@ class PluginManagerBase:
|
|||
plugin_name = plugin_name.replace("-", " ")
|
||||
self.plugins[plugin_name] = instance
|
||||
if plugin_name not in self.config["enabled_plugins"]:
|
||||
log.debug("Adding %s to enabled_plugins list in config",
|
||||
plugin_name)
|
||||
log.debug("Adding %s to enabled_plugins list in config", plugin_name)
|
||||
self.config["enabled_plugins"].append(plugin_name)
|
||||
log.info("Plugin %s enabled..", plugin_name)
|
||||
|
||||
|
|
|
@ -1,36 +1,10 @@
|
|||
#
|
||||
# init.py
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2007 Andrew Resch <andrewresch@gmail.com>
|
||||
#
|
||||
# Deluge is free software.
|
||||
#
|
||||
# You may redistribute it and/or modify it under the terms of the
|
||||
# GNU General Public License, as published by the Free Software
|
||||
# Foundation; either version 3 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# deluge is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with deluge. If not, write to:
|
||||
# The Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# In addition, as a special exception, the copyright holders give
|
||||
# permission to link the code of portions of this program with the OpenSSL
|
||||
# library.
|
||||
# You must obey the GNU General Public License in all respects for all of
|
||||
# the code used other than OpenSSL. If you modify file(s) with this
|
||||
# exception, you may extend this exception to your version of the file(s),
|
||||
# but you are not obligated to do so. If you do not wish to do so, delete
|
||||
# this exception statement from your version. If you delete this exception
|
||||
# statement from all source files in the program, then also delete it here.
|
||||
#
|
||||
# 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.
|
||||
# See LICENSE for more details.
|
||||
#
|
||||
|
||||
"""
|
||||
|
@ -40,8 +14,10 @@ import logging
|
|||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class PluginInitBase(object):
|
||||
_plugin_cls = None
|
||||
|
||||
def __init__(self, plugin_name):
|
||||
self.plugin = self._plugin_cls(plugin_name)
|
||||
|
||||
|
|
|
@ -1,36 +1,10 @@
|
|||
#
|
||||
# pluginbase.py
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2007-2010 Andrew Resch <andrewresch@gmail.com>
|
||||
#
|
||||
# Deluge is free software.
|
||||
#
|
||||
# You may redistribute it and/or modify it under the terms of the
|
||||
# GNU General Public License, as published by the Free Software
|
||||
# Foundation; either version 3 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# deluge is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with deluge. If not, write to:
|
||||
# The Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# In addition, as a special exception, the copyright holders give
|
||||
# permission to link the code of portions of this program with the OpenSSL
|
||||
# library.
|
||||
# You must obey the GNU General Public License in all respects for all of
|
||||
# the code used other than OpenSSL. If you modify file(s) with this
|
||||
# exception, you may extend this exception to your version of the file(s),
|
||||
# but you are not obligated to do so. If you do not wish to do so, delete
|
||||
# this exception statement from your version. If you delete this exception
|
||||
# statement from all source files in the program, then also delete it here.
|
||||
#
|
||||
# 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.
|
||||
# See LICENSE for more details.
|
||||
#
|
||||
|
||||
import logging
|
||||
|
@ -39,6 +13,7 @@ import deluge.component as component
|
|||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class PluginBase(component.Component):
|
||||
|
||||
update_interval = 1
|
||||
|
@ -52,6 +27,7 @@ class PluginBase(component.Component):
|
|||
def disable(self):
|
||||
raise NotImplementedError("Need to define a disable method!")
|
||||
|
||||
|
||||
class CorePluginBase(PluginBase):
|
||||
def __init__(self, plugin_name):
|
||||
super(CorePluginBase, self).__init__("CorePlugin." + plugin_name)
|
||||
|
@ -62,11 +38,13 @@ class CorePluginBase(PluginBase):
|
|||
def __del__(self):
|
||||
component.get("RPCServer").deregister_object(self)
|
||||
|
||||
|
||||
class GtkPluginBase(PluginBase):
|
||||
def __init__(self, plugin_name):
|
||||
super(GtkPluginBase, self).__init__("GtkPlugin." + plugin_name)
|
||||
log.debug("GtkPlugin initialized..")
|
||||
|
||||
|
||||
class WebPluginBase(PluginBase):
|
||||
|
||||
scripts = []
|
||||
|
|
|
@ -298,7 +298,6 @@ def loads(x, decode_utf8=False):
|
|||
return r
|
||||
|
||||
|
||||
|
||||
def encode_int(x, r):
|
||||
if 0 <= x < INT_POS_FIXED_COUNT:
|
||||
r.append(chr(INT_POS_FIXED_START + x))
|
||||
|
|
|
@ -367,8 +367,8 @@ new %(name)sPlugin();
|
|||
"""
|
||||
|
||||
GPL = """#
|
||||
# %(filename)s
|
||||
#
|
||||
# -*- coding: utf-8 -*-#
|
||||
|
||||
# Copyright (C) %(current_year)d %(author_name)s <%(author_email)s>
|
||||
#
|
||||
# Basic plugin template created by:
|
||||
|
@ -377,33 +377,9 @@ GPL = """#
|
|||
# Copyright (C) 2009 Damien Churchill <damoxc@gmail.com>
|
||||
# Copyright (C) 2010 Pedro Algarvio <pedro@algarvio.me>
|
||||
#
|
||||
# Deluge is free software.
|
||||
#
|
||||
# You may redistribute it and/or modify it under the terms of the
|
||||
# GNU General Public License, as published by the Free Software
|
||||
# Foundation; either version 3 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# deluge is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with deluge. If not, write to:
|
||||
# The Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# In addition, as a special exception, the copyright holders give
|
||||
# permission to link the code of portions of this program with the OpenSSL
|
||||
# library.
|
||||
# You must obey the GNU General Public License in all respects for all of
|
||||
# the code used other than OpenSSL. If you modify file(s) with this
|
||||
# exception, you may extend this exception to your version of the file(s),
|
||||
# but you are not obligated to do so. If you do not wish to do so, delete
|
||||
# this exception statement from your version. If you delete this exception
|
||||
# statement from all source files in the program, then also delete it here.
|
||||
# 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.
|
||||
# See LICENSE for more details.
|
||||
#
|
||||
"""
|
||||
|
||||
|
@ -415,7 +391,8 @@ pkg_resources.declare_namespace(__name__)
|
|||
CREATE_DEV_LINK = """#!/bin/bash
|
||||
BASEDIR=$(cd `dirname $0` && pwd)
|
||||
CONFIG_DIR=$( test -z $1 && echo "%(configdir)s" || echo "$1")
|
||||
[ -d "$CONFIG_DIR/plugins" ] || echo "Config dir \"$CONFIG_DIR\" is either not a directory or is not a proper deluge config directory. Exiting"
|
||||
[ -d "$CONFIG_DIR/plugins" ] || echo "Config dir \"$CONFIG_DIR\" is either not a directory \
|
||||
or is not a proper deluge config directory. Exiting"
|
||||
[ -d "$CONFIG_DIR/plugins" ] || exit 1
|
||||
cd $BASEDIR
|
||||
test -d $BASEDIR/temp || mkdir $BASEDIR/temp
|
||||
|
|
|
@ -3,32 +3,9 @@
|
|||
#
|
||||
# Copyright (C) Martijn Voncken 2008 <mvoncken@gmail.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 3, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, write to:
|
||||
# The Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# In addition, as a special exception, the copyright holders give
|
||||
# permission to link the code of portions of this program with the OpenSSL
|
||||
# library.
|
||||
# You must obey the GNU General Public License in all respects for all of
|
||||
# the code used other than OpenSSL. If you modify file(s) with this
|
||||
# exception, you may extend this exception to your version of the file(s),
|
||||
# but you are not obligated to do so. If you do not wish to do so, delete
|
||||
# this exception statement from your version. If you delete this exception
|
||||
# statement from all source files in the program, then also delete it here.
|
||||
#
|
||||
# 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.
|
||||
# See LICENSE for more details.
|
||||
#
|
||||
|
||||
#
|
||||
|
@ -51,8 +28,8 @@ print("\n\n")
|
|||
|
||||
if 0: # aclient non-core
|
||||
methods = sorted([m for m in dir(aclient) if not m.startswith('_')
|
||||
if not m in ['add_torrent_file', 'has_callback', 'get_method',
|
||||
'methodHelp', 'methodSignature', 'list_methods', 'add_torrent_file_binary']])
|
||||
if not m in ['add_torrent_file', 'has_callback', 'get_method', 'methodHelp',
|
||||
'methodSignature', 'list_methods', 'add_torrent_file_binary']])
|
||||
|
||||
for m in methods:
|
||||
func = getattr(aclient, m)
|
||||
|
@ -69,9 +46,7 @@ if 0: #aclient non-core
|
|||
|
||||
if 1: # baseclient/core
|
||||
methods = sorted([m for m in dir(Core) if m.startswith("export")]
|
||||
+ ['export_add_torrent_file_binary'] #HACK
|
||||
|
||||
)
|
||||
+ ['export_add_torrent_file_binary']) # HACK
|
||||
|
||||
for m in methods:
|
||||
|
||||
|
@ -90,7 +65,6 @@ if 1: #baseclient/core
|
|||
print("{{{\n%s\n}}}" % pydoc.getdoc(func))
|
||||
|
||||
if 0: # plugin-manager
|
||||
import WebUi
|
||||
from WebUi.pluginmanager import PluginManager
|
||||
|
||||
for m in methods:
|
||||
|
@ -115,7 +89,4 @@ if 0: #keys
|
|||
print("\n".join(textwrap.wrap(str(sorted(sclient.get_status_keys())), 100)))
|
||||
print("""}}}""")
|
||||
|
||||
|
||||
|
||||
|
||||
print("\n\n")
|
||||
|
|
|
@ -88,6 +88,7 @@ class ClientTestCase(unittest.TestCase):
|
|||
d = client.connect(
|
||||
"localhost", self.listen_port, username="", password=""
|
||||
)
|
||||
|
||||
def on_connect(result):
|
||||
self.assertEqual(client.get_auth_level(), AUTH_LEVEL_ADMIN)
|
||||
self.addCleanup(client.disconnect)
|
||||
|
|
|
@ -65,6 +65,7 @@ class TopLevelResource(Resource):
|
|||
self.putChild("ubuntu-9.04-desktop-i386.iso.torrent",
|
||||
File(common.rpath("ubuntu-9.04-desktop-i386.iso.torrent")))
|
||||
|
||||
|
||||
class CoreTestCase(unittest.TestCase):
|
||||
def setUp(self):
|
||||
common.set_tmp_config_dir()
|
||||
|
|
|
@ -1,41 +1,12 @@
|
|||
#
|
||||
# test_rpcserver.py
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2013 Bro <bro.development@gmail.com>
|
||||
#
|
||||
# Deluge is free software.
|
||||
#
|
||||
# You may redistribute it and/or modify it under the terms of the
|
||||
# GNU General Public License, as published by the Free Software
|
||||
# Foundation; either version 3 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# deluge is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with deluge. If not, write to:
|
||||
# The Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# In addition, as a special exception, the copyright holders give
|
||||
# permission to link the code of portions of this program with the OpenSSL
|
||||
# library.
|
||||
# You must obey the GNU General Public License in all respects for all of
|
||||
# the code used other than OpenSSL. If you modify file(s) with this
|
||||
# exception, you may extend this exception to your version of the file(s),
|
||||
# but you are not obligated to do so. If you do not wish to do so, delete
|
||||
# this exception statement from your version. If you delete this exception
|
||||
# statement from all source files in the program, then also delete it here.
|
||||
#
|
||||
# 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.
|
||||
# See LICENSE for more details.
|
||||
#
|
||||
|
||||
import os
|
||||
|
||||
from twisted.python import log
|
||||
from twisted.trial import unittest
|
||||
|
||||
import deluge.component as component
|
||||
|
@ -48,14 +19,15 @@ from deluge.ui.common import get_localhost_auth
|
|||
|
||||
setupLogger("none")
|
||||
|
||||
|
||||
class DelugeRPCProtocolTester(DelugeRPCProtocol):
|
||||
|
||||
messages = []
|
||||
|
||||
def transfer_message(self, data):
|
||||
import traceback
|
||||
self.messages.append(data)
|
||||
|
||||
|
||||
class RPCServerTestCase(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
|
@ -91,13 +63,7 @@ class RPCServerTestCase(unittest.TestCase):
|
|||
self.assertEquals(msg[2], data, str(msg))
|
||||
|
||||
def test_invalid_client_login(self):
|
||||
ret = self.protocol.dispatch(self.request_id, "daemon.login", [1], {})
|
||||
msg = self.protocol.messages.pop()
|
||||
self.assertEquals(msg[0], rpcserver.RPC_ERROR)
|
||||
self.assertEquals(msg[1], self.request_id)
|
||||
|
||||
def test_invalid_client_login(self):
|
||||
ret = self.protocol.dispatch(self.request_id, "daemon.login", [1], {})
|
||||
self.protocol.dispatch(self.request_id, "daemon.login", [1], {})
|
||||
msg = self.protocol.messages.pop()
|
||||
self.assertEquals(msg[0], rpcserver.RPC_ERROR)
|
||||
self.assertEquals(msg[1], self.request_id)
|
||||
|
@ -105,7 +71,7 @@ class RPCServerTestCase(unittest.TestCase):
|
|||
def test_valid_client_login(self):
|
||||
self.authmanager = AuthManager()
|
||||
auth = get_localhost_auth()
|
||||
ret = self.protocol.dispatch(self.request_id, "daemon.login", auth, {"client_version": "Test"})
|
||||
self.protocol.dispatch(self.request_id, "daemon.login", auth, {"client_version": "Test"})
|
||||
msg = self.protocol.messages.pop()
|
||||
self.assertEquals(msg[0], rpcserver.RPC_RESPONSE, str(msg))
|
||||
self.assertEquals(msg[1], self.request_id, str(msg))
|
||||
|
@ -124,7 +90,7 @@ class RPCServerTestCase(unittest.TestCase):
|
|||
self.assertEquals(msg[3][1], "AttributeError")
|
||||
|
||||
def test_daemon_info(self):
|
||||
ret = self.protocol.dispatch(self.request_id, "daemon.info", [], {})
|
||||
self.protocol.dispatch(self.request_id, "daemon.info", [], {})
|
||||
msg = self.protocol.messages.pop()
|
||||
self.assertEquals(msg[0], rpcserver.RPC_RESPONSE, str(msg))
|
||||
self.assertEquals(msg[1], self.request_id, str(msg))
|
||||
|
|
|
@ -1,36 +1,10 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# test_transfer.py
|
||||
#
|
||||
# Copyright (C) 2012 Bro <bro.development@gmail.com>
|
||||
#
|
||||
# Deluge is free software.
|
||||
#
|
||||
# You may redistribute it and/or modify it under the terms of the
|
||||
# GNU General Public License, as published by the Free Software
|
||||
# Foundation; either version 3 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# deluge is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with deluge. If not, write to:
|
||||
# The Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# In addition, as a special exception, the copyright holders give
|
||||
# permission to link the code of portions of this program with the OpenSSL
|
||||
# library.
|
||||
# You must obey the GNU General Public License in all respects for all of
|
||||
# the code used other than OpenSSL. If you modify file(s) with this
|
||||
# exception, you may extend this exception to your version of the file(s),
|
||||
# but you are not obligated to do so. If you do not wish to do so, delete
|
||||
# this exception statement from your version. If you delete this exception
|
||||
# statement from all source files in the program, then also delete it here.
|
||||
# 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.
|
||||
# See LICENSE for more details.
|
||||
#
|
||||
|
||||
from __future__ import print_function
|
||||
|
@ -113,7 +87,7 @@ class TransferTestClass(DelugeTransferProtocol):
|
|||
try:
|
||||
request = rencode.loads(dobj.decompress(data))
|
||||
print("Successfully loaded message", end=' ')
|
||||
print(" - Buffer length: %d, data length: %d, unused length: %d" % \
|
||||
print(" - Buffer length: %d, data length: %d, unused length: %d" %
|
||||
(len(data), len(data) - len(dobj.unused_data), len(dobj.unused_data)))
|
||||
print("Packet count:", self.packet_count)
|
||||
except Exception as ex:
|
||||
|
@ -286,7 +260,7 @@ class DelugeTransferProtocolTestCase(unittest.TestCase):
|
|||
expected_msgs_received_count = 0
|
||||
# Verify that the expected number of complete messages has arrived
|
||||
if expected_msgs_received_count != len(self.transfer.get_messages_in()):
|
||||
print("Expected number of messages received is %d, but %d have been received." % \
|
||||
print("Expected number of messages received is %d, but %d have been received." %
|
||||
(expected_msgs_received_count, len(self.transfer.get_messages_in())))
|
||||
|
||||
# Get the data as received by DelugeTransferProtocol
|
||||
|
|
|
@ -1,37 +1,10 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# transfer.py
|
||||
#
|
||||
# Copyright (C) 2012 Bro <bro.development@gmail.com>
|
||||
#
|
||||
# Deluge is free software.
|
||||
#
|
||||
# You may redistribute it and/or modify it under the terms of the
|
||||
# GNU General Public License, as published by the Free Software
|
||||
# Foundation; either version 3 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# deluge is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with deluge. If not, write to:
|
||||
# The Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# In addition, as a special exception, the copyright holders give
|
||||
# permission to link the code of portions of this program with the OpenSSL
|
||||
# library.
|
||||
# You must obey the GNU General Public License in all respects for all of
|
||||
# the code used other than OpenSSL. If you modify file(s) with this
|
||||
# exception, you may extend this exception to your version of the file(s),
|
||||
# but you are not obligated to do so. If you do not wish to do so, delete
|
||||
# this exception statement from your version. If you delete this exception
|
||||
# statement from all source files in the program, then also delete it here.
|
||||
#
|
||||
# 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.
|
||||
# See LICENSE for more details.
|
||||
#
|
||||
|
||||
try:
|
||||
|
@ -49,6 +22,7 @@ log = logging.getLogger(__name__)
|
|||
|
||||
MESSAGE_HEADER_SIZE = 5
|
||||
|
||||
|
||||
class DelugeTransferProtocol(Protocol):
|
||||
"""
|
||||
Data messages are transfered using very a simple protocol.
|
||||
|
|
|
@ -58,9 +58,7 @@ log = logging.getLogger(__name__)
|
|||
|
||||
|
||||
class Win32IcoFile(object):
|
||||
"""
|
||||
Decoder for Microsoft .ico files.
|
||||
"""
|
||||
"""Decoder for Microsoft .ico files."""
|
||||
|
||||
def __init__(self, buf):
|
||||
"""
|
||||
|
@ -76,53 +74,40 @@ class Win32IcoFile (object):
|
|||
|
||||
self.nb_items = header[2]
|
||||
|
||||
dir_fields = ('width', 'height', 'nb_color', 'reserved', 'planes', 'bpp',
|
||||
'size', 'offset')
|
||||
dir_fields = ('width', 'height', 'nb_color', 'reserved', 'planes', 'bpp', 'size', 'offset')
|
||||
for i in xrange(self.nb_items):
|
||||
directory = list(struct.unpack('<4B2H2I', buf.read(16)))
|
||||
for j in xrange(3):
|
||||
if not directory[j]:
|
||||
directory[j] = 256
|
||||
icon_header = dict(zip(dir_fields, directory))
|
||||
icon_header['color_depth'] = (
|
||||
icon_header['bpp'] or
|
||||
(icon_header['nb_color'] == 16 and 4))
|
||||
icon_header['color_depth'] = (icon_header['bpp'] or (icon_header['nb_color'] == 16 and 4))
|
||||
icon_header['dim'] = (icon_header['width'], icon_header['height'])
|
||||
self.entry.append(icon_header)
|
||||
#end for (read headers)
|
||||
|
||||
# order by size and color depth
|
||||
self.entry.sort(lambda x, y: \
|
||||
cmp(x['width'], y['width']) or cmp(x['color_depth'], y['color_depth']))
|
||||
self.entry.sort(lambda x, y: cmp(x['width'], y['width'])
|
||||
or cmp(x['color_depth'], y['color_depth']))
|
||||
self.entry.reverse()
|
||||
#end __init__
|
||||
|
||||
|
||||
def sizes(self):
|
||||
"""
|
||||
Get a list of all available icon sizes and color depths.
|
||||
"""
|
||||
"""Get a list of all available icon sizes and color depths."""
|
||||
return set((h['width'], h['height']) for h in self.entry)
|
||||
#end sizes
|
||||
|
||||
|
||||
def get_image(self, size, bpp=False):
|
||||
"""
|
||||
Get an image from the icon
|
||||
"""Get an image from the icon
|
||||
|
||||
Args:
|
||||
size: tuple of (width, height)
|
||||
bpp: color depth
|
||||
"""
|
||||
idx = 0
|
||||
for i in range(self.nb_items):
|
||||
h = self.entry[i]
|
||||
if size == h['dim'] and (bpp == False or bpp == h['color_depth']):
|
||||
if size == h['dim'] and (bpp is False or bpp == h['color_depth']):
|
||||
return self.frame(i)
|
||||
|
||||
return self.frame(0)
|
||||
#end get_image
|
||||
|
||||
|
||||
def frame(self, idx):
|
||||
"""
|
||||
|
@ -145,8 +130,7 @@ class Win32IcoFile (object):
|
|||
else:
|
||||
# XOR + AND mask bmp frame
|
||||
im = PIL.BmpImagePlugin.DibImageFile(self.buf)
|
||||
log.debug("Loaded image: %s %s %s %s", im.format, im.mode, im.size,
|
||||
im.info)
|
||||
log.debug("Loaded image: %s %s %s %s", im.format, im.mode, im.size, im.info)
|
||||
|
||||
# change tile dimension to only encompass XOR image
|
||||
im.size = im.size[0], im.size[1] / 2
|
||||
|
@ -196,17 +180,16 @@ class Win32IcoFile (object):
|
|||
w += 32 - (im.size[0] % 32)
|
||||
# the total mask data is padded row size * height / bits per char
|
||||
total_bytes = long((w * im.size[1]) / 8)
|
||||
log.debug("tot=%d, off=%d, w=%d, size=%d",
|
||||
len(data), and_mask_offset, w, total_bytes)
|
||||
log.debug("tot=%d, off=%d, w=%d, size=%d", len(data), and_mask_offset, w, total_bytes)
|
||||
|
||||
self.buf.seek(and_mask_offset)
|
||||
maskData = self.buf.read(total_bytes)
|
||||
mask_data = self.buf.read(total_bytes)
|
||||
|
||||
# convert raw data to image
|
||||
mask = PIL.Image.frombuffer(
|
||||
'1', # 1 bpp
|
||||
im.size, # (w, h)
|
||||
maskData, # source chars
|
||||
mask_data, # source chars
|
||||
'raw', # raw decoder
|
||||
('1;I', int(w / 8), -1) # 1bpp inverted, padded, reversed
|
||||
)
|
||||
|
@ -222,13 +205,11 @@ class Win32IcoFile (object):
|
|||
return im
|
||||
#end frame
|
||||
|
||||
|
||||
def __repr__(self):
|
||||
s = 'Microsoft Icon: %d images (max %dx%d %dbpp)' % (
|
||||
len(self.entry), self.entry[0]['width'], self.entry[0]['height'],
|
||||
self.entry[0]['bpp'])
|
||||
return s
|
||||
#end __repr__
|
||||
#end Win32IcoFile
|
||||
|
||||
|
||||
|
@ -253,7 +234,6 @@ class Win32IconImageFile (PIL.ImageFile.ImageFile):
|
|||
self.info['sizes'] = self.ico.sizes()
|
||||
self.size = self.ico.entry[0]['dim']
|
||||
self.load()
|
||||
#end _open
|
||||
|
||||
def load(self):
|
||||
im = self.ico.get_image(self.size)
|
||||
|
@ -262,7 +242,6 @@ class Win32IconImageFile (PIL.ImageFile.ImageFile):
|
|||
self.im = im.im
|
||||
self.mode = im.mode
|
||||
self.size = im.size
|
||||
#end load
|
||||
#end class Win32IconImageFile
|
||||
|
||||
|
||||
|
|
|
@ -1,37 +1,11 @@
|
|||
#
|
||||
# client.py
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2009 Andrew Resch <andrewresch@gmail.com>
|
||||
# Copyright (C) 2011 Pedro Algarvio <pedro@algarvio.me>
|
||||
#
|
||||
# Deluge is free software.
|
||||
#
|
||||
# You may redistribute it and/or modify it under the terms of the
|
||||
# GNU General Public License, as published by the Free Software
|
||||
# Foundation; either version 3 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# deluge is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with deluge. If not, write to:
|
||||
# The Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# In addition, as a special exception, the copyright holders give
|
||||
# permission to link the code of portions of this program with the OpenSSL
|
||||
# library.
|
||||
# You must obey the GNU General Public License in all respects for all of
|
||||
# the code used other than OpenSSL. If you modify file(s) with this
|
||||
# exception, you may extend this exception to your version of the file(s),
|
||||
# but you are not obligated to do so. If you do not wish to do so, delete
|
||||
# this exception statement from your version. If you delete this exception
|
||||
# statement from all source files in the program, then also delete it here.
|
||||
#
|
||||
# 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.
|
||||
# See LICENSE for more details.
|
||||
#
|
||||
|
||||
import logging
|
||||
|
@ -43,7 +17,6 @@ from twisted.internet.protocol import ClientFactory
|
|||
|
||||
import deluge.common
|
||||
from deluge import error
|
||||
from deluge.event import known_events
|
||||
from deluge.transfer import DelugeTransferProtocol
|
||||
from deluge.ui.common import get_localhost_auth
|
||||
|
||||
|
@ -53,6 +26,7 @@ RPC_EVENT = 3
|
|||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def format_kwargs(kwargs):
|
||||
return ", ".join([key + "=" + str(value) for key, value in kwargs.items()])
|
||||
|
||||
|
@ -91,10 +65,8 @@ class DelugeRPCRequest(object):
|
|||
|
||||
:returns: a properly formated RPCRequest
|
||||
"""
|
||||
if self.request_id is None or self.method is None or self.args is None \
|
||||
or self.kwargs is None:
|
||||
raise TypeError("You must set the properties of this object "
|
||||
"before calling format_message!")
|
||||
if self.request_id is None or self.method is None or self.args is None or self.kwargs is None:
|
||||
raise TypeError("You must set the properties of this object before calling format_message!")
|
||||
|
||||
return (self.request_id, self.method, self.args, self.kwargs)
|
||||
|
||||
|
@ -156,7 +128,7 @@ class DelugeRPCProtocol(DelugeTransferProtocol):
|
|||
try:
|
||||
exception_cls = getattr(error, request[2])
|
||||
exception = exception_cls(*request[3], **request[4])
|
||||
except TypeError as err:
|
||||
except TypeError:
|
||||
log.warn("Received invalid RPC_ERROR (Old daemon?): %s", request[2])
|
||||
return
|
||||
|
||||
|
@ -189,7 +161,8 @@ class DelugeRPCProtocol(DelugeTransferProtocol):
|
|||
log.debug(msg)
|
||||
except:
|
||||
import traceback
|
||||
log.error("Failed to handle RPC_ERROR (Old daemon?): %s\nLocal error: %s", request[2], traceback.format_exc())
|
||||
log.error("Failed to handle RPC_ERROR (Old daemon?): %s\nLocal error: %s",
|
||||
request[2], traceback.format_exc())
|
||||
d.errback(exception)
|
||||
del self.__rpc_requests[request_id]
|
||||
|
||||
|
@ -211,6 +184,7 @@ class DelugeRPCProtocol(DelugeTransferProtocol):
|
|||
except Exception as ex:
|
||||
log.warn("Error occurred when sending message: %s", ex)
|
||||
|
||||
|
||||
class DelugeRPCClientFactory(ClientFactory):
|
||||
protocol = DelugeRPCProtocol
|
||||
|
||||
|
@ -240,9 +214,11 @@ class DelugeRPCClientFactory(ClientFactory):
|
|||
if self.daemon.disconnect_callback:
|
||||
self.daemon.disconnect_callback()
|
||||
|
||||
|
||||
class DaemonProxy(object):
|
||||
pass
|
||||
|
||||
|
||||
class DaemonSSLProxy(DaemonProxy):
|
||||
def __init__(self, event_handlers=None):
|
||||
if event_handlers is None:
|
||||
|
@ -445,6 +421,7 @@ class DaemonSSLProxy(DaemonProxy):
|
|||
def get_bytes_sent(self):
|
||||
return self.protocol.get_bytes_sent()
|
||||
|
||||
|
||||
class DaemonClassicProxy(DaemonProxy):
|
||||
def __init__(self, event_handlers=None):
|
||||
if event_handlers is None:
|
||||
|
@ -513,6 +490,7 @@ class DaemonClassicProxy(DaemonProxy):
|
|||
"""
|
||||
self.__daemon.core.eventmanager.deregister_event_handler(event, handler)
|
||||
|
||||
|
||||
class DottedObject(object):
|
||||
"""
|
||||
This is used for dotted name calls to client
|
||||
|
@ -527,6 +505,7 @@ class DottedObject(object):
|
|||
def __getattr__(self, name):
|
||||
return RemoteMethod(self.daemon, self.base + "." + name)
|
||||
|
||||
|
||||
class RemoteMethod(DottedObject):
|
||||
"""
|
||||
This is used when something like 'client.core.get_something()' is attempted.
|
||||
|
@ -534,6 +513,7 @@ class RemoteMethod(DottedObject):
|
|||
def __call__(self, *args, **kwargs):
|
||||
return self.daemon.call(self.base, *args, **kwargs)
|
||||
|
||||
|
||||
class Client(object):
|
||||
"""
|
||||
This class is used to connect to a daemon process and issue RPC requests.
|
||||
|
@ -650,7 +630,7 @@ class Client(object):
|
|||
that you forgot to install the deluged package or it's not in your PATH."))
|
||||
else:
|
||||
log.exception(ex)
|
||||
raise e
|
||||
raise ex
|
||||
except Exception as ex:
|
||||
log.error("Unable to start daemon!")
|
||||
log.exception(ex)
|
||||
|
@ -665,8 +645,8 @@ that you forgot to install the deluged package or it's not in your PATH."))
|
|||
:returns: bool, True if connected to a localhost
|
||||
|
||||
"""
|
||||
if self._daemon_proxy and self._daemon_proxy.host in ("127.0.0.1", "localhost") or\
|
||||
isinstance(self._daemon_proxy, DaemonClassicProxy):
|
||||
if (self._daemon_proxy and self._daemon_proxy.host in ("127.0.0.1", "localhost") or
|
||||
isinstance(self._daemon_proxy, DaemonClassicProxy)):
|
||||
return True
|
||||
return False
|
||||
|
||||
|
|
|
@ -1,41 +1,15 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# deluge/ui/common.py
|
||||
#
|
||||
# Copyright (C) Damien Churchill 2008-2009 <damoxc@gmail.com>
|
||||
# Copyright (C) Andrew Resch 2009 <andrewresch@gmail.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 3, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, write to:
|
||||
# The Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# In addition, as a special exception, the copyright holders give
|
||||
# permission to link the code of portions of this program with the OpenSSL
|
||||
# library.
|
||||
# You must obey the GNU General Public License in all respects for all of
|
||||
# the code used other than OpenSSL. If you modify file(s) with this
|
||||
# exception, you may extend this exception to your version of the file(s),
|
||||
# but you are not obligated to do so. If you do not wish to do so, delete
|
||||
# this exception statement from your version. If you delete this exception
|
||||
# statement from all source files in the program, then also delete it here.
|
||||
#
|
||||
# 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.
|
||||
# See LICENSE for more details.
|
||||
#
|
||||
|
||||
"""
|
||||
The ui common module contains methods and classes that are deemed useful for
|
||||
all the interfaces.
|
||||
The ui common module contains methods and classes that are deemed useful for all the interfaces.
|
||||
"""
|
||||
|
||||
import logging
|
||||
|
@ -125,7 +99,8 @@ class TorrentInfo(object):
|
|||
path = os.path.join(prefix, *f["path.utf-8"])
|
||||
del f["path.utf-8"]
|
||||
else:
|
||||
path = utf8_encoded(os.path.join(prefix, utf8_encoded(os.path.join(*f["path"]), self.encoding)), self.encoding)
|
||||
path = utf8_encoded(os.path.join(prefix, utf8_encoded(os.path.join(*f["path"]),
|
||||
self.encoding)), self.encoding)
|
||||
f["path"] = path
|
||||
f["index"] = index
|
||||
if "sha1" in f and len(f["sha1"]) == 20:
|
||||
|
@ -267,6 +242,7 @@ class TorrentInfo(object):
|
|||
"""
|
||||
return self.__m_filedata
|
||||
|
||||
|
||||
class FileTree2(object):
|
||||
"""
|
||||
Converts a list of paths in to a file tree.
|
||||
|
@ -328,16 +304,17 @@ class FileTree2(object):
|
|||
for path in directory["contents"].keys():
|
||||
full_path = path_join(parent_path, path)
|
||||
if directory["contents"][path]["type"] == "dir":
|
||||
directory["contents"][path] = callback(full_path, directory["contents"][path]) or \
|
||||
directory["contents"][path]
|
||||
directory["contents"][path] = callback(full_path, directory["contents"][path]
|
||||
) or directory["contents"][path]
|
||||
walk(directory["contents"][path], full_path)
|
||||
else:
|
||||
directory["contents"][path] = callback(full_path, directory["contents"][path]) or \
|
||||
directory["contents"][path]
|
||||
directory["contents"][path] = callback(full_path, directory["contents"][path]
|
||||
) or directory["contents"][path]
|
||||
walk(self.tree, "")
|
||||
|
||||
def __str__(self):
|
||||
lines = []
|
||||
|
||||
def write(path, item):
|
||||
depth = path.count("/")
|
||||
path = os.path.basename(path)
|
||||
|
@ -346,6 +323,7 @@ class FileTree2(object):
|
|||
self.walk(write)
|
||||
return "\n".join(lines)
|
||||
|
||||
|
||||
class FileTree(object):
|
||||
"""
|
||||
Convert a list of paths in a file tree.
|
||||
|
@ -404,16 +382,15 @@ class FileTree(object):
|
|||
for path in directory.keys():
|
||||
full_path = os.path.join(parent_path, path)
|
||||
if type(directory[path]) is dict:
|
||||
directory[path] = callback(full_path, directory[path]) or \
|
||||
directory[path]
|
||||
directory[path] = callback(full_path, directory[path]) or directory[path]
|
||||
walk(directory[path], full_path)
|
||||
else:
|
||||
directory[path] = callback(full_path, directory[path]) or \
|
||||
directory[path]
|
||||
directory[path] = callback(full_path, directory[path]) or directory[path]
|
||||
walk(self.tree, "")
|
||||
|
||||
def __str__(self):
|
||||
lines = []
|
||||
|
||||
def write(path, item):
|
||||
depth = path.count("/")
|
||||
path = os.path.basename(path)
|
||||
|
@ -422,6 +399,7 @@ class FileTree(object):
|
|||
self.walk(write)
|
||||
return "\n".join(lines)
|
||||
|
||||
|
||||
def get_localhost_auth():
|
||||
"""
|
||||
Grabs the localclient auth line from the 'auth' file and creates a localhost uri
|
||||
|
|
|
@ -1,38 +1,11 @@
|
|||
#
|
||||
# coreconfig.py
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2008 Andrew Resch <andrewresch@gmail.com>
|
||||
#
|
||||
# Deluge is free software.
|
||||
# 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.
|
||||
# See LICENSE for more details.
|
||||
#
|
||||
# You may redistribute it and/or modify it under the terms of the
|
||||
# GNU General Public License, as published by the Free Software
|
||||
# Foundation; either version 3 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# deluge is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with deluge. If not, write to:
|
||||
# The Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# In addition, as a special exception, the copyright holders give
|
||||
# permission to link the code of portions of this program with the OpenSSL
|
||||
# library.
|
||||
# You must obey the GNU General Public License in all respects for all of
|
||||
# the code used other than OpenSSL. If you modify file(s) with this
|
||||
# exception, you may extend this exception to your version of the file(s),
|
||||
# but you are not obligated to do so. If you do not wish to do so, delete
|
||||
# this exception statement from your version. If you delete this exception
|
||||
# statement from all source files in the program, then also delete it here.
|
||||
#
|
||||
#
|
||||
|
||||
|
||||
import logging
|
||||
|
||||
|
@ -41,11 +14,13 @@ from deluge.ui.client import client
|
|||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class CoreConfig(component.Component):
|
||||
def __init__(self):
|
||||
log.debug("CoreConfig init..")
|
||||
component.Component.__init__(self, "CoreConfig")
|
||||
self.config = {}
|
||||
|
||||
def on_configvaluechanged_event(key, value):
|
||||
self.config[key] = value
|
||||
client.register_event_handler("ConfigValueChangedEvent", on_configvaluechanged_event)
|
||||
|
|
|
@ -1,38 +1,13 @@
|
|||
#
|
||||
# sessionproxy.py
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2010 Andrew Resch <andrewresch@gmail.com>
|
||||
#
|
||||
# Deluge is free software.
|
||||
#
|
||||
# You may redistribute it and/or modify it under the terms of the
|
||||
# GNU General Public License, as published by the Free Software
|
||||
# Foundation; either version 3 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# deluge is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with deluge. If not, write to:
|
||||
# The Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# In addition, as a special exception, the copyright holders give
|
||||
# permission to link the code of portions of this program with the OpenSSL
|
||||
# library.
|
||||
# You must obey the GNU General Public License in all respects for all of
|
||||
# the code used other than OpenSSL. If you modify file(s) with this
|
||||
# exception, you may extend this exception to your version of the file(s),
|
||||
# but you are not obligated to do so. If you do not wish to do so, delete
|
||||
# this exception statement from your version. If you delete this exception
|
||||
# statement from all source files in the program, then also delete it here.
|
||||
#
|
||||
# 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.
|
||||
# See LICENSE for more details.
|
||||
#
|
||||
|
||||
|
||||
import logging
|
||||
import time
|
||||
|
||||
|
@ -43,6 +18,7 @@ from deluge.ui.client import client
|
|||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class SessionProxy(component.Component):
|
||||
"""
|
||||
The SessionProxy component is used to cache session information client-side
|
||||
|
@ -161,6 +137,7 @@ class SessionProxy(component.Component):
|
|||
)
|
||||
else:
|
||||
d = client.core.get_torrent_status(torrent_id, keys_to_get, True)
|
||||
|
||||
def on_status(result, torrent_id):
|
||||
t = time.time()
|
||||
self.torrents[torrent_id][0] = t
|
||||
|
@ -171,6 +148,7 @@ class SessionProxy(component.Component):
|
|||
return d.addCallback(on_status, torrent_id)
|
||||
else:
|
||||
d = client.core.get_torrent_status(torrent_id, keys, True)
|
||||
|
||||
def on_status(result):
|
||||
if result:
|
||||
t = time.time()
|
||||
|
@ -247,7 +225,6 @@ class SessionProxy(component.Component):
|
|||
# Don't need to fetch anything
|
||||
return maybeDeferred(self.create_status_dict, self.torrents.keys(), keys)
|
||||
|
||||
|
||||
if len(filter_dict) == 1 and "id" in filter_dict:
|
||||
# At this point we should have a filter with just "id" in it
|
||||
to_fetch = find_torrents_to_fetch(filter_dict["id"])
|
||||
|
@ -271,6 +248,7 @@ class SessionProxy(component.Component):
|
|||
def on_torrent_added(self, torrent_id, from_state):
|
||||
self.torrents[torrent_id] = [time.time() - self.cache_time - 1, {}]
|
||||
self.cache_times[torrent_id] = {}
|
||||
|
||||
def on_status(status):
|
||||
self.torrents[torrent_id][1].update(status)
|
||||
t = time.time()
|
||||
|
|
|
@ -1,36 +1,10 @@
|
|||
#
|
||||
# tracker_icons.py
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2010 John Garland <johnnybg+deluge@gmail.com>
|
||||
#
|
||||
# Deluge is free software.
|
||||
#
|
||||
# You may redistribute it and/or modify it under the terms of the
|
||||
# GNU General Public License, as published by the Free Software
|
||||
# Foundation; either version 3 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# deluge is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with deluge. If not, write to:
|
||||
# The Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# In addition, as a special exception, the copyright holders give
|
||||
# permission to link the code of portions of this program with the OpenSSL
|
||||
# library.
|
||||
# You must obey the GNU General Public License in all respects for all of
|
||||
# the code used other than OpenSSL. If you modify file(s) with this
|
||||
# exception, you may extend this exception to your version of the file(s),
|
||||
# but you are not obligated to do so. If you do not wish to do so, delete
|
||||
# this exception statement from your version. If you delete this exception
|
||||
# statement from all source files in the program, then also delete it here.
|
||||
#
|
||||
# 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.
|
||||
# See LICENSE for more details.
|
||||
#
|
||||
|
||||
import logging
|
||||
|
@ -53,11 +27,10 @@ except ImportError:
|
|||
# twisted 8
|
||||
from twisted.web.error import NoResource, ForbiddenResource
|
||||
|
||||
|
||||
|
||||
try:
|
||||
import PIL.Image as Image
|
||||
import deluge.ui.Win32IconImagePlugin
|
||||
assert deluge.ui.Win32IconImagePlugin # silence pyflakes
|
||||
except ImportError:
|
||||
PIL_INSTALLED = False
|
||||
else:
|
||||
|
@ -65,6 +38,7 @@ else:
|
|||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class TrackerIcon(object):
|
||||
"""
|
||||
Represents a tracker's icon
|
||||
|
@ -77,7 +51,7 @@ class TrackerIcon(object):
|
|||
:type filename: string
|
||||
"""
|
||||
self.filename = os.path.abspath(filename)
|
||||
self.mimetype = extension_to_mimetype(self.filename.rpartition('.')[2])
|
||||
self.mimetype = extension_to_mimetype(self.filename.rpartition(".")[2])
|
||||
self.data = None
|
||||
self.icon_cache = None
|
||||
|
||||
|
@ -90,9 +64,9 @@ class TrackerIcon(object):
|
|||
:returns: whether or not they're equal
|
||||
:rtype: boolean
|
||||
"""
|
||||
return os.path.samefile(self.filename, other.filename) or \
|
||||
self.get_mimetype() == other.get_mimetype() and \
|
||||
self.get_data() == other.get_data()
|
||||
return (os.path.samefile(self.filename, other.filename) or
|
||||
self.get_mimetype() == other.get_mimetype() and
|
||||
self.get_data() == other.get_data())
|
||||
|
||||
def get_mimetype(self):
|
||||
"""
|
||||
|
@ -142,6 +116,7 @@ class TrackerIcon(object):
|
|||
"""
|
||||
return self.icon_cache
|
||||
|
||||
|
||||
class TrackerIcons(Component):
|
||||
"""
|
||||
A TrackerIcon factory class
|
||||
|
@ -175,7 +150,7 @@ class TrackerIcons(Component):
|
|||
self.icons[None] = TrackerIcon(no_icon)
|
||||
else:
|
||||
self.icons[None] = None
|
||||
self.icons[''] = self.icons[None]
|
||||
self.icons[""] = self.icons[None]
|
||||
|
||||
self.pending = {}
|
||||
self.redirects = {}
|
||||
|
@ -433,7 +408,7 @@ class TrackerIcons(Component):
|
|||
if f.check(PageRedirect):
|
||||
# Handle redirect errors
|
||||
location = urljoin(self.host_to_url(host), error_msg.split(" to ")[1])
|
||||
d = self.download_icon([(location, extension_to_mimetype(location.rpartition('.')[2]))] + icons, host)
|
||||
d = self.download_icon([(location, extension_to_mimetype(location.rpartition(".")[2]))] + icons, host)
|
||||
if not icons:
|
||||
d.addCallbacks(self.on_download_icon_complete, self.on_download_icon_fail,
|
||||
callbackArgs=(host,), errbackArgs=(host,))
|
||||
|
@ -441,7 +416,8 @@ class TrackerIcons(Component):
|
|||
d = self.download_icon(icons, host)
|
||||
elif f.check(NoIconsError, HTMLParseError):
|
||||
# No icons, try favicon.ico as an act of desperation
|
||||
d = self.download_icon([(urljoin(self.host_to_url(host), "favicon.ico"), extension_to_mimetype("ico"))], host)
|
||||
d = self.download_icon([(urljoin(self.host_to_url(host), "favicon.ico"),
|
||||
extension_to_mimetype("ico"))], host)
|
||||
d.addCallbacks(self.on_download_icon_complete, self.on_download_icon_fail,
|
||||
callbackArgs=(host,), errbackArgs=(host,))
|
||||
else:
|
||||
|
@ -465,7 +441,7 @@ class TrackerIcons(Component):
|
|||
filename = icon.get_filename()
|
||||
img = Image.open(filename)
|
||||
if img.size > (16, 16):
|
||||
new_filename = filename.rpartition('.')[0]+".png"
|
||||
new_filename = filename.rpartition(".")[0] + ".png"
|
||||
img = img.resize((16, 16), Image.ANTIALIAS)
|
||||
img.save(new_filename)
|
||||
if new_filename != filename:
|
||||
|
@ -506,6 +482,7 @@ class TrackerIcons(Component):
|
|||
|
||||
################################ HELPER CLASSES ###############################
|
||||
|
||||
|
||||
class FaviconParser(HTMLParser):
|
||||
"""
|
||||
A HTMLParser which extracts favicons from a HTML page
|
||||
|
@ -526,7 +503,7 @@ class FaviconParser(HTMLParser):
|
|||
type = value
|
||||
if href:
|
||||
try:
|
||||
mimetype = extension_to_mimetype(href.rpartition('.')[2])
|
||||
mimetype = extension_to_mimetype(href.rpartition(".")[2])
|
||||
except KeyError:
|
||||
pass
|
||||
else:
|
||||
|
@ -561,6 +538,7 @@ def url_to_host(url):
|
|||
"""
|
||||
return urlparse(url).hostname
|
||||
|
||||
|
||||
def host_to_icon_name(host, mimetype):
|
||||
"""
|
||||
Given a host, returns the appropriate icon name
|
||||
|
@ -573,7 +551,8 @@ def host_to_icon_name(host, mimetype):
|
|||
:rtype: string
|
||||
|
||||
"""
|
||||
return host+'.'+mimetype_to_extension(mimetype)
|
||||
return host + "." + mimetype_to_extension(mimetype)
|
||||
|
||||
|
||||
def icon_name_to_host(icon):
|
||||
"""
|
||||
|
@ -584,7 +563,7 @@ def icon_name_to_host(icon):
|
|||
:returns: the host name
|
||||
:rtype: string
|
||||
"""
|
||||
return icon.rpartition('.')[0]
|
||||
return icon.rpartition(".")[0]
|
||||
|
||||
MIME_MAP = {
|
||||
"image/gif": "gif",
|
||||
|
@ -599,6 +578,7 @@ MIME_MAP = {
|
|||
"ico": "image/vnd.microsoft.icon",
|
||||
}
|
||||
|
||||
|
||||
def mimetype_to_extension(mimetype):
|
||||
"""
|
||||
Given a mimetype, returns the appropriate filename extension
|
||||
|
@ -611,6 +591,7 @@ def mimetype_to_extension(mimetype):
|
|||
"""
|
||||
return MIME_MAP[mimetype.lower()]
|
||||
|
||||
|
||||
def extension_to_mimetype(extension):
|
||||
"""
|
||||
Given a filename extension, returns the appropriate mimetype
|
||||
|
@ -625,8 +606,10 @@ def extension_to_mimetype(extension):
|
|||
|
||||
################################## EXCEPTIONS #################################
|
||||
|
||||
|
||||
class NoIconsError(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class InvalidIconError(Exception):
|
||||
pass
|
||||
|
|
|
@ -1,36 +1,10 @@
|
|||
#
|
||||
# ui.py
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2007 Andrew Resch <andrewresch@gmail.com>
|
||||
#
|
||||
# Deluge is free software.
|
||||
#
|
||||
# You may redistribute it and/or modify it under the terms of the
|
||||
# GNU General Public License, as published by the Free Software
|
||||
# Foundation; either version 3 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# deluge is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with deluge. If not, write to:
|
||||
# The Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# In addition, as a special exception, the copyright holders give
|
||||
# permission to link the code of portions of this program with the OpenSSL
|
||||
# library.
|
||||
# You must obey the GNU General Public License in all respects for all of
|
||||
# the code used other than OpenSSL. If you modify file(s) with this
|
||||
# exception, you may extend this exception to your version of the file(s),
|
||||
# but you are not obligated to do so. If you do not wish to do so, delete
|
||||
# this exception statement from your version. If you delete this exception
|
||||
# statement from all source files in the program, then also delete it here.
|
||||
#
|
||||
# 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.
|
||||
# See LICENSE for more details.
|
||||
#
|
||||
|
||||
from __future__ import print_function
|
||||
|
@ -77,16 +51,13 @@ class _UI(object):
|
|||
self.__parser.add_option("-v", "--version", action="callback", callback=version_callback,
|
||||
help="Show program's version number and exit")
|
||||
group = OptionGroup(self.__parser, "Common Options")
|
||||
group.add_option("-c", "--config", dest="config",
|
||||
help="Set the config folder location", action="store", type="str")
|
||||
group.add_option("-l", "--logfile", dest="logfile",
|
||||
help="Output to designated logfile instead of stdout", action="store", type="str")
|
||||
group.add_option("-c", "--config", dest="config", help="Set the config folder location")
|
||||
group.add_option("-l", "--logfile", dest="logfile", help="Output to designated logfile instead of stdout")
|
||||
group.add_option("-L", "--loglevel", dest="loglevel",
|
||||
help="Set the log level: none, info, warning, error, critical, debug", action="store", type="str")
|
||||
group.add_option("-q", "--quiet", dest="quiet",
|
||||
help="Sets the log level to 'none', this is the same as `-L none`", action="store_true", default=False)
|
||||
group.add_option("-r", "--rotate-logs",
|
||||
help="Rotate logfiles.", action="store_true", default=False)
|
||||
help="Set the log level: none, info, warning, error, critical, debug")
|
||||
group.add_option("-q", "--quiet", dest="quiet", action="store_true", default=False,
|
||||
help="Sets the log level to 'none', this is the same as `-L none`")
|
||||
group.add_option("-r", "--rotate-logs", help="Rotate logfiles.", action="store_true", default=False)
|
||||
self.__parser.add_option_group(group)
|
||||
|
||||
@property
|
||||
|
@ -171,15 +142,15 @@ class UI:
|
|||
if selected_ui == "gtk":
|
||||
log.info("Starting GtkUI..")
|
||||
from deluge.ui.gtkui.gtkui import GtkUI
|
||||
ui = GtkUI(args)
|
||||
GtkUI(args)
|
||||
elif selected_ui == "web":
|
||||
log.info("Starting WebUI..")
|
||||
from deluge.ui.web.web import WebUI
|
||||
ui = WebUI(args)
|
||||
WebUI(args)
|
||||
elif selected_ui == "console":
|
||||
log.info("Starting ConsoleUI..")
|
||||
from deluge.ui.console.main import ConsoleUI
|
||||
ui = ConsoleUI(ui_args)
|
||||
ConsoleUI(ui_args)
|
||||
except ImportError as ex:
|
||||
import sys
|
||||
import traceback
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
from web import start
|
||||
assert start # silence pyflakes
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
#
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
from version import get_version
|
||||
from subprocess import call
|
||||
from datetime import datetime
|
||||
|
|
|
@ -17,3 +17,4 @@ frameworks = CoreFoundation, Foundation, AppKit
|
|||
[flake8]
|
||||
max-line-length = 120
|
||||
builtins = _
|
||||
ignore = N802
|
||||
|
|
44
setup.py
44
setup.py
|
@ -23,11 +23,11 @@
|
|||
#
|
||||
|
||||
try:
|
||||
from setuptools import setup, find_packages, Extension
|
||||
from setuptools import setup, find_packages
|
||||
except ImportError:
|
||||
import ez_setup
|
||||
ez_setup.use_setuptools()
|
||||
from setuptools import setup, find_packages, Extension
|
||||
from setuptools import setup, find_packages
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
@ -37,7 +37,7 @@ import glob
|
|||
|
||||
from version import get_version
|
||||
|
||||
from distutils import cmd, sysconfig
|
||||
from distutils import cmd
|
||||
from distutils.command.build import build as _build
|
||||
from distutils.command.clean import clean as _clean
|
||||
|
||||
|
@ -53,6 +53,7 @@ def windows_check():
|
|||
|
||||
desktop_data = 'deluge/ui/data/share/applications/deluge.desktop'
|
||||
|
||||
|
||||
class build_trans(cmd.Command):
|
||||
description = 'Compile .po files into .mo files & create .desktop file'
|
||||
|
||||
|
@ -79,17 +80,17 @@ class build_trans(cmd.Command):
|
|||
|
||||
if not windows_check():
|
||||
# creates the translated desktop file
|
||||
INTLTOOL_MERGE='intltool-merge'
|
||||
INTLTOOL_MERGE_OPTS='--utf8 --quiet --desktop-style'
|
||||
intltool_merge = 'intltool-merge'
|
||||
intltool_merge_opts = '--utf8 --quiet --desktop-style'
|
||||
desktop_in = 'deluge/ui/data/share/applications/deluge.desktop.in'
|
||||
print('Creating desktop file: %s' % desktop_data)
|
||||
os.system('C_ALL=C ' + '%s '*5 % (INTLTOOL_MERGE, INTLTOOL_MERGE_OPTS, \
|
||||
os.system('C_ALL=C ' + '%s ' * 5 % (intltool_merge, intltool_merge_opts,
|
||||
po_dir, desktop_in, desktop_data))
|
||||
|
||||
print('Compiling po files from %s...' % po_dir),
|
||||
for path, names, filenames in os.walk(po_dir):
|
||||
for f in filenames:
|
||||
uptoDate = False
|
||||
upto_date = False
|
||||
if f.endswith('.po'):
|
||||
lang = f[:len(f) - 3]
|
||||
src = os.path.join(path, f)
|
||||
|
@ -109,9 +110,9 @@ class build_trans(cmd.Command):
|
|||
sys.stdout.flush()
|
||||
msgfmt.make(src, dest)
|
||||
else:
|
||||
uptoDate = True
|
||||
upto_date = True
|
||||
|
||||
if uptoDate:
|
||||
if upto_date:
|
||||
sys.stdout.write(' po files already upto date. ')
|
||||
sys.stdout.write('\b\b \nFinished compiling translation files. \n')
|
||||
|
||||
|
@ -134,12 +135,13 @@ class build_plugins(cmd.Command):
|
|||
|
||||
def run(self):
|
||||
# Build the plugin eggs
|
||||
PLUGIN_PATH = "deluge/plugins/*"
|
||||
plugin_path = "deluge/plugins/*"
|
||||
|
||||
for path in glob.glob(PLUGIN_PATH):
|
||||
for path in glob.glob(plugin_path):
|
||||
if os.path.exists(os.path.join(path, "setup.py")):
|
||||
if self.develop and self.install_dir:
|
||||
os.system("cd " + path + "&& " + sys.executable + " setup.py develop --install-dir=%s" % self.install_dir)
|
||||
os.system("cd " + path + "&& " + sys.executable +
|
||||
" setup.py develop --install-dir=%s" % self.install_dir)
|
||||
elif self.develop:
|
||||
os.system("cd " + path + "&& " + sys.executable + " setup.py develop")
|
||||
else:
|
||||
|
@ -159,9 +161,9 @@ class egg_info_plugins(cmd.Command):
|
|||
|
||||
def run(self):
|
||||
# Build the plugin eggs
|
||||
PLUGIN_PATH = "deluge/plugins/*"
|
||||
plugin_path = "deluge/plugins/*"
|
||||
|
||||
for path in glob.glob(PLUGIN_PATH):
|
||||
for path in glob.glob(plugin_path):
|
||||
if os.path.exists(os.path.join(path, "setup.py")):
|
||||
os.system("cd " + path + "&& " + sys.executable + " setup.py egg_info")
|
||||
|
||||
|
@ -188,6 +190,7 @@ class build_docs(BuildDoc):
|
|||
return " "
|
||||
|
||||
old_import = __builtins__.__import__
|
||||
|
||||
def new_import(name, globals={}, locals={}, fromlist=[], level=-1):
|
||||
try:
|
||||
return old_import(name, globals, locals, fromlist, level)
|
||||
|
@ -205,6 +208,7 @@ class build_docs(BuildDoc):
|
|||
|
||||
class build(_build):
|
||||
sub_commands = [('build_trans', None), ('build_plugins', None)] + _build.sub_commands
|
||||
|
||||
def run(self):
|
||||
# Run all sub-commands (at least those that need to be run)
|
||||
_build.run(self)
|
||||
|
@ -231,9 +235,9 @@ class clean_plugins(cmd.Command):
|
|||
def run(self):
|
||||
print("Cleaning the plugin's folders..")
|
||||
|
||||
PLUGIN_PATH = "deluge/plugins/*"
|
||||
plugin_path = "deluge/plugins/*"
|
||||
|
||||
for path in glob.glob(PLUGIN_PATH):
|
||||
for path in glob.glob(plugin_path):
|
||||
if os.path.exists(os.path.join(path, "setup.py")):
|
||||
c = "cd " + path + "&& " + sys.executable + " setup.py clean"
|
||||
if self.all:
|
||||
|
@ -245,9 +249,9 @@ class clean_plugins(cmd.Command):
|
|||
print("Deleting %s" % path)
|
||||
os.remove(path)
|
||||
|
||||
EGG_INFO_DIR_PATH = "deluge/plugins/*/*.egg-info"
|
||||
egg_info_dir_path = "deluge/plugins/*/*.egg-info"
|
||||
|
||||
for path in glob.glob(EGG_INFO_DIR_PATH):
|
||||
for path in glob.glob(egg_info_dir_path):
|
||||
# Delete the .egg-info's directories
|
||||
if path[-9:] == ".egg-info":
|
||||
print("Deleting %s" % path)
|
||||
|
@ -255,9 +259,9 @@ class clean_plugins(cmd.Command):
|
|||
os.remove(os.path.join(path, fpath))
|
||||
os.removedirs(path)
|
||||
|
||||
ROOT_EGG_INFO_DIR_PATH = "deluge*.egg-info"
|
||||
root_egg_info_dir_path = "deluge*.egg-info"
|
||||
|
||||
for path in glob.glob(ROOT_EGG_INFO_DIR_PATH):
|
||||
for path in glob.glob(root_egg_info_dir_path):
|
||||
print("Deleting %s" % path)
|
||||
for fpath in os.listdir(path):
|
||||
os.remove(os.path.join(path, fpath))
|
||||
|
|
16
version.py
16
version.py
|
@ -35,18 +35,20 @@ __all__ = ("get_version")
|
|||
from subprocess import Popen, PIPE
|
||||
VERSION_FILE = "RELEASE-VERSION"
|
||||
|
||||
def call_git_describe(prefix='', suffix=''):
|
||||
cmd = 'git describe --tags --match %s[0-9]*' % prefix
|
||||
|
||||
def call_git_describe(prefix="", suffix=""):
|
||||
cmd = "git describe --tags --match %s[0-9]*" % prefix
|
||||
try:
|
||||
version = Popen(cmd.split(), stdout=PIPE).communicate()[0]
|
||||
version = version.strip().replace(prefix, '')
|
||||
if '-' in version:
|
||||
version = '.dev'.join(version.replace(suffix,'').split('-')[:2])
|
||||
version = version.strip().replace(prefix, "")
|
||||
if "-" in version:
|
||||
version = ".dev".join(version.replace(suffix, "").split("-")[:2])
|
||||
return version
|
||||
except:
|
||||
return None
|
||||
|
||||
def get_version(prefix='', suffix=''):
|
||||
|
||||
def get_version(prefix="", suffix=""):
|
||||
try:
|
||||
with open(VERSION_FILE, "r") as f:
|
||||
release_version = f.readline().strip()
|
||||
|
@ -67,4 +69,4 @@ def get_version(prefix='', suffix=''):
|
|||
return version
|
||||
|
||||
if __name__ == "__main__":
|
||||
print get_version(prefix='deluge-', suffix='.dev0')
|
||||
print get_version(prefix="deluge-", suffix=".dev0")
|
||||
|
|
Loading…
Reference in New Issue