mirror of
https://github.com/codex-storage/deluge.git
synced 2025-01-11 03:55:43 +00:00
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:
parent
3d64f0d8da
commit
3b00a7de59
@ -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
|
||||
|
@ -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__
|
||||
@ -527,7 +529,7 @@ def path_join(*parts):
|
||||
path += '/' + part
|
||||
return path
|
||||
|
||||
XML_ESCAPES = (
|
||||
XML_ESCAPES = (
|
||||
('&', '&'),
|
||||
('<', '<'),
|
||||
('>', '>'),
|
||||
@ -536,9 +538,9 @@ XML_ESCAPES = (
|
||||
)
|
||||
|
||||
def xml_decode(string):
|
||||
"""
|
||||
"""
|
||||
Unescape a string that was previously encoded for use within xml.
|
||||
|
||||
|
||||
:param string: The string to escape
|
||||
:type string: string
|
||||
:returns: The unescaped version of the string.
|
||||
@ -549,9 +551,9 @@ def xml_decode(string):
|
||||
return string
|
||||
|
||||
def xml_encode(string):
|
||||
"""
|
||||
"""
|
||||
Escape a string for use within an xml element or attribute.
|
||||
|
||||
|
||||
:param string: The string to escape
|
||||
:type string: string
|
||||
:returns: An escaped version of the string.
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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):
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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..")
|
||||
|
@ -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
|
||||
|
@ -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):
|
||||
|
@ -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.
|
||||
|
@ -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):
|
||||
|
@ -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):
|
||||
|
@ -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,
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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,
|
||||
@ -857,14 +858,14 @@ class TorrentManager(component.Component):
|
||||
torrent = self.torrents[str(alert.handle.info_hash())]
|
||||
except:
|
||||
return
|
||||
|
||||
|
||||
# Check to see if we're forcing a recheck and set it back to paused
|
||||
# if necessary
|
||||
if torrent.forcing_recheck:
|
||||
torrent.forcing_recheck = False
|
||||
if torrent.forcing_recheck_paused:
|
||||
torrent.handle.pause()
|
||||
|
||||
|
||||
# Set the torrent state
|
||||
torrent.update_state()
|
||||
|
||||
|
@ -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
|
||||
@ -141,7 +144,7 @@ def sanitise_filename(filename):
|
||||
log.warning("Potentially malicious server: trying to write to file '%s'" % filename)
|
||||
# Only use the basename
|
||||
filename = os.path.basename(filename)
|
||||
|
||||
|
||||
filename = filename.strip()
|
||||
if filename.startswith(".") or ";" in filename or "|" in filename:
|
||||
# Dodgy server, log it
|
||||
@ -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.
|
||||
|
228
deluge/log.py
228
deluge/log.py
@ -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()
|
||||
|
@ -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
|
||||
|
@ -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']
|
||||
|
||||
@ -180,7 +182,7 @@ def makeinfo(path, piece_length, progress, name = None,
|
||||
if done > 0:
|
||||
pieces.append(sh.digest())
|
||||
progress(piece_count, num_pieces)
|
||||
|
||||
|
||||
if name is not None:
|
||||
assert isinstance(name, unicode)
|
||||
name = to_utf8(name)
|
||||
|
@ -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",
|
||||
|
@ -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
|
||||
@ -57,7 +59,7 @@ OPTIONS_AVAILABLE = { #option: builtin
|
||||
"enabled":False,
|
||||
"path":False,
|
||||
"append_extension":False,
|
||||
"abspath":False,
|
||||
"abspath":False,
|
||||
"download_location":True,
|
||||
"max_download_speed":True,
|
||||
"max_upload_speed":True,
|
||||
@ -88,7 +90,7 @@ def CheckInput(cond, message):
|
||||
|
||||
class Core(CorePluginBase):
|
||||
def enable(self):
|
||||
|
||||
|
||||
#reduce typing, assigning some values to self...
|
||||
self.config = deluge.configmanager.ConfigManager("autoadd.conf", DEFAULT_PREFS)
|
||||
self.watchdirs = self.config["watchdirs"]
|
||||
@ -127,7 +129,7 @@ class Core(CorePluginBase):
|
||||
|
||||
def update(self):
|
||||
pass
|
||||
|
||||
|
||||
@export()
|
||||
def set_options(self, watchdir_id, options):
|
||||
"""Update the options for a watch folder."""
|
||||
@ -147,14 +149,14 @@ class Core(CorePluginBase):
|
||||
#disable the watch loop if it was active
|
||||
if watchdir_id in self.update_timers:
|
||||
self.disable_watchdir(watchdir_id)
|
||||
|
||||
|
||||
self.watchdirs[watchdir_id].update(options)
|
||||
#re-enable watch loop if appropriate
|
||||
if self.watchdirs[watchdir_id]['enabled']:
|
||||
self.enable_watchdir(watchdir_id)
|
||||
self.config.save()
|
||||
component.get("EventManager").emit(AutoaddOptionsChangedEvent())
|
||||
|
||||
|
||||
def load_torrent(self, filename):
|
||||
try:
|
||||
log.debug("Attempting to open %s for add.", filename)
|
||||
@ -171,7 +173,7 @@ class Core(CorePluginBase):
|
||||
info = lt.torrent_info(lt.bdecode(filedump))
|
||||
|
||||
return filedump
|
||||
|
||||
|
||||
def update_watchdir(self, watchdir_id):
|
||||
"""Check the watch folder for new torrents to add."""
|
||||
watchdir_id = str(watchdir_id)
|
||||
@ -185,7 +187,7 @@ class Core(CorePluginBase):
|
||||
log.warning("Invalid AutoAdd folder: %s", watchdir["abspath"])
|
||||
self.disable_watchdir(watchdir_id)
|
||||
return
|
||||
|
||||
|
||||
# Generate options dict for watchdir
|
||||
opts = {}
|
||||
if 'stop_at_ratio_toggle' in watchdir:
|
||||
@ -246,7 +248,7 @@ class Core(CorePluginBase):
|
||||
"""Disables any watch folders with unhandled exceptions."""
|
||||
self.disable_watchdir(watchdir_id)
|
||||
log.error("Disabling '%s', error during update: %s" % (self.watchdirs[watchdir_id]["path"], failure))
|
||||
|
||||
|
||||
@export
|
||||
def enable_watchdir(self, watchdir_id):
|
||||
watchdir_id = str(watchdir_id)
|
||||
@ -259,7 +261,7 @@ class Core(CorePluginBase):
|
||||
self.watchdirs[watchdir_id]['enabled'] = True
|
||||
self.config.save()
|
||||
component.get("EventManager").emit(AutoaddOptionsChangedEvent())
|
||||
|
||||
|
||||
@export
|
||||
def disable_watchdir(self, watchdir_id):
|
||||
watchdir_id = str(watchdir_id)
|
||||
@ -287,7 +289,7 @@ class Core(CorePluginBase):
|
||||
def get_config(self):
|
||||
"""Returns the config dictionary."""
|
||||
return self.config.config
|
||||
|
||||
|
||||
@export()
|
||||
def get_watchdirs(self):
|
||||
return self.watchdirs.keys()
|
||||
@ -319,7 +321,7 @@ class Core(CorePluginBase):
|
||||
self.config.save()
|
||||
component.get("EventManager").emit(AutoaddOptionsChangedEvent())
|
||||
return watchdir_id
|
||||
|
||||
|
||||
@export
|
||||
def remove(self, watchdir_id):
|
||||
"""Remove a watch folder."""
|
||||
|
@ -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"]
|
||||
@ -113,22 +115,22 @@ class OptionsDialog():
|
||||
self.glade.get_widget(field+"_entry").show()
|
||||
self.glade.get_widget(field+"_chooser").hide()
|
||||
self.set_sensitive()
|
||||
|
||||
|
||||
def on_get_enabled_plugins(result):
|
||||
if 'Label' in result:
|
||||
if 'Label' in result:
|
||||
self.glade.get_widget('label_frame').show()
|
||||
else:
|
||||
self.glade.get_widget('label_frame').hide()
|
||||
self.glade.get_widget('label_toggle').set_active(False)
|
||||
|
||||
|
||||
client.core.get_enabled_plugins().addCallback(on_get_enabled_plugins)
|
||||
|
||||
|
||||
def set_sensitive(self):
|
||||
maintoggles = ['download_location', 'append_extension', 'move_completed', 'label', \
|
||||
'max_download_speed', 'max_upload_speed', 'max_connections', \
|
||||
'max_upload_slots', 'add_paused', 'auto_managed', 'stop_at_ratio', 'queue_to_top']
|
||||
[self.on_toggle_toggled(self.glade.get_widget(x+'_toggle')) for x in maintoggles]
|
||||
|
||||
|
||||
def on_toggle_toggled(self, tb):
|
||||
toggle = str(tb.name).replace("_toggle", "")
|
||||
isactive = tb.get_active()
|
||||
@ -166,29 +168,29 @@ class OptionsDialog():
|
||||
self.glade.get_widget('stop_at_ratio').set_active(isactive)
|
||||
self.glade.get_widget('stop_ratio').set_sensitive(isactive)
|
||||
self.glade.get_widget('remove_at_ratio').set_sensitive(isactive)
|
||||
|
||||
|
||||
def on_apply(self, Event=None):
|
||||
client.autoadd.set_options(str(self.watchdir_id), self.generate_opts()).addCallbacks(self.on_added, self.on_error_show)
|
||||
|
||||
|
||||
def on_error_show(self, result):
|
||||
self.glade.get_widget('error_label').set_text(result.value.exception_msg)
|
||||
self.err_dialog = self.glade.get_widget('error_dialog')
|
||||
self.err_dialog.set_transient_for(self.dialog)
|
||||
result.cleanFailure()
|
||||
self.err_dialog.show()
|
||||
|
||||
|
||||
def on_added(self, result):
|
||||
self.dialog.destroy()
|
||||
|
||||
|
||||
def on_error_ok(self, Event=None):
|
||||
self.err_dialog.hide()
|
||||
|
||||
|
||||
def on_add(self, Event=None):
|
||||
client.autoadd.add(self.generate_opts()).addCallbacks(self.on_added, self.on_error_show)
|
||||
|
||||
|
||||
def on_cancel(self, Event=None):
|
||||
self.dialog.destroy()
|
||||
|
||||
|
||||
def generate_opts(self):
|
||||
# generate options dict based on gtk objects
|
||||
options = {}
|
||||
@ -217,11 +219,11 @@ class OptionsDialog():
|
||||
options[id] = self.glade.get_widget(id).get_active()
|
||||
options[id+'_toggle'] = self.glade.get_widget(id+'_toggle').get_active()
|
||||
return options
|
||||
|
||||
|
||||
|
||||
class GtkUI(GtkPluginBase):
|
||||
def enable(self):
|
||||
|
||||
|
||||
self.glade = gtk.glade.XML(get_resource("config.glade"))
|
||||
self.glade.signal_autoconnect({
|
||||
"on_add_button_clicked": self.on_add_button_clicked,
|
||||
@ -229,18 +231,18 @@ class GtkUI(GtkPluginBase):
|
||||
"on_remove_button_clicked": self.on_remove_button_clicked
|
||||
})
|
||||
self.opts_dialog = OptionsDialog()
|
||||
|
||||
|
||||
component.get("PluginManager").register_hook("on_apply_prefs", self.on_apply_prefs)
|
||||
component.get("PluginManager").register_hook("on_show_prefs", self.on_show_prefs)
|
||||
client.register_event_handler("AutoaddOptionsChangedEvent", self.on_options_changed_event)
|
||||
|
||||
|
||||
self.watchdirs = {}
|
||||
|
||||
|
||||
vbox = self.glade.get_widget("watchdirs_vbox")
|
||||
sw = gtk.ScrolledWindow()
|
||||
sw.set_shadow_type(gtk.SHADOW_ETCHED_IN)
|
||||
sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
|
||||
|
||||
|
||||
vbox.pack_start(sw, True, True, 0)
|
||||
|
||||
self.store = self.create_model()
|
||||
@ -256,28 +258,28 @@ class GtkUI(GtkPluginBase):
|
||||
component.get("Preferences").add_page("AutoAdd", self.glade.get_widget("prefs_box"))
|
||||
self.on_show_prefs()
|
||||
|
||||
|
||||
|
||||
def disable(self):
|
||||
component.get("Preferences").remove_page("AutoAdd")
|
||||
component.get("PluginManager").deregister_hook("on_apply_prefs", self.on_apply_prefs)
|
||||
component.get("PluginManager").deregister_hook("on_show_prefs", self.on_show_prefs)
|
||||
|
||||
|
||||
def create_model(self):
|
||||
|
||||
|
||||
store = gtk.ListStore(str, bool, str)
|
||||
for watchdir_id, watchdir in self.watchdirs.iteritems():
|
||||
store.append([watchdir_id, watchdir['enabled'], watchdir['path']])
|
||||
return store
|
||||
|
||||
|
||||
def create_columns(self, treeView):
|
||||
rendererToggle = gtk.CellRendererToggle()
|
||||
column = gtk.TreeViewColumn("On", rendererToggle, activatable=True, active=1)
|
||||
column.set_sort_column_id(1)
|
||||
column.set_sort_column_id(1)
|
||||
treeView.append_column(column)
|
||||
tt = gtk.Tooltip()
|
||||
tt.set_text('Double-click to toggle')
|
||||
treeView.set_tooltip_cell(tt, None, None, rendererToggle)
|
||||
|
||||
|
||||
rendererText = gtk.CellRendererText()
|
||||
column = gtk.TreeViewColumn("Path", rendererText, text=2)
|
||||
column.set_sort_column_id(2)
|
||||
@ -289,20 +291,20 @@ class GtkUI(GtkPluginBase):
|
||||
|
||||
def load_watchdir_list(self):
|
||||
pass
|
||||
|
||||
|
||||
def add_watchdir_entry(self):
|
||||
pass
|
||||
|
||||
|
||||
def on_add_button_clicked(self, Event=None):
|
||||
#display options_window
|
||||
self.opts_dialog.show()
|
||||
|
||||
|
||||
def on_remove_button_clicked(self, Event=None):
|
||||
tree, tree_id = self.treeView.get_selection().get_selected()
|
||||
watchdir_id = str(self.store.get_value(tree_id, 0))
|
||||
if watchdir_id:
|
||||
client.autoadd.remove(watchdir_id)
|
||||
|
||||
|
||||
def on_edit_button_clicked(self, Event=None, a=None, col=None):
|
||||
tree, tree_id = self.treeView.get_selection().get_selected()
|
||||
watchdir_id = str(self.store.get_value(tree_id, 0))
|
||||
@ -314,7 +316,7 @@ class GtkUI(GtkPluginBase):
|
||||
client.autoadd.enable_watchdir(watchdir_id)
|
||||
else:
|
||||
self.opts_dialog.show(self.watchdirs[watchdir_id], watchdir_id)
|
||||
|
||||
|
||||
def on_listitem_activated(self, treeview):
|
||||
tree, tree_id = self.treeView.get_selection().get_selected()
|
||||
if tree_id:
|
||||
@ -323,7 +325,7 @@ class GtkUI(GtkPluginBase):
|
||||
else:
|
||||
self.glade.get_widget('edit_button').set_sensitive(False)
|
||||
self.glade.get_widget('remove_button').set_sensitive(False)
|
||||
|
||||
|
||||
def on_apply_prefs(self):
|
||||
log.debug("applying prefs for AutoAdd")
|
||||
for watchdir_id, watchdir in self.watchdirs.iteritems():
|
||||
@ -331,7 +333,7 @@ class GtkUI(GtkPluginBase):
|
||||
|
||||
def on_show_prefs(self):
|
||||
client.autoadd.get_config().addCallback(self.cb_get_config)
|
||||
|
||||
|
||||
def on_options_changed_event(self):
|
||||
client.autoadd.get_config().addCallback(self.cb_get_config)
|
||||
|
||||
@ -344,4 +346,4 @@ class GtkUI(GtkPluginBase):
|
||||
# Disable the remove and edit buttons, because nothing in the store is selected
|
||||
self.glade.get_widget('remove_button').set_sensitive(False)
|
||||
self.glade.get_widget('edit_button').set_sensitive(False)
|
||||
|
||||
|
||||
|
@ -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")]
|
||||
|
@ -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,
|
||||
@ -161,7 +163,7 @@ class Core(CorePluginBase):
|
||||
def get_config(self):
|
||||
"""
|
||||
Returns the config dictionary
|
||||
|
||||
|
||||
:returns: the config dictionary
|
||||
:rtype: dict
|
||||
"""
|
||||
@ -182,7 +184,7 @@ class Core(CorePluginBase):
|
||||
def get_status(self):
|
||||
"""
|
||||
Returns the status of the plugin
|
||||
|
||||
|
||||
:returns: the status dict of the plugin
|
||||
:rtype: dict
|
||||
"""
|
||||
@ -260,7 +262,7 @@ class Core(CorePluginBase):
|
||||
def on_download_complete(self, blocklist):
|
||||
"""
|
||||
Runs any download clean up functions
|
||||
|
||||
|
||||
:param blocklist: path of blocklist
|
||||
:type blocklist: string
|
||||
:returns: a Deferred which fires when clean up is done
|
||||
@ -273,7 +275,7 @@ class Core(CorePluginBase):
|
||||
def on_download_error(self, f):
|
||||
"""
|
||||
Recovers from download error
|
||||
|
||||
|
||||
:param f: failure that occured
|
||||
:type f: Failure
|
||||
:returns: a Deferred if recovery was possible
|
||||
@ -309,7 +311,7 @@ class Core(CorePluginBase):
|
||||
def import_list(self, blocklist):
|
||||
"""
|
||||
Imports the downloaded blocklist into the session
|
||||
|
||||
|
||||
:param blocklist: path of blocklist
|
||||
:type blocklist: string
|
||||
:returns: a Deferred that fires when the blocklist has been imported
|
||||
@ -333,7 +335,7 @@ class Core(CorePluginBase):
|
||||
self.is_importing = True
|
||||
self.num_blocked = 0
|
||||
self.blocklist = self.core.session.get_ip_filter()
|
||||
|
||||
|
||||
if not blocklist:
|
||||
blocklist = self.filename
|
||||
|
||||
@ -351,7 +353,7 @@ class Core(CorePluginBase):
|
||||
def on_import_complete(self, blocklist):
|
||||
"""
|
||||
Runs any import clean up functions
|
||||
|
||||
|
||||
:param blocklist: path of blocklist
|
||||
:type blocklist: string
|
||||
:returns: a Deferred that fires when clean up is done
|
||||
@ -374,7 +376,7 @@ class Core(CorePluginBase):
|
||||
def on_import_error(self, f):
|
||||
"""
|
||||
Recovers from import error
|
||||
|
||||
|
||||
:param f: failure that occured
|
||||
:type f: Failure
|
||||
:returns: a Deferred if recovery was possible
|
||||
|
@ -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..")
|
||||
|
@ -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
|
||||
|
@ -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")
|
||||
|
@ -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!")
|
||||
|
@ -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
|
||||
|
@ -33,17 +33,19 @@
|
||||
#
|
||||
#
|
||||
|
||||
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")]
|
||||
|
||||
|
||||
# The enable and disable methods are not scrictly required on the WebUI
|
||||
# plugins. They are only here if you need to register images/stylesheets
|
||||
# with the webserver.
|
||||
|
@ -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": []
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -35,14 +35,16 @@
|
||||
|
||||
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")]
|
||||
debug_scripts = scripts
|
||||
|
@ -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
|
||||
@ -98,22 +100,22 @@ class Core(CorePluginBase):
|
||||
|
||||
# Now that we have the cmd, lets run it to extract the files
|
||||
fp = os.path.join(save_path, f["path"])
|
||||
|
||||
|
||||
# Get the destination path
|
||||
dest = self.config["extract_path"]
|
||||
if self.config["use_name_folder"]:
|
||||
name = component.get("TorrentManager")[torrent_id].get_status(["name"])["name"]
|
||||
dest = os.path.join(dest, name)
|
||||
|
||||
# Create the destination folder if it doesn't exist
|
||||
# Create the destination folder if it doesn't exist
|
||||
if not os.path.exists(dest):
|
||||
try:
|
||||
os.makedirs(dest)
|
||||
except Exception, e:
|
||||
log.error("Error creating destination folder: %s", e)
|
||||
return
|
||||
|
||||
log.debug("Extracting to %s", dest)
|
||||
|
||||
log.debug("Extracting to %s", dest)
|
||||
def on_extract_success(result, torrent_id):
|
||||
# XXX: Emit an event
|
||||
log.debug("Extract was successful for %s", torrent_id)
|
||||
|
@ -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"))
|
||||
@ -89,7 +91,7 @@ class GtkUI(GtkPluginBase):
|
||||
self.glade.get_widget("folderchooser_path").set_current_folder(config["extract_path"])
|
||||
else:
|
||||
self.glade.get_widget("entry_path").set_text(config["extract_path"])
|
||||
|
||||
|
||||
self.glade.get_widget("chk_use_name").set_active(config["use_name_folder"])
|
||||
|
||||
client.extractor.get_config().addCallback(on_get_config)
|
||||
|
@ -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
|
||||
|
@ -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": {},
|
||||
|
@ -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
|
||||
|
||||
@ -54,7 +56,7 @@ class feed_page:
|
||||
items = """%(old)s
|
||||
<a href="%(link)s">
|
||||
<li>%(entry)s</li>
|
||||
</a>""" % { "old":items, "entry":item, "link":entries[item]}
|
||||
</a>""" % { "old":items, "entry":item, "link":entries[item]}
|
||||
return api.render.feeder.feeds(items, feedname)
|
||||
|
||||
class filter_page:
|
||||
@ -63,7 +65,7 @@ class filter_page:
|
||||
def GET(self, args):
|
||||
new_filter = new_filter_form()
|
||||
filters = sclient.feeder_get_filters()
|
||||
|
||||
|
||||
# List filters
|
||||
txt = ""
|
||||
for filter in filters:
|
||||
@ -83,7 +85,7 @@ class filter_page:
|
||||
class new_filter_form(forms.Form):
|
||||
"basic form for a new label"
|
||||
name = forms.CharField(label="")
|
||||
|
||||
|
||||
class filter_settings_page:
|
||||
"Class for showing filter settings"
|
||||
@api.deco.deluge_page
|
||||
@ -117,7 +119,7 @@ class filter_settings_page:
|
||||
opts['max_upload_slots'] = int(-1)
|
||||
"""opts['max_upload_slots'] = long(opts['max_upload_slots'])
|
||||
opts['max_connections'] = long(opts['max_connections'])"""
|
||||
|
||||
|
||||
# TODO filter settings per feed not implemented.
|
||||
opts['feeds'] = []
|
||||
|
||||
@ -151,7 +153,7 @@ class filter_settings_form(forms.Form):
|
||||
</ul>
|
||||
""" % list
|
||||
|
||||
regex = forms.CharField(_("regular_expression"))
|
||||
regex = forms.CharField(_("regular_expression"))
|
||||
all_feeds = forms.CheckBox(_("all_feeds"))
|
||||
active = forms.CheckBox(_("active"))
|
||||
|
||||
@ -204,7 +206,7 @@ class remove_filter_page:
|
||||
</body>
|
||||
|
||||
</html>"""
|
||||
|
||||
|
||||
|
||||
class WebUI(WebUIPluginBase):
|
||||
#map url's to classes: [(url,class), ..]
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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
|
||||
|
@ -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):
|
||||
|
@ -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")]
|
||||
|
@ -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"
|
||||
|
@ -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
|
||||
|
@ -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']
|
||||
|
@ -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):
|
||||
|
@ -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):
|
||||
"""
|
||||
|
@ -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:
|
||||
|
@ -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):
|
||||
|
@ -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))
|
||||
|
||||
|
@ -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>
|
||||
|
@ -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
|
||||
|
@ -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": "",
|
||||
|
@ -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
|
||||
|
@ -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"""
|
||||
|
@ -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,
|
||||
|
@ -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"
|
||||
|
@ -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):
|
||||
|
||||
@ -42,7 +44,7 @@ class PluginBase(component.Component):
|
||||
|
||||
def __init__(self, name):
|
||||
super(PluginBase, self).__init__(name, self.update_interval)
|
||||
|
||||
|
||||
def enable(self):
|
||||
raise NotImplementedError("Need to define an enable method!")
|
||||
|
||||
@ -62,20 +64,20 @@ class GtkPluginBase(PluginBase):
|
||||
log.debug("GtkPlugin initialized..")
|
||||
|
||||
class WebPluginBase(PluginBase):
|
||||
|
||||
|
||||
scripts = []
|
||||
debug_scripts = []
|
||||
|
||||
|
||||
stylesheets = []
|
||||
debug_stylesheets = []
|
||||
|
||||
|
||||
def __init__(self, plugin_name):
|
||||
super(WebPluginBase, self).__init__("WebPlugin." + plugin_name)
|
||||
|
||||
|
||||
# Register JSON rpc methods
|
||||
component.get("JSON").register_object(self, plugin_name.lower())
|
||||
log.debug("WebPlugin initialized..")
|
||||
|
||||
|
||||
def enable(self):
|
||||
pass
|
||||
|
||||
|
@ -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,
|
||||
|
@ -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):
|
||||
|
@ -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")]
|
||||
|
||||
scripts = [get_resource("scheduler.js")]
|
||||
|
@ -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.
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
@ -33,17 +33,19 @@
|
||||
#
|
||||
#
|
||||
|
||||
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")]
|
||||
|
||||
|
||||
# The enable and disable methods are not scrictly required on the WebUI
|
||||
# plugins. They are only here if you need to register images/stylesheets
|
||||
# with the webserver.
|
||||
|
@ -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 = {
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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")]
|
||||
|
@ -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,
|
||||
@ -50,8 +52,8 @@ DEFAULT_PREFS = {
|
||||
}
|
||||
|
||||
class Core(CorePluginBase):
|
||||
|
||||
|
||||
|
||||
|
||||
def enable(self):
|
||||
self.config = configmanager.ConfigManager("web_plugin.conf", DEFAULT_PREFS)
|
||||
self.server = None
|
||||
@ -64,13 +66,13 @@ class Core(CorePluginBase):
|
||||
|
||||
def update(self):
|
||||
pass
|
||||
|
||||
|
||||
def restart(self):
|
||||
if self.server:
|
||||
self.server.stop().addCallback(self.on_stop)
|
||||
else:
|
||||
self.start()
|
||||
|
||||
|
||||
def on_stop(self, *args):
|
||||
self.start()
|
||||
|
||||
@ -81,7 +83,7 @@ class Core(CorePluginBase):
|
||||
return True
|
||||
except ImportError:
|
||||
return False
|
||||
|
||||
|
||||
@export
|
||||
def start(self):
|
||||
if not self.server:
|
||||
@ -96,7 +98,7 @@ class Core(CorePluginBase):
|
||||
self.server.https = self.config["ssl"]
|
||||
self.server.start(False)
|
||||
return True
|
||||
|
||||
|
||||
@export
|
||||
def stop(self):
|
||||
if self.server:
|
||||
@ -110,7 +112,7 @@ class Core(CorePluginBase):
|
||||
if "enabled" in config:
|
||||
if config["enabled"] != self.config["enabled"]:
|
||||
action = config["enabled"] and 'start' or 'stop'
|
||||
|
||||
|
||||
if "ssl" in config:
|
||||
if not action:
|
||||
action = 'restart'
|
||||
@ -118,7 +120,7 @@ class Core(CorePluginBase):
|
||||
for key in config.keys():
|
||||
self.config[key] = config[key]
|
||||
self.config.save()
|
||||
|
||||
|
||||
if action == 'start':
|
||||
return self.start()
|
||||
elif action == 'stop':
|
||||
|
@ -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"))
|
||||
@ -80,7 +82,7 @@ class GtkUI(GtkPluginBase):
|
||||
self.glade.get_widget("enabled_checkbutton").set_active(config["enabled"])
|
||||
self.glade.get_widget("ssl_checkbutton").set_active(config["ssl"])
|
||||
self.glade.get_widget("port_spinbutton").set_value(config["port"])
|
||||
|
||||
|
||||
def cb_chk_deluge_web(self, have_web):
|
||||
self.have_web = have_web
|
||||
if have_web:
|
||||
|
@ -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
21
deluge/tests/test_log.py
Normal 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()
|
@ -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()])
|
||||
|
||||
@ -140,7 +142,7 @@ class DelugeRPCProtocol(Protocol):
|
||||
while data:
|
||||
# Increase the byte counter
|
||||
self.factory.bytes_recv += len(data)
|
||||
|
||||
|
||||
dobj = zlib.decompressobj()
|
||||
try:
|
||||
request = rencode.loads(dobj.decompress(data))
|
||||
@ -213,7 +215,7 @@ class DelugeRPCClientFactory(ClientFactory):
|
||||
def __init__(self, daemon, event_handlers):
|
||||
self.daemon = daemon
|
||||
self.event_handlers = event_handlers
|
||||
|
||||
|
||||
self.bytes_recv = 0
|
||||
self.bytes_sent = 0
|
||||
|
||||
@ -329,7 +331,7 @@ class DaemonSSLProxy(DaemonProxy):
|
||||
|
||||
:param request_id: the request_id of the Deferred to pop
|
||||
:type request_id: int
|
||||
|
||||
|
||||
"""
|
||||
return self.__deferred.pop(request_id)
|
||||
|
||||
@ -343,7 +345,7 @@ class DaemonSSLProxy(DaemonProxy):
|
||||
:param handler: the function to be called when `:param:event`
|
||||
is emitted from the daemon
|
||||
:type handler: function
|
||||
|
||||
|
||||
"""
|
||||
if event not in self.__factory.event_handlers:
|
||||
# This is a new event to handle, so we need to tell the daemon
|
||||
@ -422,10 +424,10 @@ class DaemonSSLProxy(DaemonProxy):
|
||||
|
||||
def get_bytes_recv(self):
|
||||
return self.__factory.bytes_recv
|
||||
|
||||
|
||||
def get_bytes_sent(self):
|
||||
return self.__factory.bytes_sent
|
||||
|
||||
|
||||
class DaemonClassicProxy(DaemonProxy):
|
||||
def __init__(self, event_handlers={}):
|
||||
import deluge.core.daemon
|
||||
@ -466,7 +468,7 @@ class DaemonClassicProxy(DaemonProxy):
|
||||
:param handler: the function to be called when `:param:event`
|
||||
is emitted from the daemon
|
||||
:type handler: function
|
||||
|
||||
|
||||
"""
|
||||
self.__daemon.core.eventmanager.register_event_handler(event, handler)
|
||||
|
||||
@ -571,7 +573,7 @@ class Client(object):
|
||||
:rtype: bool
|
||||
|
||||
:raises OSError: received from subprocess.call()
|
||||
|
||||
|
||||
"""
|
||||
try:
|
||||
if deluge.common.windows_check():
|
||||
@ -679,7 +681,7 @@ class Client(object):
|
||||
def get_bytes_recv(self):
|
||||
"""
|
||||
Returns the number of bytes received from the daemon.
|
||||
|
||||
|
||||
:returns: the number of bytes received
|
||||
:rtype: int
|
||||
"""
|
||||
@ -688,11 +690,11 @@ class Client(object):
|
||||
def get_bytes_sent(self):
|
||||
"""
|
||||
Returns the number of bytes sent to the daemon.
|
||||
|
||||
|
||||
:returns: the number of bytes sent
|
||||
:rtype: int
|
||||
"""
|
||||
return self._daemon_proxy.get_bytes_sent()
|
||||
|
||||
|
||||
# This is the object clients will use
|
||||
client = Client()
|
||||
|
@ -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.
|
||||
|
@ -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"""
|
||||
|
@ -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):
|
||||
"""
|
||||
|
@ -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"""
|
||||
|
@ -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"""
|
||||
|
@ -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):
|
||||
|
@ -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")
|
||||
|
@ -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():
|
||||
|
@ -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
|
||||
|
||||
|
@ -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):
|
||||
|
@ -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):
|
||||
|
@ -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):
|
||||
|
@ -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:
|
||||
|
@ -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",
|
||||
@ -126,7 +128,7 @@ class FilterTreeView(component.Component):
|
||||
# Force the theme to use an expander-size of 15 so that we don't cut out
|
||||
# entries due to our indentation hack.
|
||||
gtk.rc_parse_string('style "treeview-style" { GtkTreeView::expander-size = 15 } class "GtkTreeView" style "treeview-style"')
|
||||
|
||||
|
||||
self.label_view.set_model(self.treestore)
|
||||
self.label_view.get_selection().connect("changed", self.on_selection_changed)
|
||||
self.create_model_filter()
|
||||
|
@ -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:
|
||||
|
@ -37,22 +37,24 @@
|
||||
import sys
|
||||
import os
|
||||
import base64
|
||||
import logging
|
||||
|
||||
try:
|
||||
import rencode
|
||||
except ImportError:
|
||||
import deluge.rencode as rencode
|
||||
|
||||
|
||||
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)
|
||||
@ -62,11 +64,11 @@ class IPCProtocolClient(Protocol):
|
||||
def connectionMade(self):
|
||||
self.transport.write(rencode.dumps(self.factory.args))
|
||||
self.transport.loseConnection()
|
||||
|
||||
|
||||
def connectionLost(self, reason):
|
||||
reactor.stop()
|
||||
self.factory.stop = True
|
||||
|
||||
|
||||
class IPCClientFactory(ClientFactory):
|
||||
protocol = IPCProtocolClient
|
||||
|
||||
@ -74,11 +76,11 @@ class IPCClientFactory(ClientFactory):
|
||||
self.stop = False
|
||||
self.args = args
|
||||
self.connect_failed = connect_failed
|
||||
|
||||
|
||||
def clientConnectionFailed(self, connector, reason):
|
||||
log.info("Connection to running instance failed. Starting new one..")
|
||||
reactor.stop()
|
||||
|
||||
|
||||
class IPCInterface(component.Component):
|
||||
def __init__(self, args):
|
||||
component.Component.__init__(self, "IPCInterface")
|
||||
@ -165,7 +167,7 @@ class IPCInterface(component.Component):
|
||||
os.remove(socket)
|
||||
except Exception, e:
|
||||
log.error("Unable to remove socket file: %s", e)
|
||||
|
||||
|
||||
lock = socket + ".lock"
|
||||
if os.path.lexists(lock):
|
||||
try:
|
||||
@ -180,7 +182,7 @@ class IPCInterface(component.Component):
|
||||
log.error("Unable to start IPC listening socket: %s", e)
|
||||
finally:
|
||||
process_args(args)
|
||||
|
||||
|
||||
def shutdown(self):
|
||||
if deluge.common.windows_check():
|
||||
import win32api
|
||||
|
@ -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):
|
||||
|
@ -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):
|
||||
|
@ -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):
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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):
|
||||
|
@ -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
Loading…
x
Reference in New Issue
Block a user