Swhiched the old style logging, ie, a single logger for all logging output to several loggers. This brings the ability to tweak the logging levels for each of the loggers, ie, we can have the "deluge" logger be at the ERROR level while having "deluge.core" at the DEBUG level, meaning we will only see log message for all of the deluge loggers above the ERROR level while still having all messages above the DEBUG level for the "deluge.core" logger and it's children. This kind of tweak can be achieved by adding a file named "logging.conf" to deluge's config dir and this is explained on the deluge.log.tweak_logging_levels function.

Passing `-r` to the cli's while also passing `-l` will make the logfile rotate when reaching 5Mb in size. Three backups will be kept at all times.
All deluge's code is now using this new style logging along with the git hosted plugins. For other plugins not hosted by deluge, which still imports `LOG` as the logger, a deprecation warning will be shown explaining the required changes needed to use the new style logging. New plugins created by the `create_plugin` script will use the new logging facilities.
This commit is contained in:
Pedro Algarvio 2010-12-06 11:20:22 +00:00
parent 3d64f0d8da
commit 3b00a7de59
113 changed files with 795 additions and 321 deletions

View File

@ -1,4 +1,6 @@
=== Deluge 1.3.0 (In Development) ===
* Improved Logging
==== Core ====
* Implement #1063 option to delete torrent file copy on torrent removal - patch from Ghent
* Implement #457 progress bars for folders

View File

@ -42,12 +42,15 @@ import subprocess
import platform
import sys
import chardet
import logging
try:
import json
except ImportError:
import simplejson as json
log = logging.getLogger(__name__)
# Do a little hack here just in case the user has json-py installed since it
# has a different api
if not hasattr(json, "dumps"):
@ -77,7 +80,6 @@ try:
gettext.textdomain("deluge")
gettext.install("deluge", pkg_resources.resource_filename("deluge", "i18n"))
except Exception, e:
from deluge.log import LOG as log
log.error("Unable to initialize gettext/locale!")
log.exception(e)
import __builtin__

View File

@ -33,9 +33,11 @@
#
#
import logging
from twisted.internet.defer import maybeDeferred, succeed, DeferredList, fail
from twisted.internet.task import LoopingCall
from deluge.log import LOG as log
log = logging.getLogger(__name__)
class ComponentAlreadyRegistered(Exception):
pass

View File

@ -68,14 +68,16 @@ version as this will be done internally.
"""
import cPickle as pickle
import logging
import shutil
import os
import deluge.common
from deluge.log import LOG as log
json = deluge.common.json
log = logging.getLogger(__name__)
def prop(func):
"""Function decorator for defining property attributes

View File

@ -34,11 +34,14 @@
#
import os
import logging
import deluge.common
from deluge.log import LOG as log
import deluge.log
from deluge.config import Config
log = logging.getLogger(__name__)
class _ConfigManager:
def __init__(self):
log.debug("ConfigManager started..")
@ -86,6 +89,7 @@ class _ConfigManager:
# to reload based on the new config directory
self.save()
self.config_files = {}
deluge.log.tweak_logging_levels()
return True

View File

@ -41,12 +41,13 @@ This should typically only be used by the Core. Plugins should utilize the
"""
import logging
from twisted.internet import reactor
import deluge.component as component
from deluge._libtorrent import lt
from deluge.log import LOG as log
log = logging.getLogger(__name__)
class AlertManager(component.Component):
def __init__(self):

View File

@ -36,12 +36,13 @@
import os
import random
import stat
import logging
import deluge.component as component
import deluge.configmanager as configmanager
import deluge.error
from deluge.log import LOG as log
log = logging.getLogger(__name__)
AUTH_LEVEL_NONE = 0
AUTH_LEVEL_READONLY = 1

View File

@ -35,15 +35,17 @@
import os
import logging
from deluge._libtorrent import lt
import deluge.component as component
from deluge.configmanager import ConfigManager
from deluge.log import LOG as log
MAX_NUM_ATTEMPTS = 10
log = logging.getLogger(__name__)
class AutoAdd(component.Component):
def __init__(self):
component.Component.__init__(self, "AutoAdd", depend=["TorrentManager"], interval=5)

View File

@ -39,6 +39,7 @@ import os
import glob
import base64
import shutil
import logging
import threading
import pkg_resources
import warnings
@ -50,9 +51,6 @@ from twisted.internet.task import LoopingCall
import twisted.web.client
from deluge.httpdownloader import download_file
from deluge.log import LOG as log
import deluge.configmanager
import deluge.common
@ -69,6 +67,8 @@ from deluge.core.authmanager import AuthManager
from deluge.core.eventmanager import EventManager
from deluge.core.rpcserver import export
log = logging.getLogger(__name__)
class Core(component.Component):
def __init__(self, listen_interface=None):
log.debug("Core init..")

View File

@ -35,6 +35,7 @@
import os
import gettext
import locale
import logging
import pkg_resources
from twisted.internet import reactor
import twisted.internet.error
@ -43,9 +44,10 @@ import deluge.component as component
import deluge.configmanager
import deluge.common
from deluge.core.rpcserver import RPCServer, export
from deluge.log import LOG as log
import deluge.error
log = logging.getLogger(__name__)
class Daemon(object):
def __init__(self, options=None, args=None, classic=False):
# Check for another running instance of the daemon

View File

@ -33,8 +33,10 @@
#
#
import logging
import deluge.component as component
from deluge.log import LOG as log
log = logging.getLogger(__name__)
class EventManager(component.Component):
def __init__(self):

View File

@ -33,12 +33,13 @@
#
#
import logging
import deluge.component as component
from deluge.log import LOG as log
STATE_SORT = ["All", "Downloading", "Seeding", "Active", "Paused", "Queued"]
log = logging.getLogger(__name__)
#special purpose filters:
def filter_keywords(torrent_ids, values):
#cleanup.

View File

@ -39,12 +39,14 @@ import os.path
import pickle
import cPickle
import shutil
import logging
from deluge._libtorrent import lt
from deluge.configmanager import ConfigManager, get_config_dir
import deluge.core.torrentmanager
from deluge.log import LOG as log
log = logging.getLogger(__name__)
#start : http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/286203
def makeFakeClass(module, name):

View File

@ -36,13 +36,15 @@
"""PluginManager for Core"""
import logging
from twisted.internet import reactor
from twisted.internet.task import LoopingCall
from deluge.event import PluginEnabledEvent, PluginDisabledEvent
import deluge.pluginmanagerbase
import deluge.component as component
from deluge.log import LOG as log
log = logging.getLogger(__name__)
class PluginManager(deluge.pluginmanagerbase.PluginManagerBase,
component.Component):

View File

@ -35,6 +35,7 @@
import os
import logging
import threading
import pkg_resources
from twisted.internet import reactor
@ -46,7 +47,8 @@ from deluge.event import *
import deluge.configmanager
import deluge.common
import deluge.component as component
from deluge.log import LOG as log
log = logging.getLogger(__name__)
DEFAULT_PREFS = {
"send_info": False,

View File

@ -39,6 +39,7 @@ import sys
import zlib
import os
import stat
import logging
import traceback
from twisted.internet.protocol import Factory, Protocol
@ -52,8 +53,6 @@ try:
except ImportError:
import deluge.rencode as rencode
from deluge.log import LOG as log
import deluge.component as component
import deluge.configmanager
from deluge.core.authmanager import AUTH_LEVEL_NONE, AUTH_LEVEL_DEFAULT
@ -62,6 +61,8 @@ RPC_RESPONSE = 1
RPC_ERROR = 2
RPC_EVENT = 3
log = logging.getLogger(__name__)
def export(auth_level=AUTH_LEVEL_DEFAULT):
"""
Decorator function to register an object's method as an RPC. The object

View File

@ -36,6 +36,7 @@
import os
import time
import logging
from urllib import unquote
from urlparse import urlparse
@ -44,11 +45,12 @@ from deluge._libtorrent import lt
import deluge.common
import deluge.component as component
from deluge.configmanager import ConfigManager, get_config_dir
from deluge.log import LOG as log
from deluge.event import *
TORRENT_STATE = deluge.common.TORRENT_STATE
log = logging.getLogger(__name__)
class TorrentOptions(dict):
def __init__(self):
config = ConfigManager("core.conf").config

View File

@ -41,6 +41,7 @@ import os
import time
import shutil
import operator
import logging
from twisted.internet import reactor
from twisted.internet.task import LoopingCall
@ -56,7 +57,7 @@ from deluge.core.torrent import TorrentOptions
import deluge.core.oldstateupgrader
from deluge.common import utf8_encoded
from deluge.log import LOG as log
log = logging.getLogger(__name__)
class TorrentState:
def __init__(self,

View File

@ -36,16 +36,19 @@ from twisted.web import client, http
from twisted.web.error import PageRedirect
from twisted.python.failure import Failure
from twisted.internet import reactor
from deluge.log import setupLogger, LOG as log
from common import get_version
import logging
import os.path
import zlib
log = logging.getLogger(__name__)
class HTTPDownloader(client.HTTPDownloader):
"""
Factory class for downloading files and keeping track of progress.
"""
def __init__(self, url, filename, part_callback=None, headers=None, force_filename=False, allow_compression=True):
def __init__(self, url, filename, part_callback=None, headers=None,
force_filename=False, allow_compression=True):
"""
:param url: the url to download from
:type url: string
@ -152,7 +155,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.

View File

@ -2,6 +2,7 @@
# log.py
#
# Copyright (C) 2007 Andrew Resch <andrewresch@gmail.com>
# Copyright (C) 2010 Pedro Algarvio <pedro@algarvio.me>
#
# Deluge is free software.
#
@ -33,18 +34,100 @@
#
#
"""Logging functions"""
import os
import logging
import inspect
import pkg_resources
from deluge import configmanager, common, component
from twisted.internet import defer
from twisted.python.log import PythonLoggingObserver
__all__ = ["setupLogger", "setLoggerLevel", "getPluginLogger", "LOG"]
LoggingLoggerClass = logging.getLoggerClass()
if 'dev' in common.get_version():
DEFAULT_LOGGING_FORMAT = "%%(asctime)s.%%(msecs)03.0f [%%(name)-%ds:%%(lineno)-4d][%%(levelname)-8s] %%(message)s"
else:
DEFAULT_LOGGING_FORMAT = "%%(asctime)s [%%(name)-%ds][%%(levelname)-8s] %%(message)s"
MAX_LOGGER_NAME_LENGTH = 3
class Logging(LoggingLoggerClass):
def __init__(self, logger_name):
LoggingLoggerClass.__init__(self, logger_name)
# This makes module name padding increase to the biggest module name
# so that logs keep readability.
global MAX_LOGGER_NAME_LENGTH
if len(logger_name) > MAX_LOGGER_NAME_LENGTH:
MAX_LOGGER_NAME_LENGTH = len(logger_name)
for handler in logging.getLogger().handlers:
handler.setFormatter(logging.Formatter(
DEFAULT_LOGGING_FORMAT % MAX_LOGGER_NAME_LENGTH,
datefmt="%H:%M:%S"
))
@defer.inlineCallbacks
def garbage(self, msg, *args, **kwargs):
yield LoggingLoggerClass.log(self, 1, msg, *args, **kwargs)
@defer.inlineCallbacks
def trace(self, msg, *args, **kwargs):
yield LoggingLoggerClass.log(self, 5, msg, *args, **kwargs)
@defer.inlineCallbacks
def debug(self, msg, *args, **kwargs):
yield LoggingLoggerClass.debug(self, msg, *args, **kwargs)
@defer.inlineCallbacks
def info(self, msg, *args, **kwargs):
yield LoggingLoggerClass.info(self, msg, *args, **kwargs)
@defer.inlineCallbacks
def warning(self, msg, *args, **kwargs):
yield LoggingLoggerClass.warning(self, msg, *args, **kwargs)
warn = warning
@defer.inlineCallbacks
def error(self, msg, *args, **kwargs):
yield LoggingLoggerClass.error(self, msg, *args, **kwargs)
@defer.inlineCallbacks
def critical(self, msg, *args, **kwargs):
yield LoggingLoggerClass.critical(self, msg, *args, **kwargs)
@defer.inlineCallbacks
def exception(self, msg, *args, **kwargs):
yield LoggingLoggerClass.exception(self, msg, *args, **kwargs)
def findCaller(self):
f = logging.currentframe().f_back
rv = "(unknown file)", 0, "(unknown function)"
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')):
f = f.f_back
continue
rv = (filename, f.f_lineno, co.co_name)
break
return rv
levels = {
"info": logging.INFO,
"warning": logging.WARNING,
"error": logging.ERROR,
"none": logging.CRITICAL,
"debug": logging.DEBUG
"debug": logging.DEBUG,
"trace": 5,
"garbage": 1
}
def setupLogger(level="error", filename=None, filemode="w"):
"""
Sets up the basic logger and if `:param:filename` is set, then it will log
@ -53,30 +136,141 @@ def setupLogger(level="error", filename=None, filemode="w"):
:param level: str, the level to log
:param filename: str, the file to log to
"""
import logging
if not level or level not in levels:
level = "error"
if logging.getLoggerClass() is not Logging:
logging.setLoggerClass(Logging)
logging.basicConfig(
level=levels[level],
format="[%(levelname)-8s] %(asctime)s %(module)s:%(lineno)d %(message)s",
datefmt="%H:%M:%S",
filename=filename,
filemode=filemode
level = levels.get(level, "error")
rootLogger = logging.getLogger()
if filename and filemode=='a':
import logging.handlers
handler = logging.handlers.RotatingFileHandler(
filename, filemode,
maxBytes=5*1024*1024, # 5 Mb
backupCount=3,
encoding='utf-8',
delay=0
)
elif filename and filemode=='w':
handler = logging.FileHandler(filename, filemode, 'utf-8', delay=0)
else:
handler = logging.StreamHandler()
handler.setLevel(level)
formatter = logging.Formatter(
DEFAULT_LOGGING_FORMAT % MAX_LOGGER_NAME_LENGTH,
datefmt="%H:%M:%S"
)
def setLoggerLevel(level):
handler.setFormatter(formatter)
rootLogger.addHandler(handler)
rootLogger.setLevel(level)
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
file are NOT like regular deluge config file's.
To use is, create a file named "logging.conf" on your Deluge's config dir
with contents like for example:
deluge:warn
deluge.core:debug
deluge.plugin:error
What the above mean is the logger "deluge" will be set to the WARN level,
the "deluge.core" logger will be set to the DEBUG level and the
"deluge.plugin" will be set to the ERROR level.
Remember, one rule per line and this WILL override the setting passed from
the command line.
"""
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'):
if line.strip().startswith("#"):
continue
name, level = line.strip().split(':')
if level in levels:
log.warn("Setting logger \"%s\" to logging level \"%s\"", name, level)
logging.getLogger(name).setLevel(levels.get(level))
def setLoggerLevel(level, logger_name=None):
"""
Sets the logger level.
:param level: str, a string representing the desired level
:param logger_name: str, a string representing desired logger name for which
the level should change. The default is "None" will will
tweak the root logger level.
"""
if level not in levels:
return
logging.getLogger(logger_name).setLevel(levels.get(level, "error"))
global LOG
LOG.setLevel(levels[level])
# Get the logger
LOG = logging.getLogger("deluge")
def getPluginLogger(logger_name):
return logging.getLogger("deluge.plugin.%s" % logger_name)
DEPRECATION_WARNING = """You seem to be using old style logging on your code, ie:
from deluge.log import LOG as log
This has been deprecated in favour of an enhanced logging system and "LOG" will
be removed on the next major version release of Deluge, meaning, code will break,
specially plugins.
If you're seeing this message and you're not the developer of the plugin which
triggered this warning, please report to it's author.
If you're the developer, please stop using the above code and instead use:
from deluge.log import getPluginLogger
log = getPluginLogger(__name__)
The above will result in, regarding the "Label" plugin for example a log message similar to:
15:33:54 [deluge.plugin.label.core:78 ][INFO ] *** Start Label plugin ***
If you wish not to have 'deluge.plugin' on the log message you can then instead use:
import logging
log = logging.getLogger(__name__)
The above will result in, regarding the "Label" plugin for example a log message similar to:
15:33:54 [label.core:78 ][INFO ] *** Start Label plugin ***
Triggering code:"""
class __BackwardsCompatibleLOG(object):
def __getattribute__(self, name):
import warnings
logger_name = 'deluge'
stack = inspect.stack()
module_stack = stack.pop(1)
caller_module = inspect.getmodule(module_stack[0])
warnings.warn_explicit(DEPRECATION_WARNING, DeprecationWarning,
module_stack[1], module_stack[2],
caller_module.__name__)
for member in stack:
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__
# Monkey Patch The Plugin Module
caller_module.log = logging.getLogger(logger_name)
break
return getattr(logging.getLogger(logger_name), name)
LOG = __BackwardsCompatibleLOG()

View File

@ -2,6 +2,7 @@
# main.py
#
# Copyright (C) 2007 Andrew Resch <andrewresch@gmail.com>
# Copyright (C) 2010 Pedro Algarvio <pedro@algarvio.me>
#
# Deluge is free software.
#
@ -44,8 +45,7 @@ import sys
from optparse import OptionParser
import deluge.log
import deluge.common
import deluge.configmanager
#import deluge.common
import deluge.error
@ -72,12 +72,25 @@ def start_ui():
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("-s", "--set-default-ui", dest="default_ui",
help="Sets the default UI to be run when no UI is specified", action="store", type="str")
# Get the options and args from the OptionParser
(options, args) = parser.parse_args()
if options.quiet:
options.loglevel = "none"
logfile_mode = 'w'
if options.rotate_logs:
logfile_mode = 'a'
# Setup the logger
deluge.log.setupLogger(level=options.loglevel, filename=options.logfile,
filemode=logfile_mode)
if options.config:
if not os.path.exists(options.config):
# Try to create the config folder if it doesn't exist
@ -93,6 +106,7 @@ def start_ui():
os.makedirs(deluge.common.get_default_config_dir())
if options.default_ui:
import deluge.configmanager
if options.config:
deluge.configmanager.set_config_dir(options.config)
@ -102,15 +116,10 @@ def start_ui():
print "The default UI has been changed to", options.default_ui
sys.exit(0)
if options.quiet:
options.loglevel = "none"
# Setup the logger
deluge.log.setupLogger(level=options.loglevel, filename=options.logfile)
version = deluge.common.get_version()
from deluge.log import LOG as log
import logging
log = logging.getLogger(__name__)
log.info("Deluge ui %s", version)
log.debug("options: %s", options)
log.debug("args: %s", args)
@ -152,6 +161,8 @@ this should be an IP address", metavar="IFACE",
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")
@ -161,6 +172,15 @@ this should be an IP address", metavar="IFACE",
if options.quiet:
options.loglevel = "none"
logfile_mode = 'w'
if options.rotate_logs:
logfile_mode = 'a'
# Setup the logger
deluge.log.setupLogger(level=options.loglevel, filename=options.logfile,
filemode=logfile_mode)
import deluge.configmanager
if options.config:
if not deluge.configmanager.set_config_dir(options.config):
print("There was an error setting the config dir! Exiting..")
@ -202,8 +222,9 @@ this should be an IP address", metavar="IFACE",
os.makedirs(os.path.abspath(os.path.dirname(options.logfile)))
except:
pass
deluge.log.setupLogger(level=options.loglevel, filename=options.logfile)
from deluge.log import LOG as log
import logging
log = logging.getLogger(__name__)
if options.profile:
import hotshot

View File

@ -20,10 +20,12 @@ import os
import os.path
import sys
import time
import logging
from hashlib import sha1 as sha
from deluge.bencode import bencode
from deluge.log import LOG as log
log = logging.getLogger(__name__)
ignore = ['core', 'CVS', 'Thumbs.db', 'desktop.ini']

View File

@ -37,15 +37,16 @@
"""PluginManagerBase"""
import os.path
import logging
import pkg_resources
import deluge.common
import deluge.configmanager
from deluge.log import LOG as log
import deluge.component as component
log = logging.getLogger(__name__)
METADATA_KEYS = [
"Name",
"License",

View File

@ -39,7 +39,7 @@
from deluge._libtorrent import lt
import os
from deluge.log import LOG as log
from deluge.log import getPluginLogger
from deluge.plugins.pluginbase import CorePluginBase
import deluge.component as component
import deluge.configmanager
@ -48,6 +48,8 @@ from twisted.internet.task import LoopingCall, deferLater
from twisted.internet import reactor
from deluge.event import DelugeEvent
log = getPluginLogger(__name__)
DEFAULT_PREFS = {
"watchdirs":{},
"next_id":1

View File

@ -39,7 +39,7 @@
import gtk
from deluge.log import LOG as log
from deluge.log import getPluginLogger
from deluge.ui.client import client
from deluge.plugins.pluginbase import GtkPluginBase
import deluge.component as component
@ -48,6 +48,8 @@ import os
from common import get_resource
log = getPluginLogger(__name__)
class OptionsDialog():
spin_ids = ["max_download_speed", "max_upload_speed", "stop_ratio"]
spin_int_ids = ["max_upload_slots", "max_connections"]

View File

@ -37,13 +37,15 @@
# statement from all source files in the program, then also delete it here.
#
from deluge.log import LOG as log
from deluge.log import getPluginLogger
from deluge.ui.client import client
from deluge import component
from deluge.plugins.pluginbase import WebPluginBase
from common import get_resource
log = getPluginLogger(__name__)
class WebUI(WebPluginBase):
scripts = [get_resource("autoadd.js")]

View File

@ -45,7 +45,7 @@ from twisted.internet.task import LoopingCall
from twisted.internet import threads, defer
from twisted.web import error
from deluge.log import LOG as log
from deluge.log import getPluginLogger
from deluge.plugins.pluginbase import CorePluginBase
import deluge.component as component
import deluge.configmanager
@ -58,6 +58,8 @@ from readers import ReaderParseError
# TODO: check return values for deferred callbacks
# TODO: review class attributes for redundancy
log = getPluginLogger(__name__)
DEFAULT_PREFS = {
"url": "http://deluge-torrent.org/blocklist/nipfilter.dat.gz",
"load_on_start": False,

View File

@ -36,13 +36,15 @@
from datetime import datetime
import gtk
from deluge.log import LOG as log
from deluge.log import getPluginLogger
from deluge.ui.client import client
import deluge.component as component
import deluge.common
from deluge.plugins.pluginbase import GtkPluginBase
import common
log = getPluginLogger(__name__)
class GtkUI(GtkPluginBase):
def enable(self):
log.debug("Blocklist GtkUI enable..")

View File

@ -7,7 +7,9 @@ from exceptions import Exception
from struct import unpack
import gzip, socket
from deluge.log import LOG as log
from deluge.log import getPluginLogger
log = getPluginLogger(__name__)
class PGException(Exception):
pass

View File

@ -36,11 +36,13 @@
import os
from deluge.log import LOG as log
from deluge.log import getPluginLogger
from deluge.ui.client import client
from deluge import component
from deluge.plugins.pluginbase import WebPluginBase
log = getPluginLogger(__name__)
#import deluge.ui.webui.lib.newforms_plus as forms
#config_page_manager = component.get("ConfigPageManager")

View File

@ -33,12 +33,14 @@
#
#
from deluge.log import LOG as log
from deluge.log import getPluginLogger
from deluge.plugins.pluginbase import CorePluginBase
import deluge.component as component
import deluge.configmanager
from deluge.core.rpcserver import export
log = getPluginLogger(__name__)
class Core(CorePluginBase):
def enable(self):
log.debug("Example core plugin enabled!")

View File

@ -35,12 +35,14 @@
import gtk
from deluge.log import LOG as log
from deluge.log import getPluginLogger
from deluge.ui.client import client
from deluge.plugins.pluginbase import GtkPluginBase
import deluge.component as component
import deluge.common
log = getPluginLogger(__name__)
class GtkUI(GtkPluginBase):
def enable(self):
pass

View File

@ -33,13 +33,15 @@
#
#
from deluge.log import LOG as log
from deluge.log import getPluginLogger
from deluge.ui.client import client
from deluge import component
from deluge.plugins.pluginbase import WebPluginBase
from common import get_resource
log = getPluginLogger(__name__)
class WebUI(WebPluginBase):
scripts = [get_resource("example.js")]

View File

@ -38,13 +38,15 @@ import time
import hashlib
from subprocess import Popen, PIPE
from deluge.log import LOG as log
from deluge.log import getPluginLogger
from deluge.plugins.pluginbase import CorePluginBase
import deluge.component as component
from deluge.configmanager import ConfigManager
from deluge.core.rpcserver import export
from deluge.event import DelugeEvent
log = getPluginLogger(__name__)
DEFAULT_CONFIG = {
"commands": []
}

View File

@ -37,12 +37,14 @@ import os
import gtk
import pkg_resources
from deluge.log import LOG as log
from deluge.log import getPluginLogger
from deluge.ui.client import client
from deluge.plugins.pluginbase import GtkPluginBase
import deluge.component as component
import deluge.common
log = getPluginLogger(__name__)
EXECUTE_ID = 0
EXECUTE_EVENT = 1
EXECUTE_COMMAND = 2

View File

@ -35,13 +35,15 @@
import pkg_resources
from deluge.log import LOG as log
from deluge.log import getPluginLogger
from deluge.ui.client import client
from deluge import component
from deluge.plugins.pluginbase import WebPluginBase
from common import get_resource
log = getPluginLogger(__name__)
class WebUI(WebPluginBase):
scripts = [get_resource("execute.js")]

View File

@ -41,12 +41,14 @@ import os
from twisted.internet.utils import getProcessValue
from deluge.log import LOG as log
from deluge.log import getPluginLogger
from deluge.plugins.pluginbase import CorePluginBase
import deluge.component as component
import deluge.configmanager
from deluge.core.rpcserver import export
log = getPluginLogger(__name__)
DEFAULT_PREFS = {
"extract_path": "",
"use_name_folder": True

View File

@ -39,7 +39,7 @@
import gtk
from deluge.log import LOG as log
from deluge.log import getPluginLogger
from deluge.ui.client import client
from deluge.plugins.pluginbase import GtkPluginBase
import deluge.component as component
@ -47,6 +47,8 @@ import deluge.common
from common import get_resource
log = getPluginLogger(__name__)
class GtkUI(GtkPluginBase):
def enable(self):
self.glade = gtk.glade.XML(get_resource("extractor_prefs.glade"))

View File

@ -37,11 +37,13 @@
#
#
from deluge.log import LOG as log
from deluge.log import getPluginLogger
from deluge.ui.client import client
from deluge import component
from deluge.plugins.pluginbase import WebPluginBase
log = getPluginLogger(__name__)
class WebUI(WebPluginBase):
def enable(self):
pass

View File

@ -42,12 +42,14 @@ import threading # for threaded updates
import re # for regular expressions
from twisted.internet.task import LoopingCall
from deluge.log import LOG as log
from deluge.log import getPluginLogger
from deluge.plugins.pluginbase import CorePluginBase
import deluge.component as component
import deluge.configmanager
from deluge.core.rpcserver import export
log = getPluginLogger(__name__)
DEFAULT_PREFS = {
"feeds": {},
"filters": {},

View File

@ -36,11 +36,13 @@
import feedparser # for proccessing feed entries
import os
from deluge.log import LOG as log
from deluge.log import getPluginLogger
from deluge.ui.client import sclient, aclient
from deluge.plugins.webuipluginbase import WebUIPluginBase
from deluge import component
log = getPluginLogger(__name__)
api = component.get("WebPluginApi")
forms = api.forms

View File

@ -1,7 +1,7 @@
#
# __init__.py
#
# Copyright (C) 2009 Pedro Algarvio <ufs@ufsoft.org>
# Copyright (C) 2009-2010 Pedro Algarvio <pedro@algarvio.me>
#
# Basic plugin template created by:
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>

View File

@ -1,7 +1,7 @@
#
# common.py
#
# Copyright (C) 2009 Pedro Algarvio <ufs@ufsoft.org>
# Copyright (C) 2009-2010 Pedro Algarvio <pedro@algarvio.me>
#
# Basic plugin template created by:
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>

View File

@ -1,7 +1,7 @@
#
# core.py
#
# Copyright (C) 2009 Pedro Algarvio <ufs@ufsoft.org>
# Copyright (C) 2009-2010 Pedro Algarvio <pedro@algarvio.me>
#
# Basic plugin template created by:
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
@ -41,13 +41,15 @@
import os, statvfs
from datetime import datetime, timedelta
from twisted.internet import task
from deluge.log import LOG as log
from deluge.log import getPluginLogger
from deluge.plugins.pluginbase import CorePluginBase
from deluge.event import DelugeEvent
import deluge.component as component
import deluge.configmanager
from deluge.core.rpcserver import export
log = getPluginLogger(__name__)
class LowDiskSpaceEvent(DelugeEvent):
"""Triggered when the available space for a specific path is getting

View File

@ -1,7 +1,7 @@
#
# gtkui.py
#
# Copyright (C) 2009 Pedro Algarvio <ufs@ufsoft.org>
# Copyright (C) 2009-2010 Pedro Algarvio <pedro@algarvio.me>
#
# Basic plugin template created by:
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
@ -39,7 +39,7 @@
import gtk
from deluge.log import LOG as log
from deluge.log import getPluginLogger
from deluge.ui.client import client
from deluge.plugins.pluginbase import GtkPluginBase
import deluge.component as component
@ -47,6 +47,8 @@ import deluge.common
from common import get_resource
log = getPluginLogger(__name__)
class GtkUI(GtkPluginBase):
def enable(self):

View File

@ -1,7 +1,7 @@
#
# webui.py
#
# Copyright (C) 2009 Pedro Algarvio <ufs@ufsoft.org>
# Copyright (C) 2009-2010 Pedro Algarvio <pedro@algarvio.me>
#
# Basic plugin template created by:
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
@ -37,13 +37,15 @@
# statement from all source files in the program, then also delete it here.
#
from deluge.log import LOG as log
from deluge.log import getPluginLogger
from deluge.ui.client import client
from deluge import component
from deluge.plugins.pluginbase import WebPluginBase
from common import get_resource
log = getPluginLogger(__name__)
class WebUI(WebPluginBase):
scripts = [get_resource("freespace.js")]

View File

@ -1,7 +1,7 @@
#
# setup.py
#
# Copyright (C) 2009 Pedro Algarvio <ufs@ufsoft.org>
# Copyright (C) 2009-2010 Pedro Algarvio <pedro@algarvio.me>
#
# Basic plugin template created by:
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
@ -41,7 +41,7 @@ from setuptools import setup
__plugin_name__ = "FreeSpace"
__author__ = "Pedro Algarvio"
__author_email__ = "ufs@ufsoft.org"
__author_email__ = "pedro@algarvio.me"
__version__ = "0.1"
__url__ = "http://deluge.ufsoft.org/hg/Notification/"
__license__ = "GPLv3"

View File

@ -36,7 +36,9 @@
"""
This base class is used in plugin's __init__ for the plugin entry points.
"""
from deluge.log import LOG as log
import logging
log = logging.getLogger(__name__)
class PluginInitBase(object):
_plugin_cls = None

View File

@ -37,7 +37,7 @@ torrent-label core plugin.
adds a status field for tracker.
"""
from deluge.log import LOG as log
from deluge.log import getPluginLogger
from deluge.plugins.pluginbase import CorePluginBase
from deluge.core.rpcserver import export
from deluge.configmanager import ConfigManager
@ -47,6 +47,8 @@ from urlparse import urlparse
import traceback
import re
log = getPluginLogger(__name__)
RE_VALID = re.compile("[a-z0-9_\-\.]*\Z")
KNOWN_STATES = ['Downloading','Seeding','Paused','Checking','Queued','Error']

View File

@ -36,7 +36,7 @@
import os
import pkg_resources # access plugin egg
from deluge.log import LOG as log
from deluge.log import getPluginLogger
from deluge import component # for systray
from deluge.plugins.pluginbase import GtkPluginBase
import gtk, gobject
@ -46,6 +46,8 @@ import sidebar_menu
import label_config
import submenu
log = getPluginLogger(__name__)
NO_LABEL = "No Label"
def cell_data_label(column, cell, model, row, data):

View File

@ -39,9 +39,11 @@ import os
import pkg_resources # access plugin egg
import deluge.component as component
import deluge.common
from deluge.log import LOG as log
from deluge.log import getPluginLogger
from deluge.ui.client import client
log = getPluginLogger(__name__)
class LabelConfig(object):
"""

View File

@ -40,9 +40,11 @@ import gtk.glade
import deluge.component as component
import deluge.common
from deluge.log import LOG as log
from deluge.log import getPluginLogger
from deluge.ui.client import client
log = getPluginLogger(__name__)
NO_LABEL = "No Label"
#helpers:

View File

@ -36,11 +36,13 @@
import os
import pkg_resources # access plugin egg
from deluge.log import LOG as log
from deluge.log import getPluginLogger
from deluge import component # for systray
import gtk, gobject
from deluge.ui.client import client
log = getPluginLogger(__name__)
NO_LABEL = "No Label"
class LabelMenu(gtk.MenuItem):

View File

@ -40,11 +40,13 @@
import os
import pkg_resources
from deluge.common import fspeed
from deluge.log import LOG as log
from deluge.log import getPluginLogger
from deluge.ui.client import client
from deluge.plugins.pluginbase import WebPluginBase
from deluge import component
log = getPluginLogger(__name__)
def get_resource(filename):
return pkg_resources.resource_filename("label", os.path.join("data", filename))

View File

@ -1,7 +1,7 @@
#
# __init__.py
#
# Copyright (C) 2009 Pedro Algarvio <ufs@ufsoft.org>
# Copyright (C) 2009-2010 Pedro Algarvio <pedro@algarvio.me>
#
# Basic plugin template created by:
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>

View File

@ -1,7 +1,7 @@
#
# common.py
#
# Copyright (C) 2009 Pedro Algarvio <ufs@ufsoft.org>
# Copyright (C) 2009-2010 Pedro Algarvio <pedro@algarvio.me>
#
# Basic plugin template created by:
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
@ -39,7 +39,9 @@
from twisted.internet import defer
from deluge import component
from deluge.log import LOG as log
from deluge.log import getPluginLogger
log = getPluginLogger(__name__)
try:
from deluge.event import known_events

View File

@ -1,7 +1,7 @@
#
# core.py
#
# Copyright (C) 2009 Pedro Algarvio <ufs@ufsoft.org>
# Copyright (C) 2009-2010 Pedro Algarvio <pedro@algarvio.me>
#
# Basic plugin template created by:
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
@ -41,13 +41,15 @@ import smtplib
from twisted.internet import defer, threads
from deluge import component
from deluge.event import known_events
from deluge.log import LOG as log
from deluge.log import getPluginLogger
from deluge.plugins.pluginbase import CorePluginBase
import deluge.configmanager
from deluge.core.rpcserver import export
from notifications.common import CustomNotifications
log = getPluginLogger(__name__)
DEFAULT_PREFS = {
"smtp_enabled": False,
"smtp_host": "",

View File

@ -1,7 +1,7 @@
#
# gtkui.py
#
# Copyright (C) 2009 Pedro Algarvio <ufs@ufsoft.org>
# Copyright (C) 2009-2010 Pedro Algarvio <pedro@algarvio.me>
#
# Basic plugin template created by:
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
@ -41,7 +41,7 @@ from os.path import basename
import gtk
from twisted.internet import defer
from deluge.log import LOG as log
from deluge.log import getPluginLogger
from deluge.ui.client import client
from deluge.plugins.pluginbase import GtkPluginBase
import deluge.component as component
@ -51,6 +51,8 @@ import deluge.configmanager
# Relative imports
from common import get_resource, CustomNotifications
log = getPluginLogger(__name__)
try:
import pygame
SOUND_AVAILABLE = True

View File

@ -1,15 +1,17 @@
# -*- coding: utf-8 -*-
# vim: sw=4 ts=4 fenc=utf-8 et
# ==============================================================================
# Copyright © 2009 UfSoft.org - Pedro Algarvio <ufs@ufsoft.org>
# Copyright © 2009-2010 UfSoft.org - Pedro Algarvio <pedro@algarvio.me>
#
# License: BSD - Please view the LICENSE file for additional information.
# ==============================================================================
from twisted.internet import reactor, task
from twisted.internet import task
from deluge import component
from deluge.event import DelugeEvent
from deluge.log import LOG as log
from deluge.log import getPluginLogger
log = getPluginLogger(__name__)
class FooEvent(DelugeEvent):
"""foo Event"""

View File

@ -1,7 +1,7 @@
#
# webui.py
#
# Copyright (C) 2009 Pedro Algarvio <ufs@ufsoft.org>
# Copyright (C) 2009-2010 Pedro Algarvio <pedro@algarvio.me>
#
# Basic plugin template created by:
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
@ -38,7 +38,7 @@
#
from twisted.internet import defer
from deluge.log import LOG as log
from deluge.log import getPluginLogger
from deluge.ui.client import client
from deluge import component
from deluge.plugins.pluginbase import WebPluginBase
@ -47,6 +47,8 @@ import deluge.configmanager
# Relative imports
from common import get_resource
log = getPluginLogger(__name__)
DEFAULT_PREFS = {
# FLASH
"flash_enabled": False,

View File

@ -1,7 +1,7 @@
#
# setup.py
#
# Copyright (C) 2009 Pedro Algarvio <ufs@ufsoft.org>
# Copyright (C) 2009-2010 Pedro Algarvio <pedro@algarvio.me>
#
# Basic plugin template created by:
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
@ -41,7 +41,7 @@ from setuptools import setup, find_packages
__plugin_name__ = "Notifications"
__author__ = "Pedro Algarvio"
__author_email__ = "ufs@ufsoft.org"
__author_email__ = "pedro@algarvio.me"
__version__ = "0.1"
__url__ = "http://dev.deluge-torrent.org/"
__license__ = "GPLv3"

View File

@ -33,8 +33,10 @@
#
#
import logging
import deluge.component as component
from deluge.log import LOG as log
log = logging.getLogger(__name__)
class PluginBase(component.Component):

View File

@ -38,7 +38,7 @@
import time
from deluge.log import LOG as log
from deluge.log import getPluginLogger
from deluge.plugins.pluginbase import CorePluginBase
import deluge.component as component
import deluge.configmanager
@ -47,6 +47,8 @@ from deluge.event import DelugeEvent
from twisted.internet import reactor
log = getPluginLogger(__name__)
DEFAULT_PREFS = {
"low_down": -1.0,
"low_up": -1.0,

View File

@ -38,7 +38,7 @@
import gtk
from deluge.log import LOG as log
from deluge.log import getPluginLogger
from deluge.ui.client import client
from deluge.plugins.pluginbase import GtkPluginBase
import deluge.component as component
@ -46,6 +46,8 @@ import deluge.common
from common import get_resource
log = getPluginLogger(__name__)
DAYS = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]
class SchedulerSelectWidget(gtk.DrawingArea):

View File

@ -36,13 +36,15 @@
# statement from all source files in the program, then also delete it here.
#
from deluge.log import LOG as log
from deluge.log import getPluginLogger
from deluge.ui.client import client
from deluge import component
from deluge.plugins.pluginbase import WebPluginBase
from common import get_resource
log = getPluginLogger(__name__)
class WebUI(WebPluginBase):
scripts = [get_resource("scheduler.js")]

View File

@ -48,12 +48,14 @@ from twisted.internet.task import LoopingCall
import time
import deluge
from deluge.log import LOG as log
from deluge.log import getPluginLogger
from deluge.plugins.pluginbase import CorePluginBase
from deluge import component
from deluge import configmanager
from deluge.core.rpcserver import export
log = getPluginLogger(__name__)
DEFAULT_PREFS = {
"test": "NiNiNi",
"update_interval": 2, #2 seconds.

View File

@ -48,7 +48,7 @@ port of old plugin by markybob.
"""
import time
import cairo
from deluge.log import LOG as log
from deluge.log import getPluginLogger
from deluge.ui.client import client
black = (0, 0, 0)
@ -60,6 +60,8 @@ green = (0, 1.0, 0)
blue = (0, 0, 1.0)
orange = (1.0, 0.74, 0)
log = getPluginLogger(__name__)
def default_formatter(value):
return str(value)

View File

@ -53,12 +53,14 @@ from twisted.internet import defer
import graph
from deluge import component
from deluge.log import LOG as log
from deluge.log import getPluginLogger
from deluge.common import fspeed
from deluge.ui.client import client
from deluge.ui.gtkui.torrentdetails import Tab
from deluge.plugins.pluginbase import GtkPluginBase
log = getPluginLogger(__name__)
class GraphsTab(Tab):
def __init__(self, glade):
Tab.__init__(self)

View File

@ -33,13 +33,15 @@
#
#
from deluge.log import LOG as log
from deluge.log import getPluginLogger
from deluge.ui.client import client
from deluge import component
from deluge.plugins.pluginbase import WebPluginBase
from common import get_resource
log = getPluginLogger(__name__)
class WebUI(WebPluginBase):
scripts = [get_resource("stats.js")]

View File

@ -37,12 +37,14 @@
# statement from all source files in the program, then also delete it here.
#
from deluge.log import LOG as log
from deluge.log import getPluginLogger
from deluge.plugins.pluginbase import CorePluginBase
import deluge.component as component
import deluge.configmanager
from deluge.core.rpcserver import export
log = getPluginLogger(__name__)
DEFAULT_PREFS = {
}

View File

@ -39,7 +39,7 @@
import gtk
from deluge.log import LOG as log
from deluge.log import getPluginLogger
from deluge.ui.client import client
from deluge.plugins.pluginbase import GtkPluginBase
import deluge.component as component
@ -47,6 +47,8 @@ import deluge.common
from common import get_resource
log = getPluginLogger(__name__)
class GtkUI(GtkPluginBase):
def enable(self):
self.core = client.toggle

View File

@ -37,13 +37,15 @@
# statement from all source files in the program, then also delete it here.
#
from deluge.log import LOG as log
from deluge.log import getPluginLogger
from deluge.ui.client import client
from deluge import component
from deluge.plugins.pluginbase import WebPluginBase
from common import get_resource
log = getPluginLogger(__name__)
class WebUI(WebPluginBase):
scripts = [get_resource("toggle.js")]

View File

@ -39,10 +39,12 @@
import os
from deluge import common, component, configmanager
from deluge.log import LOG as log
from deluge.log import getPluginLogger
from deluge.plugins.pluginbase import CorePluginBase
from deluge.core.rpcserver import export
log = getPluginLogger(__name__)
DEFAULT_PREFS = {
"enabled": False,
"ssl": False,

View File

@ -38,7 +38,7 @@
import gtk
from deluge.log import LOG as log
from deluge.log import getPluginLogger
from deluge.ui.client import client
from deluge.plugins.pluginbase import GtkPluginBase
import deluge.component as component
@ -46,6 +46,8 @@ import deluge.common
from common import get_resource
log = getPluginLogger(__name__)
class GtkUI(GtkPluginBase):
def enable(self):
self.glade = gtk.glade.XML(get_resource("config.glade"))

View File

@ -7,6 +7,7 @@ python create_plugin.py --name MyPlugin2 --basepath . --author-name "Your Name"
"""
from datetime import datetime
from optparse import OptionParser
import os
import deluge.common
@ -64,7 +65,8 @@ def create_plugin():
"filename":filename,
"plugin_base":plugin_base,
"url": options.url,
"configdir": options.configdir
"configdir": options.configdir,
"current_year": datetime.utcnow().year
}
filename = os.path.join(path, filename)
@ -98,7 +100,6 @@ def create_plugin():
CORE = """
from deluge.log import LOG as log
from deluge.plugins.pluginbase import CorePluginBase
import deluge.component as component
import deluge.configmanager
@ -192,6 +193,7 @@ setup(
"""
COMMON = """
def get_resource(filename):
import pkg_resources, os
return pkg_resources.resource_filename("%(safe_name)s", os.path.join("data", filename))
@ -200,7 +202,7 @@ def get_resource(filename):
GTKUI = """
import gtk
from deluge.log import LOG as log
from deluge.log import getPluginLogger
from deluge.ui.client import client
from deluge.plugins.pluginbase import GtkPluginBase
import deluge.component as component
@ -208,6 +210,8 @@ import deluge.common
from common import get_resource
log = getPluginLogger(__name__)
class GtkUI(GtkPluginBase):
def enable(self):
self.glade = gtk.glade.XML(get_resource("config.glade"))
@ -266,13 +270,15 @@ GLADE = """<?xml version="1.0" encoding="UTF-8" standalone="no"?>
"""
WEBUI = """
from deluge.log import LOG as log
from deluge.log import getPluginLogger
from deluge.ui.client import client
from deluge import component
from deluge.plugins.pluginbase import WebPluginBase
from common import get_resource
log = getPluginLogger(__name__)
class WebUI(WebPluginBase):
scripts = [get_resource("%(safe_name)s.js")]
@ -289,7 +295,7 @@ Script: %(filename)s
The client-side javascript code for the %(name)s plugin.
Copyright:
(C) %(author_name)s 2009 <%(author_email)s>
(C) %(author_name)s %(current_year)s <%(author_email)s>
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)
@ -318,20 +324,20 @@ Copyright:
*/
%(name)sPlugin = Ext.extend(Deluge.Plugin, {
constructor: function(config) {
config = Ext.apply({
name: "%(name)s"
}, config);
%(name)sPlugin.superclass.constructor.call(this, config);
},
constructor: function(config) {
config = Ext.apply({
name: "%(name)s"
}, config);
%(name)sPlugin.superclass.constructor.call(this, config);
},
onDisable: function() {
onDisable: function() {
},
},
onEnable: function() {
onEnable: function() {
}
}
});
new %(name)sPlugin();
"""
@ -339,12 +345,13 @@ new %(name)sPlugin();
GPL = """#
# %(filename)s
#
# Copyright (C) 2009 %(author_name)s <%(author_email)s>
# Copyright (C) %(current_year)d %(author_name)s <%(author_email)s>
#
# Basic plugin template created by:
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
# Copyright (C) 2007-2009 Andrew Resch <andrewresch@gmail.com>
# Copyright (C) 2009 Damien Churchill <damoxc@gmail.com>
# Copyright (C) 2010 Pedro Algarvio <pedro@algarvio.me>
#
# Deluge is free software.
#

21
deluge/tests/test_log.py Normal file
View File

@ -0,0 +1,21 @@
import logging
from twisted.internet import defer
from twisted.trial import unittest
from deluge.log import setupLogger
class LogTestCase(unittest.TestCase):
def setUp(self):
setupLogger(logging.DEBUG)
def tearDown(self):
pass
def test_old_LOG_deprecation_warning(self):
import warnings
from deluge.log import LOG
warnings.filterwarnings("ignore", category=DeprecationWarning,
module="deluge.tests.test_log")
d = defer.Deferred()
d.addCallback(LOG.debug, "foo")
self.assertFailure(d, DeprecationWarning)
warnings.resetwarnings()

View File

@ -33,6 +33,7 @@
#
#
import logging
from twisted.internet.protocol import Protocol, ClientFactory
from twisted.internet import reactor, ssl, defer
try:
@ -44,7 +45,6 @@ import zlib
import deluge.common
import deluge.component as component
from deluge.log import LOG as log
if deluge.common.windows_check():
import win32api
@ -55,6 +55,8 @@ RPC_RESPONSE = 1
RPC_ERROR = 2
RPC_EVENT = 3
log = logging.getLogger(__name__)
def format_kwargs(kwargs):
return ", ".join([key + "=" + str(value) for key, value in kwargs.items()])

View File

@ -40,6 +40,7 @@ all the interfaces.
import os
import sys
import logging
import urlparse
import locale
@ -51,9 +52,10 @@ except ImportError:
from deluge import bencode
from deluge.common import decode_string, path_join
from deluge.log import LOG as log
import deluge.configmanager
log = logging.getLogger(__name__)
class TorrentInfo(object):
"""
Collects information about a torrent file.

View File

@ -34,18 +34,20 @@
#
#
import re
import logging
import tokenize
import cStringIO
from optparse import make_option
from twisted.internet import defer
from deluge.ui.console.main import BaseCommand
import deluge.ui.console.colors as colors
from deluge.ui.client import client
import deluge.component as component
from deluge.log import LOG as log
from optparse import make_option
import re
import cStringIO, tokenize
log = logging.getLogger(__name__)
def atom(next, token):
"""taken with slight modifications from http://effbot.org/zone/simple-iterator-parser.htm"""

View File

@ -34,12 +34,13 @@
#
import logging
import deluge.component as component
import deluge.common
import colors
from deluge.ui.client import client
from deluge.log import LOG as log
log = logging.getLogger(__name__)
class EventLog(component.Component):
"""

View File

@ -34,7 +34,9 @@
#
#
import os, sys
import os
import sys
import logging
import optparse
import shlex
import locale
@ -50,9 +52,10 @@ from deluge.ui.console.statusbars import StatusBars
from deluge.ui.console.eventlog import EventLog
import screen
import colors
from deluge.log import LOG as log
from deluge.ui.ui import _UI
log = logging.getLogger(__name__)
class Console(_UI):
help = """Starts the Deluge console interface"""

View File

@ -34,6 +34,7 @@
#
import sys
import logging
try:
import curses
except ImportError:
@ -48,9 +49,10 @@ try:
except:
pass
from deluge.log import LOG as log
from twisted.internet import reactor
log = logging.getLogger(__name__)
class CursesStdIO(object):
"""fake fd to be registered as a reader with the twisted reactor.
Curses classes needing input should extend this"""

View File

@ -34,9 +34,11 @@
#
import logging
import deluge.component as component
from deluge.ui.client import client
from deluge.log import LOG as log
log = logging.getLogger(__name__)
class CoreConfig(component.Component):
def __init__(self):

View File

@ -36,10 +36,12 @@
import pygtk
pygtk.require('2.0')
import gtk, gtk.glade
import gtk
import gtk.glade
import gettext
import gobject
import base64
import logging
import os
import pkg_resources
@ -48,12 +50,13 @@ from deluge.ui.client import client
import deluge.component as component
import listview
from deluge.configmanager import ConfigManager
from deluge.log import LOG as log
import deluge.common
import deluge.ui.common
import dialogs
import common
log = logging.getLogger(__name__)
class AddTorrentDialog(component.Component):
def __init__(self):
component.Component.__init__(self, "AddTorrentDialog")

View File

@ -39,15 +39,17 @@ import os
import pygtk
pygtk.require('2.0')
import gtk, gtk.glade
import gtk
import gtk.glade
import logging
import pkg_resources
from deluge.ui.client import client
import deluge.component as component
from deluge.log import LOG as log
import deluge.common
log = logging.getLogger(__name__)
def get_logo(size):
"""Returns a deluge logo pixbuf based on the size parameter."""
if deluge.common.windows_check() or deluge.common.osx_check():

View File

@ -38,6 +38,7 @@ import pkg_resources
import urlparse
import time
import hashlib
import logging
from twisted.internet import reactor
import deluge.component as component
@ -48,9 +49,10 @@ from deluge.ui.client import client
import deluge.ui.client
import deluge.ui.common
from deluge.configmanager import ConfigManager
from deluge.log import LOG as log
import dialogs
log = logging.getLogger(__name__)
DEFAULT_HOST = "127.0.0.1"
DEFAULT_PORT = 58846

View File

@ -40,6 +40,7 @@ import pkg_resources
import os.path
import gobject
import base64
import logging
from twisted.internet.threads import deferToThread
@ -48,7 +49,8 @@ import listview
import deluge.component as component
import deluge.common
from deluge.configmanager import ConfigManager
from deluge.log import LOG as log
log = logging.getLogger(__name__)
class CreateTorrentDialog:
def show(self):

View File

@ -34,14 +34,16 @@
#
import gtk, gtk.glade
import gtk
import gtk.glade
import logging
from deluge.ui.client import client
import deluge.component as component
from deluge.common import fsize, is_url
from deluge.ui.gtkui.torrentdetails import Tab
from deluge.log import LOG as log
log = logging.getLogger(__name__)
class DetailsTab(Tab):
def __init__(self):

View File

@ -34,14 +34,17 @@
#
import gtk, gtk.glade
import gtk
import gtk.glade
import logging
import pkg_resources
import deluge.common
import common
from deluge.ui.client import client
import deluge.component as component
from deluge.log import LOG as log
log = logging.getLogger(__name__)
class EditTrackersDialog:
def __init__(self, torrent_id, parent=None):

View File

@ -34,11 +34,14 @@
#
import gtk, gtk.glade, gtk.gdk
import gtk
import gtk.gdk
import gtk.glade
import gobject
import gettext
import os.path
import cPickle
import logging
from deluge.ui.gtkui.torrentdetails import Tab
from deluge.ui.client import client
@ -48,7 +51,7 @@ import deluge.component as component
import deluge.common
import common
from deluge.log import LOG as log
log = logging.getLogger(__name__)
def cell_priority(column, cell, model, row, data):
if model.get_value(row, 5) == -1:

View File

@ -37,14 +37,16 @@
import gtk
import gtk.glade
import logging
import pkg_resources
import deluge.component as component
import deluge.common
from deluge.log import LOG as log
from deluge.ui.client import client
from deluge.configmanager import ConfigManager
log = logging.getLogger(__name__)
STATE_PIX = {
"All": "all",
"Downloading": "downloading",

View File

@ -32,7 +32,6 @@
# statement from all source files in the program, then also delete it here.
#
#
from deluge.log import LOG as log
# Install the twisted reactor
from twisted.internet import gtk2reactor
@ -42,8 +41,12 @@ import gobject
import gettext
import locale
import pkg_resources
import gtk, gtk.glade
import gtk
import gtk.glade
import sys
import logging
log = logging.getLogger(__name__)
# Initialize gettext
try:

View File

@ -37,6 +37,7 @@
import sys
import os
import base64
import logging
try:
import rencode
@ -47,12 +48,13 @@ import deluge.component as component
from deluge.ui.client import client
import deluge.common
from deluge.configmanager import ConfigManager
from deluge.log import LOG as log
from twisted.internet.protocol import Factory, Protocol, ClientFactory
from twisted.internet import reactor
import twisted.internet.error
log = logging.getLogger(__name__)
class IPCProtocolServer(Protocol):
def dataReceived(self, data):
data = rencode.loads(data)

View File

@ -37,6 +37,7 @@
import cPickle
import os.path
import logging
import pygtk
pygtk.require('2.0')
@ -46,13 +47,13 @@ import gettext
from deluge.configmanager import ConfigManager
import deluge.configmanager
import deluge.common
from deluge.log import LOG as log
from gobject import signal_new, SIGNAL_RUN_LAST, TYPE_NONE
from gtk import gdk
signal_new('button-press-event', gtk.TreeViewColumn,
SIGNAL_RUN_LAST, TYPE_NONE, (gdk.Event,))
log = logging.getLogger(__name__)
# Cell data functions to pass to add_func_column()
def cell_data_speed(column, cell, model, row, data):

View File

@ -36,8 +36,10 @@
import pygtk
pygtk.require('2.0')
import gtk, gtk.glade
import gtk
import gtk.glade
import gobject
import logging
import pkg_resources
from urlparse import urlparse
import urllib
@ -51,7 +53,7 @@ from twisted.internet import reactor
import deluge.common
import common
from deluge.log import LOG as log
log = logging.getLogger(__name__)
class MainWindow(component.Component):
def __init__(self):

View File

@ -36,7 +36,9 @@
import pygtk
pygtk.require('2.0')
import gtk, gtk.glade
import gtk
import gtk.glade
import logging
import pkg_resources
import deluge.error
@ -46,7 +48,7 @@ import deluge.common
import common
from deluge.configmanager import ConfigManager
from deluge.log import LOG as log
log = logging.getLogger(__name__)
class MenuBar(component.Component):
def __init__(self):

View File

@ -34,13 +34,15 @@
#
import logging
import deluge.component as component
import deluge.common
import common
from deluge.log import LOG as log
from deluge.configmanager import ConfigManager
from deluge.ui.client import client
log = logging.getLogger(__name__)
class Notification:
def __init__(self):
self.config = ConfigManager("gtkui.conf")
@ -53,7 +55,9 @@ class Notification:
self.get_torrent_status(torrent_id)
def get_torrent_status(self, torrent_id):
component.get("SessionProxy").get_torrent_status(torrent_id, ["name", "num_files", "total_payload_download"]).addCallback(self._on_get_torrent_status)
component.get("SessionProxy").get_torrent_status(torrent_id, [
"name", "num_files", "total_payload_download"
]).addCallback(self._on_get_torrent_status)
def _on_get_torrent_status(self, status):
if status is None:
@ -77,7 +81,10 @@ class Notification:
if not pynotify.init("Deluge"):
return
title = deluge.common.xml_encode(_("Torrent complete"))
message = deluge.common.xml_encode(status["name"] + "\n" + _("Including %i files" % status["num_files"]))
message = deluge.common.xml_encode(
status["name"] + "\n" +
_("Including %i files" % status["num_files"])
)
self.note = pynotify.Notification(title, message)
self.note.set_icon_from_pixbuf(common.get_logo(48))
if not self.note.show():
@ -106,9 +113,12 @@ class Notification:
headers = "From: %s\r\nTo: %s\r\nSubject: %s\r\n\r\n" % (
self.config["ntf_email_add"], self.config["ntf_email_add"],
"Finished torrent %s" % (status["name"]))
text = _("This email is to inform you that Deluge has finished downloading %(name)s , \
which includes %(num_files)i files.\nTo stop receiving these alerts, simply turn off \
email notification in Deluge's preferences.\n\nThank you,\nDeluge") % {"name": status["name"], "num_files": status["num_files"]}
text = _("This email is to inform you that Deluge has finished "
"downloading %(name)s , which includes %(num_files)i files.\n"
"To stop receiving these alerts, simply turn off email "
"notification in Deluge's preferences.\n\n"
"Thank you,\nDeluge") % {"name": status["name"],
"num_files": status["num_files"]}
message = headers + text
if self.config["ntf_security"] == 'SSL':
port = 465

View File

@ -34,7 +34,9 @@
#
import gtk, gtk.glade
import gtk
import gtk.glade
import logging
import os.path
import cPickle
import pkg_resources
@ -48,9 +50,10 @@ import deluge.component as component
import deluge.common
from deluge.ui.gtkui.listview import cell_data_speed as cell_data_speed
from deluge.ui.gtkui.torrentdetails import Tab
from deluge.log import LOG as log
from deluge.ui.countries import COUNTRIES
log = logging.getLogger(__name__)
def cell_data_progress(column, cell, model, row, data):
value = model.get_value(row, data)
cell.set_property("value", value * 100)

View File

@ -34,11 +34,13 @@
#
import logging
import deluge.component as component
import deluge.pluginmanagerbase
from deluge.ui.client import client
from deluge.configmanager import ConfigManager
from deluge.log import LOG as log
log = logging.getLogger(__name__)
class PluginManager(deluge.pluginmanagerbase.PluginManagerBase,
component.Component):

View File

@ -36,11 +36,12 @@
import pygtk
pygtk.require('2.0')
import gtk, gtk.glade
import gtk
import gtk.glade
import logging
import pkg_resources
import deluge.component as component
from deluge.log import LOG as log
from deluge.ui.client import client
import deluge.common
import deluge.error
@ -48,13 +49,15 @@ import common
from deluge.configmanager import ConfigManager
import deluge.configmanager
log = logging.getLogger(__name__)
class Preferences(component.Component):
def __init__(self):
component.Component.__init__(self, "Preferences")
self.window = component.get("MainWindow")
self.glade = gtk.glade.XML(
pkg_resources.resource_filename("deluge.ui.gtkui",
"glade/preferences_dialog.glade"))
self.glade = gtk.glade.XML(pkg_resources.resource_filename(
"deluge.ui.gtkui", "glade/preferences_dialog.glade"
))
self.pref_dialog = self.glade.get_widget("pref_dialog")
self.pref_dialog.set_icon(common.get_deluge_icon())
self.treeview = self.glade.get_widget("treeview")

Some files were not shown because too many files have changed in this diff Show More