mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-02 22:48:40 +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
113 changed files with 795 additions and 321 deletions
|
@ -1,4 +1,6 @@
|
||||||
=== Deluge 1.3.0 (In Development) ===
|
=== Deluge 1.3.0 (In Development) ===
|
||||||
|
* Improved Logging
|
||||||
|
|
||||||
==== Core ====
|
==== Core ====
|
||||||
* Implement #1063 option to delete torrent file copy on torrent removal - patch from Ghent
|
* Implement #1063 option to delete torrent file copy on torrent removal - patch from Ghent
|
||||||
* Implement #457 progress bars for folders
|
* Implement #457 progress bars for folders
|
||||||
|
|
|
@ -42,12 +42,15 @@ import subprocess
|
||||||
import platform
|
import platform
|
||||||
import sys
|
import sys
|
||||||
import chardet
|
import chardet
|
||||||
|
import logging
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import json
|
import json
|
||||||
except ImportError:
|
except ImportError:
|
||||||
import simplejson as json
|
import simplejson as json
|
||||||
|
|
||||||
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
# Do a little hack here just in case the user has json-py installed since it
|
# Do a little hack here just in case the user has json-py installed since it
|
||||||
# has a different api
|
# has a different api
|
||||||
if not hasattr(json, "dumps"):
|
if not hasattr(json, "dumps"):
|
||||||
|
@ -77,7 +80,6 @@ try:
|
||||||
gettext.textdomain("deluge")
|
gettext.textdomain("deluge")
|
||||||
gettext.install("deluge", pkg_resources.resource_filename("deluge", "i18n"))
|
gettext.install("deluge", pkg_resources.resource_filename("deluge", "i18n"))
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
from deluge.log import LOG as log
|
|
||||||
log.error("Unable to initialize gettext/locale!")
|
log.error("Unable to initialize gettext/locale!")
|
||||||
log.exception(e)
|
log.exception(e)
|
||||||
import __builtin__
|
import __builtin__
|
||||||
|
@ -527,7 +529,7 @@ def path_join(*parts):
|
||||||
path += '/' + part
|
path += '/' + part
|
||||||
return path
|
return path
|
||||||
|
|
||||||
XML_ESCAPES = (
|
XML_ESCAPES = (
|
||||||
('&', '&'),
|
('&', '&'),
|
||||||
('<', '<'),
|
('<', '<'),
|
||||||
('>', '>'),
|
('>', '>'),
|
||||||
|
@ -536,9 +538,9 @@ XML_ESCAPES = (
|
||||||
)
|
)
|
||||||
|
|
||||||
def xml_decode(string):
|
def xml_decode(string):
|
||||||
"""
|
"""
|
||||||
Unescape a string that was previously encoded for use within xml.
|
Unescape a string that was previously encoded for use within xml.
|
||||||
|
|
||||||
:param string: The string to escape
|
:param string: The string to escape
|
||||||
:type string: string
|
:type string: string
|
||||||
:returns: The unescaped version of the string.
|
:returns: The unescaped version of the string.
|
||||||
|
@ -549,9 +551,9 @@ def xml_decode(string):
|
||||||
return string
|
return string
|
||||||
|
|
||||||
def xml_encode(string):
|
def xml_encode(string):
|
||||||
"""
|
"""
|
||||||
Escape a string for use within an xml element or attribute.
|
Escape a string for use within an xml element or attribute.
|
||||||
|
|
||||||
:param string: The string to escape
|
:param string: The string to escape
|
||||||
:type string: string
|
:type string: string
|
||||||
:returns: An escaped version of the 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.defer import maybeDeferred, succeed, DeferredList, fail
|
||||||
from twisted.internet.task import LoopingCall
|
from twisted.internet.task import LoopingCall
|
||||||
from deluge.log import LOG as log
|
|
||||||
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
class ComponentAlreadyRegistered(Exception):
|
class ComponentAlreadyRegistered(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -68,14 +68,16 @@ version as this will be done internally.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import cPickle as pickle
|
import cPickle as pickle
|
||||||
|
import logging
|
||||||
import shutil
|
import shutil
|
||||||
import os
|
import os
|
||||||
|
|
||||||
import deluge.common
|
import deluge.common
|
||||||
from deluge.log import LOG as log
|
|
||||||
|
|
||||||
json = deluge.common.json
|
json = deluge.common.json
|
||||||
|
|
||||||
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
def prop(func):
|
def prop(func):
|
||||||
"""Function decorator for defining property attributes
|
"""Function decorator for defining property attributes
|
||||||
|
|
||||||
|
|
|
@ -34,11 +34,14 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import logging
|
||||||
|
|
||||||
import deluge.common
|
import deluge.common
|
||||||
from deluge.log import LOG as log
|
import deluge.log
|
||||||
from deluge.config import Config
|
from deluge.config import Config
|
||||||
|
|
||||||
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
class _ConfigManager:
|
class _ConfigManager:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
log.debug("ConfigManager started..")
|
log.debug("ConfigManager started..")
|
||||||
|
@ -86,6 +89,7 @@ class _ConfigManager:
|
||||||
# to reload based on the new config directory
|
# to reload based on the new config directory
|
||||||
self.save()
|
self.save()
|
||||||
self.config_files = {}
|
self.config_files = {}
|
||||||
|
deluge.log.tweak_logging_levels()
|
||||||
|
|
||||||
return True
|
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
|
from twisted.internet import reactor
|
||||||
|
|
||||||
import deluge.component as component
|
import deluge.component as component
|
||||||
from deluge._libtorrent import lt
|
from deluge._libtorrent import lt
|
||||||
|
|
||||||
from deluge.log import LOG as log
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
class AlertManager(component.Component):
|
class AlertManager(component.Component):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|
|
@ -36,12 +36,13 @@
|
||||||
import os
|
import os
|
||||||
import random
|
import random
|
||||||
import stat
|
import stat
|
||||||
|
import logging
|
||||||
|
|
||||||
import deluge.component as component
|
import deluge.component as component
|
||||||
import deluge.configmanager as configmanager
|
import deluge.configmanager as configmanager
|
||||||
import deluge.error
|
import deluge.error
|
||||||
|
|
||||||
from deluge.log import LOG as log
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
AUTH_LEVEL_NONE = 0
|
AUTH_LEVEL_NONE = 0
|
||||||
AUTH_LEVEL_READONLY = 1
|
AUTH_LEVEL_READONLY = 1
|
||||||
|
|
|
@ -35,15 +35,17 @@
|
||||||
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import logging
|
||||||
|
|
||||||
from deluge._libtorrent import lt
|
from deluge._libtorrent import lt
|
||||||
|
|
||||||
import deluge.component as component
|
import deluge.component as component
|
||||||
from deluge.configmanager import ConfigManager
|
from deluge.configmanager import ConfigManager
|
||||||
from deluge.log import LOG as log
|
|
||||||
|
|
||||||
MAX_NUM_ATTEMPTS = 10
|
MAX_NUM_ATTEMPTS = 10
|
||||||
|
|
||||||
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
class AutoAdd(component.Component):
|
class AutoAdd(component.Component):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
component.Component.__init__(self, "AutoAdd", depend=["TorrentManager"], interval=5)
|
component.Component.__init__(self, "AutoAdd", depend=["TorrentManager"], interval=5)
|
||||||
|
|
|
@ -39,6 +39,7 @@ import os
|
||||||
import glob
|
import glob
|
||||||
import base64
|
import base64
|
||||||
import shutil
|
import shutil
|
||||||
|
import logging
|
||||||
import threading
|
import threading
|
||||||
import pkg_resources
|
import pkg_resources
|
||||||
import warnings
|
import warnings
|
||||||
|
@ -50,9 +51,6 @@ from twisted.internet.task import LoopingCall
|
||||||
import twisted.web.client
|
import twisted.web.client
|
||||||
|
|
||||||
from deluge.httpdownloader import download_file
|
from deluge.httpdownloader import download_file
|
||||||
from deluge.log import LOG as log
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import deluge.configmanager
|
import deluge.configmanager
|
||||||
import deluge.common
|
import deluge.common
|
||||||
|
@ -69,6 +67,8 @@ from deluge.core.authmanager import AuthManager
|
||||||
from deluge.core.eventmanager import EventManager
|
from deluge.core.eventmanager import EventManager
|
||||||
from deluge.core.rpcserver import export
|
from deluge.core.rpcserver import export
|
||||||
|
|
||||||
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
class Core(component.Component):
|
class Core(component.Component):
|
||||||
def __init__(self, listen_interface=None):
|
def __init__(self, listen_interface=None):
|
||||||
log.debug("Core init..")
|
log.debug("Core init..")
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
import os
|
import os
|
||||||
import gettext
|
import gettext
|
||||||
import locale
|
import locale
|
||||||
|
import logging
|
||||||
import pkg_resources
|
import pkg_resources
|
||||||
from twisted.internet import reactor
|
from twisted.internet import reactor
|
||||||
import twisted.internet.error
|
import twisted.internet.error
|
||||||
|
@ -43,9 +44,10 @@ import deluge.component as component
|
||||||
import deluge.configmanager
|
import deluge.configmanager
|
||||||
import deluge.common
|
import deluge.common
|
||||||
from deluge.core.rpcserver import RPCServer, export
|
from deluge.core.rpcserver import RPCServer, export
|
||||||
from deluge.log import LOG as log
|
|
||||||
import deluge.error
|
import deluge.error
|
||||||
|
|
||||||
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
class Daemon(object):
|
class Daemon(object):
|
||||||
def __init__(self, options=None, args=None, classic=False):
|
def __init__(self, options=None, args=None, classic=False):
|
||||||
# Check for another running instance of the daemon
|
# Check for another running instance of the daemon
|
||||||
|
|
|
@ -33,8 +33,10 @@
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
|
|
||||||
|
import logging
|
||||||
import deluge.component as component
|
import deluge.component as component
|
||||||
from deluge.log import LOG as log
|
|
||||||
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
class EventManager(component.Component):
|
class EventManager(component.Component):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|
|
@ -33,12 +33,13 @@
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
|
|
||||||
|
import logging
|
||||||
import deluge.component as component
|
import deluge.component as component
|
||||||
from deluge.log import LOG as log
|
|
||||||
|
|
||||||
STATE_SORT = ["All", "Downloading", "Seeding", "Active", "Paused", "Queued"]
|
STATE_SORT = ["All", "Downloading", "Seeding", "Active", "Paused", "Queued"]
|
||||||
|
|
||||||
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
#special purpose filters:
|
#special purpose filters:
|
||||||
def filter_keywords(torrent_ids, values):
|
def filter_keywords(torrent_ids, values):
|
||||||
#cleanup.
|
#cleanup.
|
||||||
|
|
|
@ -39,12 +39,14 @@ import os.path
|
||||||
import pickle
|
import pickle
|
||||||
import cPickle
|
import cPickle
|
||||||
import shutil
|
import shutil
|
||||||
|
import logging
|
||||||
|
|
||||||
from deluge._libtorrent import lt
|
from deluge._libtorrent import lt
|
||||||
|
|
||||||
from deluge.configmanager import ConfigManager, get_config_dir
|
from deluge.configmanager import ConfigManager, get_config_dir
|
||||||
import deluge.core.torrentmanager
|
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
|
#start : http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/286203
|
||||||
def makeFakeClass(module, name):
|
def makeFakeClass(module, name):
|
||||||
|
|
|
@ -36,13 +36,15 @@
|
||||||
|
|
||||||
"""PluginManager for Core"""
|
"""PluginManager for Core"""
|
||||||
|
|
||||||
|
import logging
|
||||||
from twisted.internet import reactor
|
from twisted.internet import reactor
|
||||||
from twisted.internet.task import LoopingCall
|
from twisted.internet.task import LoopingCall
|
||||||
|
|
||||||
from deluge.event import PluginEnabledEvent, PluginDisabledEvent
|
from deluge.event import PluginEnabledEvent, PluginDisabledEvent
|
||||||
import deluge.pluginmanagerbase
|
import deluge.pluginmanagerbase
|
||||||
import deluge.component as component
|
import deluge.component as component
|
||||||
from deluge.log import LOG as log
|
|
||||||
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
class PluginManager(deluge.pluginmanagerbase.PluginManagerBase,
|
class PluginManager(deluge.pluginmanagerbase.PluginManagerBase,
|
||||||
component.Component):
|
component.Component):
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import logging
|
||||||
import threading
|
import threading
|
||||||
import pkg_resources
|
import pkg_resources
|
||||||
from twisted.internet import reactor
|
from twisted.internet import reactor
|
||||||
|
@ -46,7 +47,8 @@ from deluge.event import *
|
||||||
import deluge.configmanager
|
import deluge.configmanager
|
||||||
import deluge.common
|
import deluge.common
|
||||||
import deluge.component as component
|
import deluge.component as component
|
||||||
from deluge.log import LOG as log
|
|
||||||
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
DEFAULT_PREFS = {
|
DEFAULT_PREFS = {
|
||||||
"send_info": False,
|
"send_info": False,
|
||||||
|
|
|
@ -39,6 +39,7 @@ import sys
|
||||||
import zlib
|
import zlib
|
||||||
import os
|
import os
|
||||||
import stat
|
import stat
|
||||||
|
import logging
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
from twisted.internet.protocol import Factory, Protocol
|
from twisted.internet.protocol import Factory, Protocol
|
||||||
|
@ -52,8 +53,6 @@ try:
|
||||||
except ImportError:
|
except ImportError:
|
||||||
import deluge.rencode as rencode
|
import deluge.rencode as rencode
|
||||||
|
|
||||||
from deluge.log import LOG as log
|
|
||||||
|
|
||||||
import deluge.component as component
|
import deluge.component as component
|
||||||
import deluge.configmanager
|
import deluge.configmanager
|
||||||
from deluge.core.authmanager import AUTH_LEVEL_NONE, AUTH_LEVEL_DEFAULT
|
from deluge.core.authmanager import AUTH_LEVEL_NONE, AUTH_LEVEL_DEFAULT
|
||||||
|
@ -62,6 +61,8 @@ RPC_RESPONSE = 1
|
||||||
RPC_ERROR = 2
|
RPC_ERROR = 2
|
||||||
RPC_EVENT = 3
|
RPC_EVENT = 3
|
||||||
|
|
||||||
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
def export(auth_level=AUTH_LEVEL_DEFAULT):
|
def export(auth_level=AUTH_LEVEL_DEFAULT):
|
||||||
"""
|
"""
|
||||||
Decorator function to register an object's method as an RPC. The object
|
Decorator function to register an object's method as an RPC. The object
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
|
import logging
|
||||||
from urllib import unquote
|
from urllib import unquote
|
||||||
from urlparse import urlparse
|
from urlparse import urlparse
|
||||||
|
|
||||||
|
@ -44,11 +45,12 @@ from deluge._libtorrent import lt
|
||||||
import deluge.common
|
import deluge.common
|
||||||
import deluge.component as component
|
import deluge.component as component
|
||||||
from deluge.configmanager import ConfigManager, get_config_dir
|
from deluge.configmanager import ConfigManager, get_config_dir
|
||||||
from deluge.log import LOG as log
|
|
||||||
from deluge.event import *
|
from deluge.event import *
|
||||||
|
|
||||||
TORRENT_STATE = deluge.common.TORRENT_STATE
|
TORRENT_STATE = deluge.common.TORRENT_STATE
|
||||||
|
|
||||||
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
class TorrentOptions(dict):
|
class TorrentOptions(dict):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
config = ConfigManager("core.conf").config
|
config = ConfigManager("core.conf").config
|
||||||
|
|
|
@ -41,6 +41,7 @@ import os
|
||||||
import time
|
import time
|
||||||
import shutil
|
import shutil
|
||||||
import operator
|
import operator
|
||||||
|
import logging
|
||||||
|
|
||||||
from twisted.internet import reactor
|
from twisted.internet import reactor
|
||||||
from twisted.internet.task import LoopingCall
|
from twisted.internet.task import LoopingCall
|
||||||
|
@ -56,7 +57,7 @@ from deluge.core.torrent import TorrentOptions
|
||||||
import deluge.core.oldstateupgrader
|
import deluge.core.oldstateupgrader
|
||||||
from deluge.common import utf8_encoded
|
from deluge.common import utf8_encoded
|
||||||
|
|
||||||
from deluge.log import LOG as log
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
class TorrentState:
|
class TorrentState:
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
|
@ -857,14 +858,14 @@ class TorrentManager(component.Component):
|
||||||
torrent = self.torrents[str(alert.handle.info_hash())]
|
torrent = self.torrents[str(alert.handle.info_hash())]
|
||||||
except:
|
except:
|
||||||
return
|
return
|
||||||
|
|
||||||
# Check to see if we're forcing a recheck and set it back to paused
|
# Check to see if we're forcing a recheck and set it back to paused
|
||||||
# if necessary
|
# if necessary
|
||||||
if torrent.forcing_recheck:
|
if torrent.forcing_recheck:
|
||||||
torrent.forcing_recheck = False
|
torrent.forcing_recheck = False
|
||||||
if torrent.forcing_recheck_paused:
|
if torrent.forcing_recheck_paused:
|
||||||
torrent.handle.pause()
|
torrent.handle.pause()
|
||||||
|
|
||||||
# Set the torrent state
|
# Set the torrent state
|
||||||
torrent.update_state()
|
torrent.update_state()
|
||||||
|
|
||||||
|
|
|
@ -36,16 +36,19 @@ from twisted.web import client, http
|
||||||
from twisted.web.error import PageRedirect
|
from twisted.web.error import PageRedirect
|
||||||
from twisted.python.failure import Failure
|
from twisted.python.failure import Failure
|
||||||
from twisted.internet import reactor
|
from twisted.internet import reactor
|
||||||
from deluge.log import setupLogger, LOG as log
|
|
||||||
from common import get_version
|
from common import get_version
|
||||||
|
import logging
|
||||||
import os.path
|
import os.path
|
||||||
import zlib
|
import zlib
|
||||||
|
|
||||||
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
class HTTPDownloader(client.HTTPDownloader):
|
class HTTPDownloader(client.HTTPDownloader):
|
||||||
"""
|
"""
|
||||||
Factory class for downloading files and keeping track of progress.
|
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
|
:param url: the url to download from
|
||||||
:type url: string
|
:type url: string
|
||||||
|
@ -141,7 +144,7 @@ def sanitise_filename(filename):
|
||||||
log.warning("Potentially malicious server: trying to write to file '%s'" % filename)
|
log.warning("Potentially malicious server: trying to write to file '%s'" % filename)
|
||||||
# Only use the basename
|
# Only use the basename
|
||||||
filename = os.path.basename(filename)
|
filename = os.path.basename(filename)
|
||||||
|
|
||||||
filename = filename.strip()
|
filename = filename.strip()
|
||||||
if filename.startswith(".") or ";" in filename or "|" in filename:
|
if filename.startswith(".") or ";" in filename or "|" in filename:
|
||||||
# Dodgy server, log it
|
# Dodgy server, log it
|
||||||
|
@ -152,7 +155,8 @@ def sanitise_filename(filename):
|
||||||
|
|
||||||
return 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
|
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.
|
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
|
# log.py
|
||||||
#
|
#
|
||||||
# Copyright (C) 2007 Andrew Resch <andrewresch@gmail.com>
|
# Copyright (C) 2007 Andrew Resch <andrewresch@gmail.com>
|
||||||
|
# Copyright (C) 2010 Pedro Algarvio <pedro@algarvio.me>
|
||||||
#
|
#
|
||||||
# Deluge is free software.
|
# Deluge is free software.
|
||||||
#
|
#
|
||||||
|
@ -33,18 +34,100 @@
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
||||||
"""Logging functions"""
|
"""Logging functions"""
|
||||||
|
|
||||||
|
import os
|
||||||
import logging
|
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 = {
|
levels = {
|
||||||
"info": logging.INFO,
|
"info": logging.INFO,
|
||||||
"warning": logging.WARNING,
|
"warning": logging.WARNING,
|
||||||
"error": logging.ERROR,
|
"error": logging.ERROR,
|
||||||
"none": logging.CRITICAL,
|
"none": logging.CRITICAL,
|
||||||
"debug": logging.DEBUG
|
"debug": logging.DEBUG,
|
||||||
|
"trace": 5,
|
||||||
|
"garbage": 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def setupLogger(level="error", filename=None, filemode="w"):
|
def setupLogger(level="error", filename=None, filemode="w"):
|
||||||
"""
|
"""
|
||||||
Sets up the basic logger and if `:param:filename` is set, then it will log
|
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 level: str, the level to log
|
||||||
:param filename: str, the file to log to
|
:param filename: str, the file to log to
|
||||||
"""
|
"""
|
||||||
|
import logging
|
||||||
|
|
||||||
if not level or level not in levels:
|
if logging.getLoggerClass() is not Logging:
|
||||||
level = "error"
|
logging.setLoggerClass(Logging)
|
||||||
|
|
||||||
logging.basicConfig(
|
level = levels.get(level, "error")
|
||||||
level=levels[level],
|
|
||||||
format="[%(levelname)-8s] %(asctime)s %(module)s:%(lineno)d %(message)s",
|
rootLogger = logging.getLogger()
|
||||||
datefmt="%H:%M:%S",
|
|
||||||
filename=filename,
|
if filename and filemode=='a':
|
||||||
filemode=filemode
|
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.
|
Sets the logger level.
|
||||||
|
|
||||||
:param level: str, a string representing the desired 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:
|
logging.getLogger(logger_name).setLevel(levels.get(level, "error"))
|
||||||
return
|
|
||||||
|
|
||||||
global LOG
|
|
||||||
LOG.setLevel(levels[level])
|
|
||||||
|
|
||||||
# Get the logger
|
def getPluginLogger(logger_name):
|
||||||
LOG = logging.getLogger("deluge")
|
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
|
# main.py
|
||||||
#
|
#
|
||||||
# Copyright (C) 2007 Andrew Resch <andrewresch@gmail.com>
|
# Copyright (C) 2007 Andrew Resch <andrewresch@gmail.com>
|
||||||
|
# Copyright (C) 2010 Pedro Algarvio <pedro@algarvio.me>
|
||||||
#
|
#
|
||||||
# Deluge is free software.
|
# Deluge is free software.
|
||||||
#
|
#
|
||||||
|
@ -44,8 +45,7 @@ import sys
|
||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
|
|
||||||
import deluge.log
|
import deluge.log
|
||||||
import deluge.common
|
#import deluge.common
|
||||||
import deluge.configmanager
|
|
||||||
import deluge.error
|
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")
|
help="Set the log level: none, info, warning, error, critical, debug", action="store", type="str")
|
||||||
parser.add_option("-q", "--quiet", dest="quiet",
|
parser.add_option("-q", "--quiet", dest="quiet",
|
||||||
help="Sets the log level to 'none', this is the same as `-L none`", action="store_true", default=False)
|
help="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",
|
parser.add_option("-s", "--set-default-ui", dest="default_ui",
|
||||||
help="Sets the default UI to be run when no UI is specified", action="store", type="str")
|
help="Sets the default UI to be run when no UI is specified", action="store", type="str")
|
||||||
|
|
||||||
# Get the options and args from the OptionParser
|
# Get the options and args from the OptionParser
|
||||||
(options, args) = parser.parse_args()
|
(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 options.config:
|
||||||
if not os.path.exists(options.config):
|
if not os.path.exists(options.config):
|
||||||
# Try to create the config folder if it doesn't exist
|
# 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())
|
os.makedirs(deluge.common.get_default_config_dir())
|
||||||
|
|
||||||
if options.default_ui:
|
if options.default_ui:
|
||||||
|
import deluge.configmanager
|
||||||
if options.config:
|
if options.config:
|
||||||
deluge.configmanager.set_config_dir(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
|
print "The default UI has been changed to", options.default_ui
|
||||||
sys.exit(0)
|
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()
|
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.info("Deluge ui %s", version)
|
||||||
log.debug("options: %s", options)
|
log.debug("options: %s", options)
|
||||||
log.debug("args: %s", args)
|
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")
|
help="Set the log level: none, info, warning, error, critical, debug", action="store", type="str")
|
||||||
parser.add_option("-q", "--quiet", dest="quiet",
|
parser.add_option("-q", "--quiet", dest="quiet",
|
||||||
help="Sets the log level to 'none', this is the same as `-L none`", action="store_true", default=False)
|
help="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,
|
parser.add_option("--profile", dest="profile", action="store_true", default=False,
|
||||||
help="Profiles the daemon")
|
help="Profiles the daemon")
|
||||||
|
|
||||||
|
@ -161,6 +172,15 @@ this should be an IP address", metavar="IFACE",
|
||||||
if options.quiet:
|
if options.quiet:
|
||||||
options.loglevel = "none"
|
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 options.config:
|
||||||
if not deluge.configmanager.set_config_dir(options.config):
|
if not deluge.configmanager.set_config_dir(options.config):
|
||||||
print("There was an error setting the config dir! Exiting..")
|
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)))
|
os.makedirs(os.path.abspath(os.path.dirname(options.logfile)))
|
||||||
except:
|
except:
|
||||||
pass
|
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:
|
if options.profile:
|
||||||
import hotshot
|
import hotshot
|
||||||
|
|
|
@ -20,10 +20,12 @@ import os
|
||||||
import os.path
|
import os.path
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
|
import logging
|
||||||
from hashlib import sha1 as sha
|
from hashlib import sha1 as sha
|
||||||
|
|
||||||
from deluge.bencode import bencode
|
from deluge.bencode import bencode
|
||||||
from deluge.log import LOG as log
|
|
||||||
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
ignore = ['core', 'CVS', 'Thumbs.db', 'desktop.ini']
|
ignore = ['core', 'CVS', 'Thumbs.db', 'desktop.ini']
|
||||||
|
|
||||||
|
@ -180,7 +182,7 @@ def makeinfo(path, piece_length, progress, name = None,
|
||||||
if done > 0:
|
if done > 0:
|
||||||
pieces.append(sh.digest())
|
pieces.append(sh.digest())
|
||||||
progress(piece_count, num_pieces)
|
progress(piece_count, num_pieces)
|
||||||
|
|
||||||
if name is not None:
|
if name is not None:
|
||||||
assert isinstance(name, unicode)
|
assert isinstance(name, unicode)
|
||||||
name = to_utf8(name)
|
name = to_utf8(name)
|
||||||
|
|
|
@ -37,15 +37,16 @@
|
||||||
"""PluginManagerBase"""
|
"""PluginManagerBase"""
|
||||||
|
|
||||||
import os.path
|
import os.path
|
||||||
|
import logging
|
||||||
import pkg_resources
|
import pkg_resources
|
||||||
|
|
||||||
import deluge.common
|
import deluge.common
|
||||||
import deluge.configmanager
|
import deluge.configmanager
|
||||||
from deluge.log import LOG as log
|
|
||||||
|
|
||||||
import deluge.component as component
|
import deluge.component as component
|
||||||
|
|
||||||
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
METADATA_KEYS = [
|
METADATA_KEYS = [
|
||||||
"Name",
|
"Name",
|
||||||
"License",
|
"License",
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
|
|
||||||
from deluge._libtorrent import lt
|
from deluge._libtorrent import lt
|
||||||
import os
|
import os
|
||||||
from deluge.log import LOG as log
|
from deluge.log import getPluginLogger
|
||||||
from deluge.plugins.pluginbase import CorePluginBase
|
from deluge.plugins.pluginbase import CorePluginBase
|
||||||
import deluge.component as component
|
import deluge.component as component
|
||||||
import deluge.configmanager
|
import deluge.configmanager
|
||||||
|
@ -48,6 +48,8 @@ from twisted.internet.task import LoopingCall, deferLater
|
||||||
from twisted.internet import reactor
|
from twisted.internet import reactor
|
||||||
from deluge.event import DelugeEvent
|
from deluge.event import DelugeEvent
|
||||||
|
|
||||||
|
log = getPluginLogger(__name__)
|
||||||
|
|
||||||
DEFAULT_PREFS = {
|
DEFAULT_PREFS = {
|
||||||
"watchdirs":{},
|
"watchdirs":{},
|
||||||
"next_id":1
|
"next_id":1
|
||||||
|
@ -57,7 +59,7 @@ OPTIONS_AVAILABLE = { #option: builtin
|
||||||
"enabled":False,
|
"enabled":False,
|
||||||
"path":False,
|
"path":False,
|
||||||
"append_extension":False,
|
"append_extension":False,
|
||||||
"abspath":False,
|
"abspath":False,
|
||||||
"download_location":True,
|
"download_location":True,
|
||||||
"max_download_speed":True,
|
"max_download_speed":True,
|
||||||
"max_upload_speed":True,
|
"max_upload_speed":True,
|
||||||
|
@ -88,7 +90,7 @@ def CheckInput(cond, message):
|
||||||
|
|
||||||
class Core(CorePluginBase):
|
class Core(CorePluginBase):
|
||||||
def enable(self):
|
def enable(self):
|
||||||
|
|
||||||
#reduce typing, assigning some values to self...
|
#reduce typing, assigning some values to self...
|
||||||
self.config = deluge.configmanager.ConfigManager("autoadd.conf", DEFAULT_PREFS)
|
self.config = deluge.configmanager.ConfigManager("autoadd.conf", DEFAULT_PREFS)
|
||||||
self.watchdirs = self.config["watchdirs"]
|
self.watchdirs = self.config["watchdirs"]
|
||||||
|
@ -127,7 +129,7 @@ class Core(CorePluginBase):
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@export()
|
@export()
|
||||||
def set_options(self, watchdir_id, options):
|
def set_options(self, watchdir_id, options):
|
||||||
"""Update the options for a watch folder."""
|
"""Update the options for a watch folder."""
|
||||||
|
@ -147,14 +149,14 @@ class Core(CorePluginBase):
|
||||||
#disable the watch loop if it was active
|
#disable the watch loop if it was active
|
||||||
if watchdir_id in self.update_timers:
|
if watchdir_id in self.update_timers:
|
||||||
self.disable_watchdir(watchdir_id)
|
self.disable_watchdir(watchdir_id)
|
||||||
|
|
||||||
self.watchdirs[watchdir_id].update(options)
|
self.watchdirs[watchdir_id].update(options)
|
||||||
#re-enable watch loop if appropriate
|
#re-enable watch loop if appropriate
|
||||||
if self.watchdirs[watchdir_id]['enabled']:
|
if self.watchdirs[watchdir_id]['enabled']:
|
||||||
self.enable_watchdir(watchdir_id)
|
self.enable_watchdir(watchdir_id)
|
||||||
self.config.save()
|
self.config.save()
|
||||||
component.get("EventManager").emit(AutoaddOptionsChangedEvent())
|
component.get("EventManager").emit(AutoaddOptionsChangedEvent())
|
||||||
|
|
||||||
def load_torrent(self, filename):
|
def load_torrent(self, filename):
|
||||||
try:
|
try:
|
||||||
log.debug("Attempting to open %s for add.", filename)
|
log.debug("Attempting to open %s for add.", filename)
|
||||||
|
@ -171,7 +173,7 @@ class Core(CorePluginBase):
|
||||||
info = lt.torrent_info(lt.bdecode(filedump))
|
info = lt.torrent_info(lt.bdecode(filedump))
|
||||||
|
|
||||||
return filedump
|
return filedump
|
||||||
|
|
||||||
def update_watchdir(self, watchdir_id):
|
def update_watchdir(self, watchdir_id):
|
||||||
"""Check the watch folder for new torrents to add."""
|
"""Check the watch folder for new torrents to add."""
|
||||||
watchdir_id = str(watchdir_id)
|
watchdir_id = str(watchdir_id)
|
||||||
|
@ -185,7 +187,7 @@ class Core(CorePluginBase):
|
||||||
log.warning("Invalid AutoAdd folder: %s", watchdir["abspath"])
|
log.warning("Invalid AutoAdd folder: %s", watchdir["abspath"])
|
||||||
self.disable_watchdir(watchdir_id)
|
self.disable_watchdir(watchdir_id)
|
||||||
return
|
return
|
||||||
|
|
||||||
# Generate options dict for watchdir
|
# Generate options dict for watchdir
|
||||||
opts = {}
|
opts = {}
|
||||||
if 'stop_at_ratio_toggle' in watchdir:
|
if 'stop_at_ratio_toggle' in watchdir:
|
||||||
|
@ -246,7 +248,7 @@ class Core(CorePluginBase):
|
||||||
"""Disables any watch folders with unhandled exceptions."""
|
"""Disables any watch folders with unhandled exceptions."""
|
||||||
self.disable_watchdir(watchdir_id)
|
self.disable_watchdir(watchdir_id)
|
||||||
log.error("Disabling '%s', error during update: %s" % (self.watchdirs[watchdir_id]["path"], failure))
|
log.error("Disabling '%s', error during update: %s" % (self.watchdirs[watchdir_id]["path"], failure))
|
||||||
|
|
||||||
@export
|
@export
|
||||||
def enable_watchdir(self, watchdir_id):
|
def enable_watchdir(self, watchdir_id):
|
||||||
watchdir_id = str(watchdir_id)
|
watchdir_id = str(watchdir_id)
|
||||||
|
@ -259,7 +261,7 @@ class Core(CorePluginBase):
|
||||||
self.watchdirs[watchdir_id]['enabled'] = True
|
self.watchdirs[watchdir_id]['enabled'] = True
|
||||||
self.config.save()
|
self.config.save()
|
||||||
component.get("EventManager").emit(AutoaddOptionsChangedEvent())
|
component.get("EventManager").emit(AutoaddOptionsChangedEvent())
|
||||||
|
|
||||||
@export
|
@export
|
||||||
def disable_watchdir(self, watchdir_id):
|
def disable_watchdir(self, watchdir_id):
|
||||||
watchdir_id = str(watchdir_id)
|
watchdir_id = str(watchdir_id)
|
||||||
|
@ -287,7 +289,7 @@ class Core(CorePluginBase):
|
||||||
def get_config(self):
|
def get_config(self):
|
||||||
"""Returns the config dictionary."""
|
"""Returns the config dictionary."""
|
||||||
return self.config.config
|
return self.config.config
|
||||||
|
|
||||||
@export()
|
@export()
|
||||||
def get_watchdirs(self):
|
def get_watchdirs(self):
|
||||||
return self.watchdirs.keys()
|
return self.watchdirs.keys()
|
||||||
|
@ -319,7 +321,7 @@ class Core(CorePluginBase):
|
||||||
self.config.save()
|
self.config.save()
|
||||||
component.get("EventManager").emit(AutoaddOptionsChangedEvent())
|
component.get("EventManager").emit(AutoaddOptionsChangedEvent())
|
||||||
return watchdir_id
|
return watchdir_id
|
||||||
|
|
||||||
@export
|
@export
|
||||||
def remove(self, watchdir_id):
|
def remove(self, watchdir_id):
|
||||||
"""Remove a watch folder."""
|
"""Remove a watch folder."""
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
|
|
||||||
import gtk
|
import gtk
|
||||||
|
|
||||||
from deluge.log import LOG as log
|
from deluge.log import getPluginLogger
|
||||||
from deluge.ui.client import client
|
from deluge.ui.client import client
|
||||||
from deluge.plugins.pluginbase import GtkPluginBase
|
from deluge.plugins.pluginbase import GtkPluginBase
|
||||||
import deluge.component as component
|
import deluge.component as component
|
||||||
|
@ -48,6 +48,8 @@ import os
|
||||||
|
|
||||||
from common import get_resource
|
from common import get_resource
|
||||||
|
|
||||||
|
log = getPluginLogger(__name__)
|
||||||
|
|
||||||
class OptionsDialog():
|
class OptionsDialog():
|
||||||
spin_ids = ["max_download_speed", "max_upload_speed", "stop_ratio"]
|
spin_ids = ["max_download_speed", "max_upload_speed", "stop_ratio"]
|
||||||
spin_int_ids = ["max_upload_slots", "max_connections"]
|
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+"_entry").show()
|
||||||
self.glade.get_widget(field+"_chooser").hide()
|
self.glade.get_widget(field+"_chooser").hide()
|
||||||
self.set_sensitive()
|
self.set_sensitive()
|
||||||
|
|
||||||
def on_get_enabled_plugins(result):
|
def on_get_enabled_plugins(result):
|
||||||
if 'Label' in result:
|
if 'Label' in result:
|
||||||
self.glade.get_widget('label_frame').show()
|
self.glade.get_widget('label_frame').show()
|
||||||
else:
|
else:
|
||||||
self.glade.get_widget('label_frame').hide()
|
self.glade.get_widget('label_frame').hide()
|
||||||
self.glade.get_widget('label_toggle').set_active(False)
|
self.glade.get_widget('label_toggle').set_active(False)
|
||||||
|
|
||||||
client.core.get_enabled_plugins().addCallback(on_get_enabled_plugins)
|
client.core.get_enabled_plugins().addCallback(on_get_enabled_plugins)
|
||||||
|
|
||||||
def set_sensitive(self):
|
def set_sensitive(self):
|
||||||
maintoggles = ['download_location', 'append_extension', 'move_completed', 'label', \
|
maintoggles = ['download_location', 'append_extension', 'move_completed', 'label', \
|
||||||
'max_download_speed', 'max_upload_speed', 'max_connections', \
|
'max_download_speed', 'max_upload_speed', 'max_connections', \
|
||||||
'max_upload_slots', 'add_paused', 'auto_managed', 'stop_at_ratio', 'queue_to_top']
|
'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]
|
[self.on_toggle_toggled(self.glade.get_widget(x+'_toggle')) for x in maintoggles]
|
||||||
|
|
||||||
def on_toggle_toggled(self, tb):
|
def on_toggle_toggled(self, tb):
|
||||||
toggle = str(tb.name).replace("_toggle", "")
|
toggle = str(tb.name).replace("_toggle", "")
|
||||||
isactive = tb.get_active()
|
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_at_ratio').set_active(isactive)
|
||||||
self.glade.get_widget('stop_ratio').set_sensitive(isactive)
|
self.glade.get_widget('stop_ratio').set_sensitive(isactive)
|
||||||
self.glade.get_widget('remove_at_ratio').set_sensitive(isactive)
|
self.glade.get_widget('remove_at_ratio').set_sensitive(isactive)
|
||||||
|
|
||||||
def on_apply(self, Event=None):
|
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)
|
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):
|
def on_error_show(self, result):
|
||||||
self.glade.get_widget('error_label').set_text(result.value.exception_msg)
|
self.glade.get_widget('error_label').set_text(result.value.exception_msg)
|
||||||
self.err_dialog = self.glade.get_widget('error_dialog')
|
self.err_dialog = self.glade.get_widget('error_dialog')
|
||||||
self.err_dialog.set_transient_for(self.dialog)
|
self.err_dialog.set_transient_for(self.dialog)
|
||||||
result.cleanFailure()
|
result.cleanFailure()
|
||||||
self.err_dialog.show()
|
self.err_dialog.show()
|
||||||
|
|
||||||
def on_added(self, result):
|
def on_added(self, result):
|
||||||
self.dialog.destroy()
|
self.dialog.destroy()
|
||||||
|
|
||||||
def on_error_ok(self, Event=None):
|
def on_error_ok(self, Event=None):
|
||||||
self.err_dialog.hide()
|
self.err_dialog.hide()
|
||||||
|
|
||||||
def on_add(self, Event=None):
|
def on_add(self, Event=None):
|
||||||
client.autoadd.add(self.generate_opts()).addCallbacks(self.on_added, self.on_error_show)
|
client.autoadd.add(self.generate_opts()).addCallbacks(self.on_added, self.on_error_show)
|
||||||
|
|
||||||
def on_cancel(self, Event=None):
|
def on_cancel(self, Event=None):
|
||||||
self.dialog.destroy()
|
self.dialog.destroy()
|
||||||
|
|
||||||
def generate_opts(self):
|
def generate_opts(self):
|
||||||
# generate options dict based on gtk objects
|
# generate options dict based on gtk objects
|
||||||
options = {}
|
options = {}
|
||||||
|
@ -217,11 +219,11 @@ class OptionsDialog():
|
||||||
options[id] = self.glade.get_widget(id).get_active()
|
options[id] = self.glade.get_widget(id).get_active()
|
||||||
options[id+'_toggle'] = self.glade.get_widget(id+'_toggle').get_active()
|
options[id+'_toggle'] = self.glade.get_widget(id+'_toggle').get_active()
|
||||||
return options
|
return options
|
||||||
|
|
||||||
|
|
||||||
class GtkUI(GtkPluginBase):
|
class GtkUI(GtkPluginBase):
|
||||||
def enable(self):
|
def enable(self):
|
||||||
|
|
||||||
self.glade = gtk.glade.XML(get_resource("config.glade"))
|
self.glade = gtk.glade.XML(get_resource("config.glade"))
|
||||||
self.glade.signal_autoconnect({
|
self.glade.signal_autoconnect({
|
||||||
"on_add_button_clicked": self.on_add_button_clicked,
|
"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
|
"on_remove_button_clicked": self.on_remove_button_clicked
|
||||||
})
|
})
|
||||||
self.opts_dialog = OptionsDialog()
|
self.opts_dialog = OptionsDialog()
|
||||||
|
|
||||||
component.get("PluginManager").register_hook("on_apply_prefs", self.on_apply_prefs)
|
component.get("PluginManager").register_hook("on_apply_prefs", self.on_apply_prefs)
|
||||||
component.get("PluginManager").register_hook("on_show_prefs", self.on_show_prefs)
|
component.get("PluginManager").register_hook("on_show_prefs", self.on_show_prefs)
|
||||||
client.register_event_handler("AutoaddOptionsChangedEvent", self.on_options_changed_event)
|
client.register_event_handler("AutoaddOptionsChangedEvent", self.on_options_changed_event)
|
||||||
|
|
||||||
self.watchdirs = {}
|
self.watchdirs = {}
|
||||||
|
|
||||||
vbox = self.glade.get_widget("watchdirs_vbox")
|
vbox = self.glade.get_widget("watchdirs_vbox")
|
||||||
sw = gtk.ScrolledWindow()
|
sw = gtk.ScrolledWindow()
|
||||||
sw.set_shadow_type(gtk.SHADOW_ETCHED_IN)
|
sw.set_shadow_type(gtk.SHADOW_ETCHED_IN)
|
||||||
sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
|
sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
|
||||||
|
|
||||||
vbox.pack_start(sw, True, True, 0)
|
vbox.pack_start(sw, True, True, 0)
|
||||||
|
|
||||||
self.store = self.create_model()
|
self.store = self.create_model()
|
||||||
|
@ -256,28 +258,28 @@ class GtkUI(GtkPluginBase):
|
||||||
component.get("Preferences").add_page("AutoAdd", self.glade.get_widget("prefs_box"))
|
component.get("Preferences").add_page("AutoAdd", self.glade.get_widget("prefs_box"))
|
||||||
self.on_show_prefs()
|
self.on_show_prefs()
|
||||||
|
|
||||||
|
|
||||||
def disable(self):
|
def disable(self):
|
||||||
component.get("Preferences").remove_page("AutoAdd")
|
component.get("Preferences").remove_page("AutoAdd")
|
||||||
component.get("PluginManager").deregister_hook("on_apply_prefs", self.on_apply_prefs)
|
component.get("PluginManager").deregister_hook("on_apply_prefs", self.on_apply_prefs)
|
||||||
component.get("PluginManager").deregister_hook("on_show_prefs", self.on_show_prefs)
|
component.get("PluginManager").deregister_hook("on_show_prefs", self.on_show_prefs)
|
||||||
|
|
||||||
def create_model(self):
|
def create_model(self):
|
||||||
|
|
||||||
store = gtk.ListStore(str, bool, str)
|
store = gtk.ListStore(str, bool, str)
|
||||||
for watchdir_id, watchdir in self.watchdirs.iteritems():
|
for watchdir_id, watchdir in self.watchdirs.iteritems():
|
||||||
store.append([watchdir_id, watchdir['enabled'], watchdir['path']])
|
store.append([watchdir_id, watchdir['enabled'], watchdir['path']])
|
||||||
return store
|
return store
|
||||||
|
|
||||||
def create_columns(self, treeView):
|
def create_columns(self, treeView):
|
||||||
rendererToggle = gtk.CellRendererToggle()
|
rendererToggle = gtk.CellRendererToggle()
|
||||||
column = gtk.TreeViewColumn("On", rendererToggle, activatable=True, active=1)
|
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)
|
treeView.append_column(column)
|
||||||
tt = gtk.Tooltip()
|
tt = gtk.Tooltip()
|
||||||
tt.set_text('Double-click to toggle')
|
tt.set_text('Double-click to toggle')
|
||||||
treeView.set_tooltip_cell(tt, None, None, rendererToggle)
|
treeView.set_tooltip_cell(tt, None, None, rendererToggle)
|
||||||
|
|
||||||
rendererText = gtk.CellRendererText()
|
rendererText = gtk.CellRendererText()
|
||||||
column = gtk.TreeViewColumn("Path", rendererText, text=2)
|
column = gtk.TreeViewColumn("Path", rendererText, text=2)
|
||||||
column.set_sort_column_id(2)
|
column.set_sort_column_id(2)
|
||||||
|
@ -289,20 +291,20 @@ class GtkUI(GtkPluginBase):
|
||||||
|
|
||||||
def load_watchdir_list(self):
|
def load_watchdir_list(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def add_watchdir_entry(self):
|
def add_watchdir_entry(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def on_add_button_clicked(self, Event=None):
|
def on_add_button_clicked(self, Event=None):
|
||||||
#display options_window
|
#display options_window
|
||||||
self.opts_dialog.show()
|
self.opts_dialog.show()
|
||||||
|
|
||||||
def on_remove_button_clicked(self, Event=None):
|
def on_remove_button_clicked(self, Event=None):
|
||||||
tree, tree_id = self.treeView.get_selection().get_selected()
|
tree, tree_id = self.treeView.get_selection().get_selected()
|
||||||
watchdir_id = str(self.store.get_value(tree_id, 0))
|
watchdir_id = str(self.store.get_value(tree_id, 0))
|
||||||
if watchdir_id:
|
if watchdir_id:
|
||||||
client.autoadd.remove(watchdir_id)
|
client.autoadd.remove(watchdir_id)
|
||||||
|
|
||||||
def on_edit_button_clicked(self, Event=None, a=None, col=None):
|
def on_edit_button_clicked(self, Event=None, a=None, col=None):
|
||||||
tree, tree_id = self.treeView.get_selection().get_selected()
|
tree, tree_id = self.treeView.get_selection().get_selected()
|
||||||
watchdir_id = str(self.store.get_value(tree_id, 0))
|
watchdir_id = str(self.store.get_value(tree_id, 0))
|
||||||
|
@ -314,7 +316,7 @@ class GtkUI(GtkPluginBase):
|
||||||
client.autoadd.enable_watchdir(watchdir_id)
|
client.autoadd.enable_watchdir(watchdir_id)
|
||||||
else:
|
else:
|
||||||
self.opts_dialog.show(self.watchdirs[watchdir_id], watchdir_id)
|
self.opts_dialog.show(self.watchdirs[watchdir_id], watchdir_id)
|
||||||
|
|
||||||
def on_listitem_activated(self, treeview):
|
def on_listitem_activated(self, treeview):
|
||||||
tree, tree_id = self.treeView.get_selection().get_selected()
|
tree, tree_id = self.treeView.get_selection().get_selected()
|
||||||
if tree_id:
|
if tree_id:
|
||||||
|
@ -323,7 +325,7 @@ class GtkUI(GtkPluginBase):
|
||||||
else:
|
else:
|
||||||
self.glade.get_widget('edit_button').set_sensitive(False)
|
self.glade.get_widget('edit_button').set_sensitive(False)
|
||||||
self.glade.get_widget('remove_button').set_sensitive(False)
|
self.glade.get_widget('remove_button').set_sensitive(False)
|
||||||
|
|
||||||
def on_apply_prefs(self):
|
def on_apply_prefs(self):
|
||||||
log.debug("applying prefs for AutoAdd")
|
log.debug("applying prefs for AutoAdd")
|
||||||
for watchdir_id, watchdir in self.watchdirs.iteritems():
|
for watchdir_id, watchdir in self.watchdirs.iteritems():
|
||||||
|
@ -331,7 +333,7 @@ class GtkUI(GtkPluginBase):
|
||||||
|
|
||||||
def on_show_prefs(self):
|
def on_show_prefs(self):
|
||||||
client.autoadd.get_config().addCallback(self.cb_get_config)
|
client.autoadd.get_config().addCallback(self.cb_get_config)
|
||||||
|
|
||||||
def on_options_changed_event(self):
|
def on_options_changed_event(self):
|
||||||
client.autoadd.get_config().addCallback(self.cb_get_config)
|
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
|
# 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('remove_button').set_sensitive(False)
|
||||||
self.glade.get_widget('edit_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.
|
# 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.ui.client import client
|
||||||
from deluge import component
|
from deluge import component
|
||||||
from deluge.plugins.pluginbase import WebPluginBase
|
from deluge.plugins.pluginbase import WebPluginBase
|
||||||
|
|
||||||
from common import get_resource
|
from common import get_resource
|
||||||
|
|
||||||
|
log = getPluginLogger(__name__)
|
||||||
|
|
||||||
class WebUI(WebPluginBase):
|
class WebUI(WebPluginBase):
|
||||||
|
|
||||||
scripts = [get_resource("autoadd.js")]
|
scripts = [get_resource("autoadd.js")]
|
||||||
|
|
|
@ -45,7 +45,7 @@ from twisted.internet.task import LoopingCall
|
||||||
from twisted.internet import threads, defer
|
from twisted.internet import threads, defer
|
||||||
from twisted.web import error
|
from twisted.web import error
|
||||||
|
|
||||||
from deluge.log import LOG as log
|
from deluge.log import getPluginLogger
|
||||||
from deluge.plugins.pluginbase import CorePluginBase
|
from deluge.plugins.pluginbase import CorePluginBase
|
||||||
import deluge.component as component
|
import deluge.component as component
|
||||||
import deluge.configmanager
|
import deluge.configmanager
|
||||||
|
@ -58,6 +58,8 @@ from readers import ReaderParseError
|
||||||
# TODO: check return values for deferred callbacks
|
# TODO: check return values for deferred callbacks
|
||||||
# TODO: review class attributes for redundancy
|
# TODO: review class attributes for redundancy
|
||||||
|
|
||||||
|
log = getPluginLogger(__name__)
|
||||||
|
|
||||||
DEFAULT_PREFS = {
|
DEFAULT_PREFS = {
|
||||||
"url": "http://deluge-torrent.org/blocklist/nipfilter.dat.gz",
|
"url": "http://deluge-torrent.org/blocklist/nipfilter.dat.gz",
|
||||||
"load_on_start": False,
|
"load_on_start": False,
|
||||||
|
@ -161,7 +163,7 @@ class Core(CorePluginBase):
|
||||||
def get_config(self):
|
def get_config(self):
|
||||||
"""
|
"""
|
||||||
Returns the config dictionary
|
Returns the config dictionary
|
||||||
|
|
||||||
:returns: the config dictionary
|
:returns: the config dictionary
|
||||||
:rtype: dict
|
:rtype: dict
|
||||||
"""
|
"""
|
||||||
|
@ -182,7 +184,7 @@ class Core(CorePluginBase):
|
||||||
def get_status(self):
|
def get_status(self):
|
||||||
"""
|
"""
|
||||||
Returns the status of the plugin
|
Returns the status of the plugin
|
||||||
|
|
||||||
:returns: the status dict of the plugin
|
:returns: the status dict of the plugin
|
||||||
:rtype: dict
|
:rtype: dict
|
||||||
"""
|
"""
|
||||||
|
@ -260,7 +262,7 @@ class Core(CorePluginBase):
|
||||||
def on_download_complete(self, blocklist):
|
def on_download_complete(self, blocklist):
|
||||||
"""
|
"""
|
||||||
Runs any download clean up functions
|
Runs any download clean up functions
|
||||||
|
|
||||||
:param blocklist: path of blocklist
|
:param blocklist: path of blocklist
|
||||||
:type blocklist: string
|
:type blocklist: string
|
||||||
:returns: a Deferred which fires when clean up is done
|
:returns: a Deferred which fires when clean up is done
|
||||||
|
@ -273,7 +275,7 @@ class Core(CorePluginBase):
|
||||||
def on_download_error(self, f):
|
def on_download_error(self, f):
|
||||||
"""
|
"""
|
||||||
Recovers from download error
|
Recovers from download error
|
||||||
|
|
||||||
:param f: failure that occured
|
:param f: failure that occured
|
||||||
:type f: Failure
|
:type f: Failure
|
||||||
:returns: a Deferred if recovery was possible
|
:returns: a Deferred if recovery was possible
|
||||||
|
@ -309,7 +311,7 @@ class Core(CorePluginBase):
|
||||||
def import_list(self, blocklist):
|
def import_list(self, blocklist):
|
||||||
"""
|
"""
|
||||||
Imports the downloaded blocklist into the session
|
Imports the downloaded blocklist into the session
|
||||||
|
|
||||||
:param blocklist: path of blocklist
|
:param blocklist: path of blocklist
|
||||||
:type blocklist: string
|
:type blocklist: string
|
||||||
:returns: a Deferred that fires when the blocklist has been imported
|
:returns: a Deferred that fires when the blocklist has been imported
|
||||||
|
@ -333,7 +335,7 @@ class Core(CorePluginBase):
|
||||||
self.is_importing = True
|
self.is_importing = True
|
||||||
self.num_blocked = 0
|
self.num_blocked = 0
|
||||||
self.blocklist = self.core.session.get_ip_filter()
|
self.blocklist = self.core.session.get_ip_filter()
|
||||||
|
|
||||||
if not blocklist:
|
if not blocklist:
|
||||||
blocklist = self.filename
|
blocklist = self.filename
|
||||||
|
|
||||||
|
@ -351,7 +353,7 @@ class Core(CorePluginBase):
|
||||||
def on_import_complete(self, blocklist):
|
def on_import_complete(self, blocklist):
|
||||||
"""
|
"""
|
||||||
Runs any import clean up functions
|
Runs any import clean up functions
|
||||||
|
|
||||||
:param blocklist: path of blocklist
|
:param blocklist: path of blocklist
|
||||||
:type blocklist: string
|
:type blocklist: string
|
||||||
:returns: a Deferred that fires when clean up is done
|
:returns: a Deferred that fires when clean up is done
|
||||||
|
@ -374,7 +376,7 @@ class Core(CorePluginBase):
|
||||||
def on_import_error(self, f):
|
def on_import_error(self, f):
|
||||||
"""
|
"""
|
||||||
Recovers from import error
|
Recovers from import error
|
||||||
|
|
||||||
:param f: failure that occured
|
:param f: failure that occured
|
||||||
:type f: Failure
|
:type f: Failure
|
||||||
:returns: a Deferred if recovery was possible
|
:returns: a Deferred if recovery was possible
|
||||||
|
|
|
@ -36,13 +36,15 @@
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import gtk
|
import gtk
|
||||||
|
|
||||||
from deluge.log import LOG as log
|
from deluge.log import getPluginLogger
|
||||||
from deluge.ui.client import client
|
from deluge.ui.client import client
|
||||||
import deluge.component as component
|
import deluge.component as component
|
||||||
import deluge.common
|
import deluge.common
|
||||||
from deluge.plugins.pluginbase import GtkPluginBase
|
from deluge.plugins.pluginbase import GtkPluginBase
|
||||||
import common
|
import common
|
||||||
|
|
||||||
|
log = getPluginLogger(__name__)
|
||||||
|
|
||||||
class GtkUI(GtkPluginBase):
|
class GtkUI(GtkPluginBase):
|
||||||
def enable(self):
|
def enable(self):
|
||||||
log.debug("Blocklist GtkUI enable..")
|
log.debug("Blocklist GtkUI enable..")
|
||||||
|
|
|
@ -7,7 +7,9 @@ from exceptions import Exception
|
||||||
from struct import unpack
|
from struct import unpack
|
||||||
import gzip, socket
|
import gzip, socket
|
||||||
|
|
||||||
from deluge.log import LOG as log
|
from deluge.log import getPluginLogger
|
||||||
|
|
||||||
|
log = getPluginLogger(__name__)
|
||||||
|
|
||||||
class PGException(Exception):
|
class PGException(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -36,11 +36,13 @@
|
||||||
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
from deluge.log import LOG as log
|
from deluge.log import getPluginLogger
|
||||||
from deluge.ui.client import client
|
from deluge.ui.client import client
|
||||||
from deluge import component
|
from deluge import component
|
||||||
from deluge.plugins.pluginbase import WebPluginBase
|
from deluge.plugins.pluginbase import WebPluginBase
|
||||||
|
|
||||||
|
log = getPluginLogger(__name__)
|
||||||
|
|
||||||
#import deluge.ui.webui.lib.newforms_plus as forms
|
#import deluge.ui.webui.lib.newforms_plus as forms
|
||||||
|
|
||||||
#config_page_manager = component.get("ConfigPageManager")
|
#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
|
from deluge.plugins.pluginbase import CorePluginBase
|
||||||
import deluge.component as component
|
import deluge.component as component
|
||||||
import deluge.configmanager
|
import deluge.configmanager
|
||||||
from deluge.core.rpcserver import export
|
from deluge.core.rpcserver import export
|
||||||
|
|
||||||
|
log = getPluginLogger(__name__)
|
||||||
|
|
||||||
class Core(CorePluginBase):
|
class Core(CorePluginBase):
|
||||||
def enable(self):
|
def enable(self):
|
||||||
log.debug("Example core plugin enabled!")
|
log.debug("Example core plugin enabled!")
|
||||||
|
|
|
@ -35,12 +35,14 @@
|
||||||
|
|
||||||
import gtk
|
import gtk
|
||||||
|
|
||||||
from deluge.log import LOG as log
|
from deluge.log import getPluginLogger
|
||||||
from deluge.ui.client import client
|
from deluge.ui.client import client
|
||||||
from deluge.plugins.pluginbase import GtkPluginBase
|
from deluge.plugins.pluginbase import GtkPluginBase
|
||||||
import deluge.component as component
|
import deluge.component as component
|
||||||
import deluge.common
|
import deluge.common
|
||||||
|
|
||||||
|
log = getPluginLogger(__name__)
|
||||||
|
|
||||||
class GtkUI(GtkPluginBase):
|
class GtkUI(GtkPluginBase):
|
||||||
def enable(self):
|
def enable(self):
|
||||||
pass
|
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.ui.client import client
|
||||||
from deluge import component
|
from deluge import component
|
||||||
from deluge.plugins.pluginbase import WebPluginBase
|
from deluge.plugins.pluginbase import WebPluginBase
|
||||||
|
|
||||||
from common import get_resource
|
from common import get_resource
|
||||||
|
|
||||||
|
log = getPluginLogger(__name__)
|
||||||
|
|
||||||
class WebUI(WebPluginBase):
|
class WebUI(WebPluginBase):
|
||||||
|
|
||||||
scripts = [get_resource("example.js")]
|
scripts = [get_resource("example.js")]
|
||||||
|
|
||||||
# The enable and disable methods are not scrictly required on the WebUI
|
# The enable and disable methods are not scrictly required on the WebUI
|
||||||
# plugins. They are only here if you need to register images/stylesheets
|
# plugins. They are only here if you need to register images/stylesheets
|
||||||
# with the webserver.
|
# with the webserver.
|
||||||
|
|
|
@ -38,13 +38,15 @@ import time
|
||||||
import hashlib
|
import hashlib
|
||||||
from subprocess import Popen, PIPE
|
from subprocess import Popen, PIPE
|
||||||
|
|
||||||
from deluge.log import LOG as log
|
from deluge.log import getPluginLogger
|
||||||
from deluge.plugins.pluginbase import CorePluginBase
|
from deluge.plugins.pluginbase import CorePluginBase
|
||||||
import deluge.component as component
|
import deluge.component as component
|
||||||
from deluge.configmanager import ConfigManager
|
from deluge.configmanager import ConfigManager
|
||||||
from deluge.core.rpcserver import export
|
from deluge.core.rpcserver import export
|
||||||
from deluge.event import DelugeEvent
|
from deluge.event import DelugeEvent
|
||||||
|
|
||||||
|
log = getPluginLogger(__name__)
|
||||||
|
|
||||||
DEFAULT_CONFIG = {
|
DEFAULT_CONFIG = {
|
||||||
"commands": []
|
"commands": []
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,12 +37,14 @@ import os
|
||||||
import gtk
|
import gtk
|
||||||
import pkg_resources
|
import pkg_resources
|
||||||
|
|
||||||
from deluge.log import LOG as log
|
from deluge.log import getPluginLogger
|
||||||
from deluge.ui.client import client
|
from deluge.ui.client import client
|
||||||
from deluge.plugins.pluginbase import GtkPluginBase
|
from deluge.plugins.pluginbase import GtkPluginBase
|
||||||
import deluge.component as component
|
import deluge.component as component
|
||||||
import deluge.common
|
import deluge.common
|
||||||
|
|
||||||
|
log = getPluginLogger(__name__)
|
||||||
|
|
||||||
EXECUTE_ID = 0
|
EXECUTE_ID = 0
|
||||||
EXECUTE_EVENT = 1
|
EXECUTE_EVENT = 1
|
||||||
EXECUTE_COMMAND = 2
|
EXECUTE_COMMAND = 2
|
||||||
|
|
|
@ -35,14 +35,16 @@
|
||||||
|
|
||||||
import pkg_resources
|
import pkg_resources
|
||||||
|
|
||||||
from deluge.log import LOG as log
|
from deluge.log import getPluginLogger
|
||||||
from deluge.ui.client import client
|
from deluge.ui.client import client
|
||||||
from deluge import component
|
from deluge import component
|
||||||
from deluge.plugins.pluginbase import WebPluginBase
|
from deluge.plugins.pluginbase import WebPluginBase
|
||||||
|
|
||||||
from common import get_resource
|
from common import get_resource
|
||||||
|
|
||||||
|
log = getPluginLogger(__name__)
|
||||||
|
|
||||||
class WebUI(WebPluginBase):
|
class WebUI(WebPluginBase):
|
||||||
|
|
||||||
scripts = [get_resource("execute.js")]
|
scripts = [get_resource("execute.js")]
|
||||||
debug_scripts = scripts
|
debug_scripts = scripts
|
||||||
|
|
|
@ -41,12 +41,14 @@ import os
|
||||||
|
|
||||||
from twisted.internet.utils import getProcessValue
|
from twisted.internet.utils import getProcessValue
|
||||||
|
|
||||||
from deluge.log import LOG as log
|
from deluge.log import getPluginLogger
|
||||||
from deluge.plugins.pluginbase import CorePluginBase
|
from deluge.plugins.pluginbase import CorePluginBase
|
||||||
import deluge.component as component
|
import deluge.component as component
|
||||||
import deluge.configmanager
|
import deluge.configmanager
|
||||||
from deluge.core.rpcserver import export
|
from deluge.core.rpcserver import export
|
||||||
|
|
||||||
|
log = getPluginLogger(__name__)
|
||||||
|
|
||||||
DEFAULT_PREFS = {
|
DEFAULT_PREFS = {
|
||||||
"extract_path": "",
|
"extract_path": "",
|
||||||
"use_name_folder": True
|
"use_name_folder": True
|
||||||
|
@ -98,22 +100,22 @@ class Core(CorePluginBase):
|
||||||
|
|
||||||
# Now that we have the cmd, lets run it to extract the files
|
# Now that we have the cmd, lets run it to extract the files
|
||||||
fp = os.path.join(save_path, f["path"])
|
fp = os.path.join(save_path, f["path"])
|
||||||
|
|
||||||
# Get the destination path
|
# Get the destination path
|
||||||
dest = self.config["extract_path"]
|
dest = self.config["extract_path"]
|
||||||
if self.config["use_name_folder"]:
|
if self.config["use_name_folder"]:
|
||||||
name = component.get("TorrentManager")[torrent_id].get_status(["name"])["name"]
|
name = component.get("TorrentManager")[torrent_id].get_status(["name"])["name"]
|
||||||
dest = os.path.join(dest, 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):
|
if not os.path.exists(dest):
|
||||||
try:
|
try:
|
||||||
os.makedirs(dest)
|
os.makedirs(dest)
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
log.error("Error creating destination folder: %s", e)
|
log.error("Error creating destination folder: %s", e)
|
||||||
return
|
return
|
||||||
|
|
||||||
log.debug("Extracting to %s", dest)
|
log.debug("Extracting to %s", dest)
|
||||||
def on_extract_success(result, torrent_id):
|
def on_extract_success(result, torrent_id):
|
||||||
# XXX: Emit an event
|
# XXX: Emit an event
|
||||||
log.debug("Extract was successful for %s", torrent_id)
|
log.debug("Extract was successful for %s", torrent_id)
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
|
|
||||||
import gtk
|
import gtk
|
||||||
|
|
||||||
from deluge.log import LOG as log
|
from deluge.log import getPluginLogger
|
||||||
from deluge.ui.client import client
|
from deluge.ui.client import client
|
||||||
from deluge.plugins.pluginbase import GtkPluginBase
|
from deluge.plugins.pluginbase import GtkPluginBase
|
||||||
import deluge.component as component
|
import deluge.component as component
|
||||||
|
@ -47,6 +47,8 @@ import deluge.common
|
||||||
|
|
||||||
from common import get_resource
|
from common import get_resource
|
||||||
|
|
||||||
|
log = getPluginLogger(__name__)
|
||||||
|
|
||||||
class GtkUI(GtkPluginBase):
|
class GtkUI(GtkPluginBase):
|
||||||
def enable(self):
|
def enable(self):
|
||||||
self.glade = gtk.glade.XML(get_resource("extractor_prefs.glade"))
|
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"])
|
self.glade.get_widget("folderchooser_path").set_current_folder(config["extract_path"])
|
||||||
else:
|
else:
|
||||||
self.glade.get_widget("entry_path").set_text(config["extract_path"])
|
self.glade.get_widget("entry_path").set_text(config["extract_path"])
|
||||||
|
|
||||||
self.glade.get_widget("chk_use_name").set_active(config["use_name_folder"])
|
self.glade.get_widget("chk_use_name").set_active(config["use_name_folder"])
|
||||||
|
|
||||||
client.extractor.get_config().addCallback(on_get_config)
|
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.ui.client import client
|
||||||
from deluge import component
|
from deluge import component
|
||||||
from deluge.plugins.pluginbase import WebPluginBase
|
from deluge.plugins.pluginbase import WebPluginBase
|
||||||
|
|
||||||
|
log = getPluginLogger(__name__)
|
||||||
|
|
||||||
class WebUI(WebPluginBase):
|
class WebUI(WebPluginBase):
|
||||||
def enable(self):
|
def enable(self):
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -42,12 +42,14 @@ import threading # for threaded updates
|
||||||
import re # for regular expressions
|
import re # for regular expressions
|
||||||
from twisted.internet.task import LoopingCall
|
from twisted.internet.task import LoopingCall
|
||||||
|
|
||||||
from deluge.log import LOG as log
|
from deluge.log import getPluginLogger
|
||||||
from deluge.plugins.pluginbase import CorePluginBase
|
from deluge.plugins.pluginbase import CorePluginBase
|
||||||
import deluge.component as component
|
import deluge.component as component
|
||||||
import deluge.configmanager
|
import deluge.configmanager
|
||||||
from deluge.core.rpcserver import export
|
from deluge.core.rpcserver import export
|
||||||
|
|
||||||
|
log = getPluginLogger(__name__)
|
||||||
|
|
||||||
DEFAULT_PREFS = {
|
DEFAULT_PREFS = {
|
||||||
"feeds": {},
|
"feeds": {},
|
||||||
"filters": {},
|
"filters": {},
|
||||||
|
|
|
@ -36,11 +36,13 @@
|
||||||
|
|
||||||
import feedparser # for proccessing feed entries
|
import feedparser # for proccessing feed entries
|
||||||
import os
|
import os
|
||||||
from deluge.log import LOG as log
|
from deluge.log import getPluginLogger
|
||||||
from deluge.ui.client import sclient, aclient
|
from deluge.ui.client import sclient, aclient
|
||||||
from deluge.plugins.webuipluginbase import WebUIPluginBase
|
from deluge.plugins.webuipluginbase import WebUIPluginBase
|
||||||
from deluge import component
|
from deluge import component
|
||||||
|
|
||||||
|
log = getPluginLogger(__name__)
|
||||||
|
|
||||||
api = component.get("WebPluginApi")
|
api = component.get("WebPluginApi")
|
||||||
forms = api.forms
|
forms = api.forms
|
||||||
|
|
||||||
|
@ -54,7 +56,7 @@ class feed_page:
|
||||||
items = """%(old)s
|
items = """%(old)s
|
||||||
<a href="%(link)s">
|
<a href="%(link)s">
|
||||||
<li>%(entry)s</li>
|
<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)
|
return api.render.feeder.feeds(items, feedname)
|
||||||
|
|
||||||
class filter_page:
|
class filter_page:
|
||||||
|
@ -63,7 +65,7 @@ class filter_page:
|
||||||
def GET(self, args):
|
def GET(self, args):
|
||||||
new_filter = new_filter_form()
|
new_filter = new_filter_form()
|
||||||
filters = sclient.feeder_get_filters()
|
filters = sclient.feeder_get_filters()
|
||||||
|
|
||||||
# List filters
|
# List filters
|
||||||
txt = ""
|
txt = ""
|
||||||
for filter in filters:
|
for filter in filters:
|
||||||
|
@ -83,7 +85,7 @@ class filter_page:
|
||||||
class new_filter_form(forms.Form):
|
class new_filter_form(forms.Form):
|
||||||
"basic form for a new label"
|
"basic form for a new label"
|
||||||
name = forms.CharField(label="")
|
name = forms.CharField(label="")
|
||||||
|
|
||||||
class filter_settings_page:
|
class filter_settings_page:
|
||||||
"Class for showing filter settings"
|
"Class for showing filter settings"
|
||||||
@api.deco.deluge_page
|
@api.deco.deluge_page
|
||||||
|
@ -117,7 +119,7 @@ class filter_settings_page:
|
||||||
opts['max_upload_slots'] = int(-1)
|
opts['max_upload_slots'] = int(-1)
|
||||||
"""opts['max_upload_slots'] = long(opts['max_upload_slots'])
|
"""opts['max_upload_slots'] = long(opts['max_upload_slots'])
|
||||||
opts['max_connections'] = long(opts['max_connections'])"""
|
opts['max_connections'] = long(opts['max_connections'])"""
|
||||||
|
|
||||||
# TODO filter settings per feed not implemented.
|
# TODO filter settings per feed not implemented.
|
||||||
opts['feeds'] = []
|
opts['feeds'] = []
|
||||||
|
|
||||||
|
@ -151,7 +153,7 @@ class filter_settings_form(forms.Form):
|
||||||
</ul>
|
</ul>
|
||||||
""" % list
|
""" % list
|
||||||
|
|
||||||
regex = forms.CharField(_("regular_expression"))
|
regex = forms.CharField(_("regular_expression"))
|
||||||
all_feeds = forms.CheckBox(_("all_feeds"))
|
all_feeds = forms.CheckBox(_("all_feeds"))
|
||||||
active = forms.CheckBox(_("active"))
|
active = forms.CheckBox(_("active"))
|
||||||
|
|
||||||
|
@ -204,7 +206,7 @@ class remove_filter_page:
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>"""
|
</html>"""
|
||||||
|
|
||||||
|
|
||||||
class WebUI(WebUIPluginBase):
|
class WebUI(WebUIPluginBase):
|
||||||
#map url's to classes: [(url,class), ..]
|
#map url's to classes: [(url,class), ..]
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#
|
#
|
||||||
# __init__.py
|
# __init__.py
|
||||||
#
|
#
|
||||||
# Copyright (C) 2009 Pedro Algarvio <ufs@ufsoft.org>
|
# Copyright (C) 2009-2010 Pedro Algarvio <pedro@algarvio.me>
|
||||||
#
|
#
|
||||||
# Basic plugin template created by:
|
# Basic plugin template created by:
|
||||||
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#
|
#
|
||||||
# common.py
|
# common.py
|
||||||
#
|
#
|
||||||
# Copyright (C) 2009 Pedro Algarvio <ufs@ufsoft.org>
|
# Copyright (C) 2009-2010 Pedro Algarvio <pedro@algarvio.me>
|
||||||
#
|
#
|
||||||
# Basic plugin template created by:
|
# Basic plugin template created by:
|
||||||
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#
|
#
|
||||||
# core.py
|
# core.py
|
||||||
#
|
#
|
||||||
# Copyright (C) 2009 Pedro Algarvio <ufs@ufsoft.org>
|
# Copyright (C) 2009-2010 Pedro Algarvio <pedro@algarvio.me>
|
||||||
#
|
#
|
||||||
# Basic plugin template created by:
|
# Basic plugin template created by:
|
||||||
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
||||||
|
@ -41,13 +41,15 @@
|
||||||
import os, statvfs
|
import os, statvfs
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from twisted.internet import task
|
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.plugins.pluginbase import CorePluginBase
|
||||||
from deluge.event import DelugeEvent
|
from deluge.event import DelugeEvent
|
||||||
import deluge.component as component
|
import deluge.component as component
|
||||||
import deluge.configmanager
|
import deluge.configmanager
|
||||||
from deluge.core.rpcserver import export
|
from deluge.core.rpcserver import export
|
||||||
|
|
||||||
|
log = getPluginLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class LowDiskSpaceEvent(DelugeEvent):
|
class LowDiskSpaceEvent(DelugeEvent):
|
||||||
"""Triggered when the available space for a specific path is getting
|
"""Triggered when the available space for a specific path is getting
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#
|
#
|
||||||
# gtkui.py
|
# gtkui.py
|
||||||
#
|
#
|
||||||
# Copyright (C) 2009 Pedro Algarvio <ufs@ufsoft.org>
|
# Copyright (C) 2009-2010 Pedro Algarvio <pedro@algarvio.me>
|
||||||
#
|
#
|
||||||
# Basic plugin template created by:
|
# Basic plugin template created by:
|
||||||
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
||||||
|
@ -39,7 +39,7 @@
|
||||||
|
|
||||||
import gtk
|
import gtk
|
||||||
|
|
||||||
from deluge.log import LOG as log
|
from deluge.log import getPluginLogger
|
||||||
from deluge.ui.client import client
|
from deluge.ui.client import client
|
||||||
from deluge.plugins.pluginbase import GtkPluginBase
|
from deluge.plugins.pluginbase import GtkPluginBase
|
||||||
import deluge.component as component
|
import deluge.component as component
|
||||||
|
@ -47,6 +47,8 @@ import deluge.common
|
||||||
|
|
||||||
from common import get_resource
|
from common import get_resource
|
||||||
|
|
||||||
|
log = getPluginLogger(__name__)
|
||||||
|
|
||||||
class GtkUI(GtkPluginBase):
|
class GtkUI(GtkPluginBase):
|
||||||
|
|
||||||
def enable(self):
|
def enable(self):
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#
|
#
|
||||||
# webui.py
|
# webui.py
|
||||||
#
|
#
|
||||||
# Copyright (C) 2009 Pedro Algarvio <ufs@ufsoft.org>
|
# Copyright (C) 2009-2010 Pedro Algarvio <pedro@algarvio.me>
|
||||||
#
|
#
|
||||||
# Basic plugin template created by:
|
# Basic plugin template created by:
|
||||||
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
# 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.
|
# 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.ui.client import client
|
||||||
from deluge import component
|
from deluge import component
|
||||||
from deluge.plugins.pluginbase import WebPluginBase
|
from deluge.plugins.pluginbase import WebPluginBase
|
||||||
|
|
||||||
from common import get_resource
|
from common import get_resource
|
||||||
|
|
||||||
|
log = getPluginLogger(__name__)
|
||||||
|
|
||||||
class WebUI(WebPluginBase):
|
class WebUI(WebPluginBase):
|
||||||
|
|
||||||
scripts = [get_resource("freespace.js")]
|
scripts = [get_resource("freespace.js")]
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#
|
#
|
||||||
# setup.py
|
# setup.py
|
||||||
#
|
#
|
||||||
# Copyright (C) 2009 Pedro Algarvio <ufs@ufsoft.org>
|
# Copyright (C) 2009-2010 Pedro Algarvio <pedro@algarvio.me>
|
||||||
#
|
#
|
||||||
# Basic plugin template created by:
|
# Basic plugin template created by:
|
||||||
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
||||||
|
@ -41,7 +41,7 @@ from setuptools import setup
|
||||||
|
|
||||||
__plugin_name__ = "FreeSpace"
|
__plugin_name__ = "FreeSpace"
|
||||||
__author__ = "Pedro Algarvio"
|
__author__ = "Pedro Algarvio"
|
||||||
__author_email__ = "ufs@ufsoft.org"
|
__author_email__ = "pedro@algarvio.me"
|
||||||
__version__ = "0.1"
|
__version__ = "0.1"
|
||||||
__url__ = "http://deluge.ufsoft.org/hg/Notification/"
|
__url__ = "http://deluge.ufsoft.org/hg/Notification/"
|
||||||
__license__ = "GPLv3"
|
__license__ = "GPLv3"
|
||||||
|
|
|
@ -36,7 +36,9 @@
|
||||||
"""
|
"""
|
||||||
This base class is used in plugin's __init__ for the plugin entry points.
|
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):
|
class PluginInitBase(object):
|
||||||
_plugin_cls = None
|
_plugin_cls = None
|
||||||
|
|
|
@ -37,7 +37,7 @@ torrent-label core plugin.
|
||||||
adds a status field for tracker.
|
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.plugins.pluginbase import CorePluginBase
|
||||||
from deluge.core.rpcserver import export
|
from deluge.core.rpcserver import export
|
||||||
from deluge.configmanager import ConfigManager
|
from deluge.configmanager import ConfigManager
|
||||||
|
@ -47,6 +47,8 @@ from urlparse import urlparse
|
||||||
import traceback
|
import traceback
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
log = getPluginLogger(__name__)
|
||||||
|
|
||||||
RE_VALID = re.compile("[a-z0-9_\-\.]*\Z")
|
RE_VALID = re.compile("[a-z0-9_\-\.]*\Z")
|
||||||
|
|
||||||
KNOWN_STATES = ['Downloading','Seeding','Paused','Checking','Queued','Error']
|
KNOWN_STATES = ['Downloading','Seeding','Paused','Checking','Queued','Error']
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import pkg_resources # access plugin egg
|
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 import component # for systray
|
||||||
from deluge.plugins.pluginbase import GtkPluginBase
|
from deluge.plugins.pluginbase import GtkPluginBase
|
||||||
import gtk, gobject
|
import gtk, gobject
|
||||||
|
@ -46,6 +46,8 @@ import sidebar_menu
|
||||||
import label_config
|
import label_config
|
||||||
import submenu
|
import submenu
|
||||||
|
|
||||||
|
log = getPluginLogger(__name__)
|
||||||
|
|
||||||
NO_LABEL = "No Label"
|
NO_LABEL = "No Label"
|
||||||
|
|
||||||
def cell_data_label(column, cell, model, row, data):
|
def cell_data_label(column, cell, model, row, data):
|
||||||
|
|
|
@ -39,9 +39,11 @@ import os
|
||||||
import pkg_resources # access plugin egg
|
import pkg_resources # access plugin egg
|
||||||
import deluge.component as component
|
import deluge.component as component
|
||||||
import deluge.common
|
import deluge.common
|
||||||
from deluge.log import LOG as log
|
from deluge.log import getPluginLogger
|
||||||
from deluge.ui.client import client
|
from deluge.ui.client import client
|
||||||
|
|
||||||
|
log = getPluginLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class LabelConfig(object):
|
class LabelConfig(object):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -40,9 +40,11 @@ import gtk.glade
|
||||||
|
|
||||||
import deluge.component as component
|
import deluge.component as component
|
||||||
import deluge.common
|
import deluge.common
|
||||||
from deluge.log import LOG as log
|
from deluge.log import getPluginLogger
|
||||||
from deluge.ui.client import client
|
from deluge.ui.client import client
|
||||||
|
|
||||||
|
log = getPluginLogger(__name__)
|
||||||
|
|
||||||
NO_LABEL = "No Label"
|
NO_LABEL = "No Label"
|
||||||
|
|
||||||
#helpers:
|
#helpers:
|
||||||
|
|
|
@ -36,11 +36,13 @@
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import pkg_resources # access plugin egg
|
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 import component # for systray
|
||||||
import gtk, gobject
|
import gtk, gobject
|
||||||
from deluge.ui.client import client
|
from deluge.ui.client import client
|
||||||
|
|
||||||
|
log = getPluginLogger(__name__)
|
||||||
|
|
||||||
NO_LABEL = "No Label"
|
NO_LABEL = "No Label"
|
||||||
|
|
||||||
class LabelMenu(gtk.MenuItem):
|
class LabelMenu(gtk.MenuItem):
|
||||||
|
|
|
@ -40,11 +40,13 @@
|
||||||
import os
|
import os
|
||||||
import pkg_resources
|
import pkg_resources
|
||||||
from deluge.common import fspeed
|
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.ui.client import client
|
||||||
from deluge.plugins.pluginbase import WebPluginBase
|
from deluge.plugins.pluginbase import WebPluginBase
|
||||||
from deluge import component
|
from deluge import component
|
||||||
|
|
||||||
|
log = getPluginLogger(__name__)
|
||||||
|
|
||||||
def get_resource(filename):
|
def get_resource(filename):
|
||||||
return pkg_resources.resource_filename("label", os.path.join("data", filename))
|
return pkg_resources.resource_filename("label", os.path.join("data", filename))
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#
|
#
|
||||||
# __init__.py
|
# __init__.py
|
||||||
#
|
#
|
||||||
# Copyright (C) 2009 Pedro Algarvio <ufs@ufsoft.org>
|
# Copyright (C) 2009-2010 Pedro Algarvio <pedro@algarvio.me>
|
||||||
#
|
#
|
||||||
# Basic plugin template created by:
|
# Basic plugin template created by:
|
||||||
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#
|
#
|
||||||
# common.py
|
# common.py
|
||||||
#
|
#
|
||||||
# Copyright (C) 2009 Pedro Algarvio <ufs@ufsoft.org>
|
# Copyright (C) 2009-2010 Pedro Algarvio <pedro@algarvio.me>
|
||||||
#
|
#
|
||||||
# Basic plugin template created by:
|
# Basic plugin template created by:
|
||||||
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
||||||
|
@ -39,7 +39,9 @@
|
||||||
|
|
||||||
from twisted.internet import defer
|
from twisted.internet import defer
|
||||||
from deluge import component
|
from deluge import component
|
||||||
from deluge.log import LOG as log
|
from deluge.log import getPluginLogger
|
||||||
|
|
||||||
|
log = getPluginLogger(__name__)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from deluge.event import known_events
|
from deluge.event import known_events
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#
|
#
|
||||||
# core.py
|
# core.py
|
||||||
#
|
#
|
||||||
# Copyright (C) 2009 Pedro Algarvio <ufs@ufsoft.org>
|
# Copyright (C) 2009-2010 Pedro Algarvio <pedro@algarvio.me>
|
||||||
#
|
#
|
||||||
# Basic plugin template created by:
|
# Basic plugin template created by:
|
||||||
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
||||||
|
@ -41,13 +41,15 @@ import smtplib
|
||||||
from twisted.internet import defer, threads
|
from twisted.internet import defer, threads
|
||||||
from deluge import component
|
from deluge import component
|
||||||
from deluge.event import known_events
|
from deluge.event import known_events
|
||||||
from deluge.log import LOG as log
|
from deluge.log import getPluginLogger
|
||||||
from deluge.plugins.pluginbase import CorePluginBase
|
from deluge.plugins.pluginbase import CorePluginBase
|
||||||
import deluge.configmanager
|
import deluge.configmanager
|
||||||
from deluge.core.rpcserver import export
|
from deluge.core.rpcserver import export
|
||||||
|
|
||||||
from notifications.common import CustomNotifications
|
from notifications.common import CustomNotifications
|
||||||
|
|
||||||
|
log = getPluginLogger(__name__)
|
||||||
|
|
||||||
DEFAULT_PREFS = {
|
DEFAULT_PREFS = {
|
||||||
"smtp_enabled": False,
|
"smtp_enabled": False,
|
||||||
"smtp_host": "",
|
"smtp_host": "",
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#
|
#
|
||||||
# gtkui.py
|
# gtkui.py
|
||||||
#
|
#
|
||||||
# Copyright (C) 2009 Pedro Algarvio <ufs@ufsoft.org>
|
# Copyright (C) 2009-2010 Pedro Algarvio <pedro@algarvio.me>
|
||||||
#
|
#
|
||||||
# Basic plugin template created by:
|
# Basic plugin template created by:
|
||||||
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
||||||
|
@ -41,7 +41,7 @@ from os.path import basename
|
||||||
import gtk
|
import gtk
|
||||||
|
|
||||||
from twisted.internet import defer
|
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.ui.client import client
|
||||||
from deluge.plugins.pluginbase import GtkPluginBase
|
from deluge.plugins.pluginbase import GtkPluginBase
|
||||||
import deluge.component as component
|
import deluge.component as component
|
||||||
|
@ -51,6 +51,8 @@ import deluge.configmanager
|
||||||
# Relative imports
|
# Relative imports
|
||||||
from common import get_resource, CustomNotifications
|
from common import get_resource, CustomNotifications
|
||||||
|
|
||||||
|
log = getPluginLogger(__name__)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import pygame
|
import pygame
|
||||||
SOUND_AVAILABLE = True
|
SOUND_AVAILABLE = True
|
||||||
|
|
|
@ -1,15 +1,17 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# vim: sw=4 ts=4 fenc=utf-8 et
|
# 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.
|
# 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 import component
|
||||||
from deluge.event import DelugeEvent
|
from deluge.event import DelugeEvent
|
||||||
from deluge.log import LOG as log
|
from deluge.log import getPluginLogger
|
||||||
|
|
||||||
|
log = getPluginLogger(__name__)
|
||||||
|
|
||||||
class FooEvent(DelugeEvent):
|
class FooEvent(DelugeEvent):
|
||||||
"""foo Event"""
|
"""foo Event"""
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#
|
#
|
||||||
# webui.py
|
# webui.py
|
||||||
#
|
#
|
||||||
# Copyright (C) 2009 Pedro Algarvio <ufs@ufsoft.org>
|
# Copyright (C) 2009-2010 Pedro Algarvio <pedro@algarvio.me>
|
||||||
#
|
#
|
||||||
# Basic plugin template created by:
|
# Basic plugin template created by:
|
||||||
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
||||||
|
@ -38,7 +38,7 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
from twisted.internet import defer
|
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.ui.client import client
|
||||||
from deluge import component
|
from deluge import component
|
||||||
from deluge.plugins.pluginbase import WebPluginBase
|
from deluge.plugins.pluginbase import WebPluginBase
|
||||||
|
@ -47,6 +47,8 @@ import deluge.configmanager
|
||||||
# Relative imports
|
# Relative imports
|
||||||
from common import get_resource
|
from common import get_resource
|
||||||
|
|
||||||
|
log = getPluginLogger(__name__)
|
||||||
|
|
||||||
DEFAULT_PREFS = {
|
DEFAULT_PREFS = {
|
||||||
# FLASH
|
# FLASH
|
||||||
"flash_enabled": False,
|
"flash_enabled": False,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#
|
#
|
||||||
# setup.py
|
# setup.py
|
||||||
#
|
#
|
||||||
# Copyright (C) 2009 Pedro Algarvio <ufs@ufsoft.org>
|
# Copyright (C) 2009-2010 Pedro Algarvio <pedro@algarvio.me>
|
||||||
#
|
#
|
||||||
# Basic plugin template created by:
|
# Basic plugin template created by:
|
||||||
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
||||||
|
@ -41,7 +41,7 @@ from setuptools import setup, find_packages
|
||||||
|
|
||||||
__plugin_name__ = "Notifications"
|
__plugin_name__ = "Notifications"
|
||||||
__author__ = "Pedro Algarvio"
|
__author__ = "Pedro Algarvio"
|
||||||
__author_email__ = "ufs@ufsoft.org"
|
__author_email__ = "pedro@algarvio.me"
|
||||||
__version__ = "0.1"
|
__version__ = "0.1"
|
||||||
__url__ = "http://dev.deluge-torrent.org/"
|
__url__ = "http://dev.deluge-torrent.org/"
|
||||||
__license__ = "GPLv3"
|
__license__ = "GPLv3"
|
||||||
|
|
|
@ -33,8 +33,10 @@
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
|
|
||||||
|
import logging
|
||||||
import deluge.component as component
|
import deluge.component as component
|
||||||
from deluge.log import LOG as log
|
|
||||||
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
class PluginBase(component.Component):
|
class PluginBase(component.Component):
|
||||||
|
|
||||||
|
@ -42,7 +44,7 @@ class PluginBase(component.Component):
|
||||||
|
|
||||||
def __init__(self, name):
|
def __init__(self, name):
|
||||||
super(PluginBase, self).__init__(name, self.update_interval)
|
super(PluginBase, self).__init__(name, self.update_interval)
|
||||||
|
|
||||||
def enable(self):
|
def enable(self):
|
||||||
raise NotImplementedError("Need to define an enable method!")
|
raise NotImplementedError("Need to define an enable method!")
|
||||||
|
|
||||||
|
@ -62,20 +64,20 @@ class GtkPluginBase(PluginBase):
|
||||||
log.debug("GtkPlugin initialized..")
|
log.debug("GtkPlugin initialized..")
|
||||||
|
|
||||||
class WebPluginBase(PluginBase):
|
class WebPluginBase(PluginBase):
|
||||||
|
|
||||||
scripts = []
|
scripts = []
|
||||||
debug_scripts = []
|
debug_scripts = []
|
||||||
|
|
||||||
stylesheets = []
|
stylesheets = []
|
||||||
debug_stylesheets = []
|
debug_stylesheets = []
|
||||||
|
|
||||||
def __init__(self, plugin_name):
|
def __init__(self, plugin_name):
|
||||||
super(WebPluginBase, self).__init__("WebPlugin." + plugin_name)
|
super(WebPluginBase, self).__init__("WebPlugin." + plugin_name)
|
||||||
|
|
||||||
# Register JSON rpc methods
|
# Register JSON rpc methods
|
||||||
component.get("JSON").register_object(self, plugin_name.lower())
|
component.get("JSON").register_object(self, plugin_name.lower())
|
||||||
log.debug("WebPlugin initialized..")
|
log.debug("WebPlugin initialized..")
|
||||||
|
|
||||||
def enable(self):
|
def enable(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@
|
||||||
|
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from deluge.log import LOG as log
|
from deluge.log import getPluginLogger
|
||||||
from deluge.plugins.pluginbase import CorePluginBase
|
from deluge.plugins.pluginbase import CorePluginBase
|
||||||
import deluge.component as component
|
import deluge.component as component
|
||||||
import deluge.configmanager
|
import deluge.configmanager
|
||||||
|
@ -47,6 +47,8 @@ from deluge.event import DelugeEvent
|
||||||
|
|
||||||
from twisted.internet import reactor
|
from twisted.internet import reactor
|
||||||
|
|
||||||
|
log = getPluginLogger(__name__)
|
||||||
|
|
||||||
DEFAULT_PREFS = {
|
DEFAULT_PREFS = {
|
||||||
"low_down": -1.0,
|
"low_down": -1.0,
|
||||||
"low_up": -1.0,
|
"low_up": -1.0,
|
||||||
|
|
|
@ -38,7 +38,7 @@
|
||||||
|
|
||||||
import gtk
|
import gtk
|
||||||
|
|
||||||
from deluge.log import LOG as log
|
from deluge.log import getPluginLogger
|
||||||
from deluge.ui.client import client
|
from deluge.ui.client import client
|
||||||
from deluge.plugins.pluginbase import GtkPluginBase
|
from deluge.plugins.pluginbase import GtkPluginBase
|
||||||
import deluge.component as component
|
import deluge.component as component
|
||||||
|
@ -46,6 +46,8 @@ import deluge.common
|
||||||
|
|
||||||
from common import get_resource
|
from common import get_resource
|
||||||
|
|
||||||
|
log = getPluginLogger(__name__)
|
||||||
|
|
||||||
DAYS = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]
|
DAYS = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]
|
||||||
|
|
||||||
class SchedulerSelectWidget(gtk.DrawingArea):
|
class SchedulerSelectWidget(gtk.DrawingArea):
|
||||||
|
|
|
@ -36,13 +36,15 @@
|
||||||
# statement from all source files in the program, then also delete it here.
|
# 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.ui.client import client
|
||||||
from deluge import component
|
from deluge import component
|
||||||
from deluge.plugins.pluginbase import WebPluginBase
|
from deluge.plugins.pluginbase import WebPluginBase
|
||||||
|
|
||||||
from common import get_resource
|
from common import get_resource
|
||||||
|
|
||||||
|
log = getPluginLogger(__name__)
|
||||||
|
|
||||||
class WebUI(WebPluginBase):
|
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 time
|
||||||
|
|
||||||
import deluge
|
import deluge
|
||||||
from deluge.log import LOG as log
|
from deluge.log import getPluginLogger
|
||||||
from deluge.plugins.pluginbase import CorePluginBase
|
from deluge.plugins.pluginbase import CorePluginBase
|
||||||
from deluge import component
|
from deluge import component
|
||||||
from deluge import configmanager
|
from deluge import configmanager
|
||||||
from deluge.core.rpcserver import export
|
from deluge.core.rpcserver import export
|
||||||
|
|
||||||
|
log = getPluginLogger(__name__)
|
||||||
|
|
||||||
DEFAULT_PREFS = {
|
DEFAULT_PREFS = {
|
||||||
"test": "NiNiNi",
|
"test": "NiNiNi",
|
||||||
"update_interval": 2, #2 seconds.
|
"update_interval": 2, #2 seconds.
|
||||||
|
|
|
@ -48,7 +48,7 @@ port of old plugin by markybob.
|
||||||
"""
|
"""
|
||||||
import time
|
import time
|
||||||
import cairo
|
import cairo
|
||||||
from deluge.log import LOG as log
|
from deluge.log import getPluginLogger
|
||||||
from deluge.ui.client import client
|
from deluge.ui.client import client
|
||||||
|
|
||||||
black = (0, 0, 0)
|
black = (0, 0, 0)
|
||||||
|
@ -60,6 +60,8 @@ green = (0, 1.0, 0)
|
||||||
blue = (0, 0, 1.0)
|
blue = (0, 0, 1.0)
|
||||||
orange = (1.0, 0.74, 0)
|
orange = (1.0, 0.74, 0)
|
||||||
|
|
||||||
|
log = getPluginLogger(__name__)
|
||||||
|
|
||||||
def default_formatter(value):
|
def default_formatter(value):
|
||||||
return str(value)
|
return str(value)
|
||||||
|
|
||||||
|
|
|
@ -53,12 +53,14 @@ from twisted.internet import defer
|
||||||
|
|
||||||
import graph
|
import graph
|
||||||
from deluge import component
|
from deluge import component
|
||||||
from deluge.log import LOG as log
|
from deluge.log import getPluginLogger
|
||||||
from deluge.common import fspeed
|
from deluge.common import fspeed
|
||||||
from deluge.ui.client import client
|
from deluge.ui.client import client
|
||||||
from deluge.ui.gtkui.torrentdetails import Tab
|
from deluge.ui.gtkui.torrentdetails import Tab
|
||||||
from deluge.plugins.pluginbase import GtkPluginBase
|
from deluge.plugins.pluginbase import GtkPluginBase
|
||||||
|
|
||||||
|
log = getPluginLogger(__name__)
|
||||||
|
|
||||||
class GraphsTab(Tab):
|
class GraphsTab(Tab):
|
||||||
def __init__(self, glade):
|
def __init__(self, glade):
|
||||||
Tab.__init__(self)
|
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.ui.client import client
|
||||||
from deluge import component
|
from deluge import component
|
||||||
from deluge.plugins.pluginbase import WebPluginBase
|
from deluge.plugins.pluginbase import WebPluginBase
|
||||||
|
|
||||||
from common import get_resource
|
from common import get_resource
|
||||||
|
|
||||||
|
log = getPluginLogger(__name__)
|
||||||
|
|
||||||
class WebUI(WebPluginBase):
|
class WebUI(WebPluginBase):
|
||||||
|
|
||||||
scripts = [get_resource("stats.js")]
|
scripts = [get_resource("stats.js")]
|
||||||
|
|
||||||
# The enable and disable methods are not scrictly required on the WebUI
|
# The enable and disable methods are not scrictly required on the WebUI
|
||||||
# plugins. They are only here if you need to register images/stylesheets
|
# plugins. They are only here if you need to register images/stylesheets
|
||||||
# with the webserver.
|
# with the webserver.
|
||||||
|
|
|
@ -37,12 +37,14 @@
|
||||||
# statement from all source files in the program, then also delete it here.
|
# 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
|
from deluge.plugins.pluginbase import CorePluginBase
|
||||||
import deluge.component as component
|
import deluge.component as component
|
||||||
import deluge.configmanager
|
import deluge.configmanager
|
||||||
from deluge.core.rpcserver import export
|
from deluge.core.rpcserver import export
|
||||||
|
|
||||||
|
log = getPluginLogger(__name__)
|
||||||
|
|
||||||
DEFAULT_PREFS = {
|
DEFAULT_PREFS = {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
|
|
||||||
import gtk
|
import gtk
|
||||||
|
|
||||||
from deluge.log import LOG as log
|
from deluge.log import getPluginLogger
|
||||||
from deluge.ui.client import client
|
from deluge.ui.client import client
|
||||||
from deluge.plugins.pluginbase import GtkPluginBase
|
from deluge.plugins.pluginbase import GtkPluginBase
|
||||||
import deluge.component as component
|
import deluge.component as component
|
||||||
|
@ -47,6 +47,8 @@ import deluge.common
|
||||||
|
|
||||||
from common import get_resource
|
from common import get_resource
|
||||||
|
|
||||||
|
log = getPluginLogger(__name__)
|
||||||
|
|
||||||
class GtkUI(GtkPluginBase):
|
class GtkUI(GtkPluginBase):
|
||||||
def enable(self):
|
def enable(self):
|
||||||
self.core = client.toggle
|
self.core = client.toggle
|
||||||
|
|
|
@ -37,13 +37,15 @@
|
||||||
# statement from all source files in the program, then also delete it here.
|
# 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.ui.client import client
|
||||||
from deluge import component
|
from deluge import component
|
||||||
from deluge.plugins.pluginbase import WebPluginBase
|
from deluge.plugins.pluginbase import WebPluginBase
|
||||||
|
|
||||||
from common import get_resource
|
from common import get_resource
|
||||||
|
|
||||||
|
log = getPluginLogger(__name__)
|
||||||
|
|
||||||
class WebUI(WebPluginBase):
|
class WebUI(WebPluginBase):
|
||||||
|
|
||||||
scripts = [get_resource("toggle.js")]
|
scripts = [get_resource("toggle.js")]
|
||||||
|
|
|
@ -39,10 +39,12 @@
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from deluge import common, component, configmanager
|
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.plugins.pluginbase import CorePluginBase
|
||||||
from deluge.core.rpcserver import export
|
from deluge.core.rpcserver import export
|
||||||
|
|
||||||
|
log = getPluginLogger(__name__)
|
||||||
|
|
||||||
DEFAULT_PREFS = {
|
DEFAULT_PREFS = {
|
||||||
"enabled": False,
|
"enabled": False,
|
||||||
"ssl": False,
|
"ssl": False,
|
||||||
|
@ -50,8 +52,8 @@ DEFAULT_PREFS = {
|
||||||
}
|
}
|
||||||
|
|
||||||
class Core(CorePluginBase):
|
class Core(CorePluginBase):
|
||||||
|
|
||||||
|
|
||||||
def enable(self):
|
def enable(self):
|
||||||
self.config = configmanager.ConfigManager("web_plugin.conf", DEFAULT_PREFS)
|
self.config = configmanager.ConfigManager("web_plugin.conf", DEFAULT_PREFS)
|
||||||
self.server = None
|
self.server = None
|
||||||
|
@ -64,13 +66,13 @@ class Core(CorePluginBase):
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def restart(self):
|
def restart(self):
|
||||||
if self.server:
|
if self.server:
|
||||||
self.server.stop().addCallback(self.on_stop)
|
self.server.stop().addCallback(self.on_stop)
|
||||||
else:
|
else:
|
||||||
self.start()
|
self.start()
|
||||||
|
|
||||||
def on_stop(self, *args):
|
def on_stop(self, *args):
|
||||||
self.start()
|
self.start()
|
||||||
|
|
||||||
|
@ -81,7 +83,7 @@ class Core(CorePluginBase):
|
||||||
return True
|
return True
|
||||||
except ImportError:
|
except ImportError:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@export
|
@export
|
||||||
def start(self):
|
def start(self):
|
||||||
if not self.server:
|
if not self.server:
|
||||||
|
@ -96,7 +98,7 @@ class Core(CorePluginBase):
|
||||||
self.server.https = self.config["ssl"]
|
self.server.https = self.config["ssl"]
|
||||||
self.server.start(False)
|
self.server.start(False)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@export
|
@export
|
||||||
def stop(self):
|
def stop(self):
|
||||||
if self.server:
|
if self.server:
|
||||||
|
@ -110,7 +112,7 @@ class Core(CorePluginBase):
|
||||||
if "enabled" in config:
|
if "enabled" in config:
|
||||||
if config["enabled"] != self.config["enabled"]:
|
if config["enabled"] != self.config["enabled"]:
|
||||||
action = config["enabled"] and 'start' or 'stop'
|
action = config["enabled"] and 'start' or 'stop'
|
||||||
|
|
||||||
if "ssl" in config:
|
if "ssl" in config:
|
||||||
if not action:
|
if not action:
|
||||||
action = 'restart'
|
action = 'restart'
|
||||||
|
@ -118,7 +120,7 @@ class Core(CorePluginBase):
|
||||||
for key in config.keys():
|
for key in config.keys():
|
||||||
self.config[key] = config[key]
|
self.config[key] = config[key]
|
||||||
self.config.save()
|
self.config.save()
|
||||||
|
|
||||||
if action == 'start':
|
if action == 'start':
|
||||||
return self.start()
|
return self.start()
|
||||||
elif action == 'stop':
|
elif action == 'stop':
|
||||||
|
|
|
@ -38,7 +38,7 @@
|
||||||
|
|
||||||
import gtk
|
import gtk
|
||||||
|
|
||||||
from deluge.log import LOG as log
|
from deluge.log import getPluginLogger
|
||||||
from deluge.ui.client import client
|
from deluge.ui.client import client
|
||||||
from deluge.plugins.pluginbase import GtkPluginBase
|
from deluge.plugins.pluginbase import GtkPluginBase
|
||||||
import deluge.component as component
|
import deluge.component as component
|
||||||
|
@ -46,6 +46,8 @@ import deluge.common
|
||||||
|
|
||||||
from common import get_resource
|
from common import get_resource
|
||||||
|
|
||||||
|
log = getPluginLogger(__name__)
|
||||||
|
|
||||||
class GtkUI(GtkPluginBase):
|
class GtkUI(GtkPluginBase):
|
||||||
def enable(self):
|
def enable(self):
|
||||||
self.glade = gtk.glade.XML(get_resource("config.glade"))
|
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("enabled_checkbutton").set_active(config["enabled"])
|
||||||
self.glade.get_widget("ssl_checkbutton").set_active(config["ssl"])
|
self.glade.get_widget("ssl_checkbutton").set_active(config["ssl"])
|
||||||
self.glade.get_widget("port_spinbutton").set_value(config["port"])
|
self.glade.get_widget("port_spinbutton").set_value(config["port"])
|
||||||
|
|
||||||
def cb_chk_deluge_web(self, have_web):
|
def cb_chk_deluge_web(self, have_web):
|
||||||
self.have_web = have_web
|
self.have_web = have_web
|
||||||
if 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
|
from optparse import OptionParser
|
||||||
import os
|
import os
|
||||||
import deluge.common
|
import deluge.common
|
||||||
|
@ -64,7 +65,8 @@ def create_plugin():
|
||||||
"filename":filename,
|
"filename":filename,
|
||||||
"plugin_base":plugin_base,
|
"plugin_base":plugin_base,
|
||||||
"url": options.url,
|
"url": options.url,
|
||||||
"configdir": options.configdir
|
"configdir": options.configdir,
|
||||||
|
"current_year": datetime.utcnow().year
|
||||||
}
|
}
|
||||||
|
|
||||||
filename = os.path.join(path, filename)
|
filename = os.path.join(path, filename)
|
||||||
|
@ -98,7 +100,6 @@ def create_plugin():
|
||||||
|
|
||||||
|
|
||||||
CORE = """
|
CORE = """
|
||||||
from deluge.log import LOG as log
|
|
||||||
from deluge.plugins.pluginbase import CorePluginBase
|
from deluge.plugins.pluginbase import CorePluginBase
|
||||||
import deluge.component as component
|
import deluge.component as component
|
||||||
import deluge.configmanager
|
import deluge.configmanager
|
||||||
|
@ -192,6 +193,7 @@ setup(
|
||||||
"""
|
"""
|
||||||
|
|
||||||
COMMON = """
|
COMMON = """
|
||||||
|
|
||||||
def get_resource(filename):
|
def get_resource(filename):
|
||||||
import pkg_resources, os
|
import pkg_resources, os
|
||||||
return pkg_resources.resource_filename("%(safe_name)s", os.path.join("data", filename))
|
return pkg_resources.resource_filename("%(safe_name)s", os.path.join("data", filename))
|
||||||
|
@ -200,7 +202,7 @@ def get_resource(filename):
|
||||||
GTKUI = """
|
GTKUI = """
|
||||||
import gtk
|
import gtk
|
||||||
|
|
||||||
from deluge.log import LOG as log
|
from deluge.log import getPluginLogger
|
||||||
from deluge.ui.client import client
|
from deluge.ui.client import client
|
||||||
from deluge.plugins.pluginbase import GtkPluginBase
|
from deluge.plugins.pluginbase import GtkPluginBase
|
||||||
import deluge.component as component
|
import deluge.component as component
|
||||||
|
@ -208,6 +210,8 @@ import deluge.common
|
||||||
|
|
||||||
from common import get_resource
|
from common import get_resource
|
||||||
|
|
||||||
|
log = getPluginLogger(__name__)
|
||||||
|
|
||||||
class GtkUI(GtkPluginBase):
|
class GtkUI(GtkPluginBase):
|
||||||
def enable(self):
|
def enable(self):
|
||||||
self.glade = gtk.glade.XML(get_resource("config.glade"))
|
self.glade = gtk.glade.XML(get_resource("config.glade"))
|
||||||
|
@ -266,13 +270,15 @@ GLADE = """<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
"""
|
"""
|
||||||
|
|
||||||
WEBUI = """
|
WEBUI = """
|
||||||
from deluge.log import LOG as log
|
from deluge.log import getPluginLogger
|
||||||
from deluge.ui.client import client
|
from deluge.ui.client import client
|
||||||
from deluge import component
|
from deluge import component
|
||||||
from deluge.plugins.pluginbase import WebPluginBase
|
from deluge.plugins.pluginbase import WebPluginBase
|
||||||
|
|
||||||
from common import get_resource
|
from common import get_resource
|
||||||
|
|
||||||
|
log = getPluginLogger(__name__)
|
||||||
|
|
||||||
class WebUI(WebPluginBase):
|
class WebUI(WebPluginBase):
|
||||||
|
|
||||||
scripts = [get_resource("%(safe_name)s.js")]
|
scripts = [get_resource("%(safe_name)s.js")]
|
||||||
|
@ -289,7 +295,7 @@ Script: %(filename)s
|
||||||
The client-side javascript code for the %(name)s plugin.
|
The client-side javascript code for the %(name)s plugin.
|
||||||
|
|
||||||
Copyright:
|
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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation; either version 3, or (at your option)
|
the Free Software Foundation; either version 3, or (at your option)
|
||||||
|
@ -318,20 +324,20 @@ Copyright:
|
||||||
*/
|
*/
|
||||||
|
|
||||||
%(name)sPlugin = Ext.extend(Deluge.Plugin, {
|
%(name)sPlugin = Ext.extend(Deluge.Plugin, {
|
||||||
constructor: function(config) {
|
constructor: function(config) {
|
||||||
config = Ext.apply({
|
config = Ext.apply({
|
||||||
name: "%(name)s"
|
name: "%(name)s"
|
||||||
}, config);
|
}, config);
|
||||||
%(name)sPlugin.superclass.constructor.call(this, config);
|
%(name)sPlugin.superclass.constructor.call(this, config);
|
||||||
},
|
},
|
||||||
|
|
||||||
onDisable: function() {
|
onDisable: function() {
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
onEnable: function() {
|
onEnable: function() {
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
new %(name)sPlugin();
|
new %(name)sPlugin();
|
||||||
"""
|
"""
|
||||||
|
@ -339,12 +345,13 @@ new %(name)sPlugin();
|
||||||
GPL = """#
|
GPL = """#
|
||||||
# %(filename)s
|
# %(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:
|
# Basic plugin template created by:
|
||||||
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
|
||||||
# Copyright (C) 2007-2009 Andrew Resch <andrewresch@gmail.com>
|
# Copyright (C) 2007-2009 Andrew Resch <andrewresch@gmail.com>
|
||||||
# Copyright (C) 2009 Damien Churchill <damoxc@gmail.com>
|
# Copyright (C) 2009 Damien Churchill <damoxc@gmail.com>
|
||||||
|
# Copyright (C) 2010 Pedro Algarvio <pedro@algarvio.me>
|
||||||
#
|
#
|
||||||
# Deluge is free software.
|
# 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.protocol import Protocol, ClientFactory
|
||||||
from twisted.internet import reactor, ssl, defer
|
from twisted.internet import reactor, ssl, defer
|
||||||
try:
|
try:
|
||||||
|
@ -44,7 +45,6 @@ import zlib
|
||||||
|
|
||||||
import deluge.common
|
import deluge.common
|
||||||
import deluge.component as component
|
import deluge.component as component
|
||||||
from deluge.log import LOG as log
|
|
||||||
|
|
||||||
if deluge.common.windows_check():
|
if deluge.common.windows_check():
|
||||||
import win32api
|
import win32api
|
||||||
|
@ -55,6 +55,8 @@ RPC_RESPONSE = 1
|
||||||
RPC_ERROR = 2
|
RPC_ERROR = 2
|
||||||
RPC_EVENT = 3
|
RPC_EVENT = 3
|
||||||
|
|
||||||
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
def format_kwargs(kwargs):
|
def format_kwargs(kwargs):
|
||||||
return ", ".join([key + "=" + str(value) for key, value in kwargs.items()])
|
return ", ".join([key + "=" + str(value) for key, value in kwargs.items()])
|
||||||
|
|
||||||
|
@ -140,7 +142,7 @@ class DelugeRPCProtocol(Protocol):
|
||||||
while data:
|
while data:
|
||||||
# Increase the byte counter
|
# Increase the byte counter
|
||||||
self.factory.bytes_recv += len(data)
|
self.factory.bytes_recv += len(data)
|
||||||
|
|
||||||
dobj = zlib.decompressobj()
|
dobj = zlib.decompressobj()
|
||||||
try:
|
try:
|
||||||
request = rencode.loads(dobj.decompress(data))
|
request = rencode.loads(dobj.decompress(data))
|
||||||
|
@ -213,7 +215,7 @@ class DelugeRPCClientFactory(ClientFactory):
|
||||||
def __init__(self, daemon, event_handlers):
|
def __init__(self, daemon, event_handlers):
|
||||||
self.daemon = daemon
|
self.daemon = daemon
|
||||||
self.event_handlers = event_handlers
|
self.event_handlers = event_handlers
|
||||||
|
|
||||||
self.bytes_recv = 0
|
self.bytes_recv = 0
|
||||||
self.bytes_sent = 0
|
self.bytes_sent = 0
|
||||||
|
|
||||||
|
@ -329,7 +331,7 @@ class DaemonSSLProxy(DaemonProxy):
|
||||||
|
|
||||||
:param request_id: the request_id of the Deferred to pop
|
:param request_id: the request_id of the Deferred to pop
|
||||||
:type request_id: int
|
:type request_id: int
|
||||||
|
|
||||||
"""
|
"""
|
||||||
return self.__deferred.pop(request_id)
|
return self.__deferred.pop(request_id)
|
||||||
|
|
||||||
|
@ -343,7 +345,7 @@ class DaemonSSLProxy(DaemonProxy):
|
||||||
:param handler: the function to be called when `:param:event`
|
:param handler: the function to be called when `:param:event`
|
||||||
is emitted from the daemon
|
is emitted from the daemon
|
||||||
:type handler: function
|
:type handler: function
|
||||||
|
|
||||||
"""
|
"""
|
||||||
if event not in self.__factory.event_handlers:
|
if event not in self.__factory.event_handlers:
|
||||||
# This is a new event to handle, so we need to tell the daemon
|
# 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):
|
def get_bytes_recv(self):
|
||||||
return self.__factory.bytes_recv
|
return self.__factory.bytes_recv
|
||||||
|
|
||||||
def get_bytes_sent(self):
|
def get_bytes_sent(self):
|
||||||
return self.__factory.bytes_sent
|
return self.__factory.bytes_sent
|
||||||
|
|
||||||
class DaemonClassicProxy(DaemonProxy):
|
class DaemonClassicProxy(DaemonProxy):
|
||||||
def __init__(self, event_handlers={}):
|
def __init__(self, event_handlers={}):
|
||||||
import deluge.core.daemon
|
import deluge.core.daemon
|
||||||
|
@ -466,7 +468,7 @@ class DaemonClassicProxy(DaemonProxy):
|
||||||
:param handler: the function to be called when `:param:event`
|
:param handler: the function to be called when `:param:event`
|
||||||
is emitted from the daemon
|
is emitted from the daemon
|
||||||
:type handler: function
|
:type handler: function
|
||||||
|
|
||||||
"""
|
"""
|
||||||
self.__daemon.core.eventmanager.register_event_handler(event, handler)
|
self.__daemon.core.eventmanager.register_event_handler(event, handler)
|
||||||
|
|
||||||
|
@ -571,7 +573,7 @@ class Client(object):
|
||||||
:rtype: bool
|
:rtype: bool
|
||||||
|
|
||||||
:raises OSError: received from subprocess.call()
|
:raises OSError: received from subprocess.call()
|
||||||
|
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
if deluge.common.windows_check():
|
if deluge.common.windows_check():
|
||||||
|
@ -679,7 +681,7 @@ class Client(object):
|
||||||
def get_bytes_recv(self):
|
def get_bytes_recv(self):
|
||||||
"""
|
"""
|
||||||
Returns the number of bytes received from the daemon.
|
Returns the number of bytes received from the daemon.
|
||||||
|
|
||||||
:returns: the number of bytes received
|
:returns: the number of bytes received
|
||||||
:rtype: int
|
:rtype: int
|
||||||
"""
|
"""
|
||||||
|
@ -688,11 +690,11 @@ class Client(object):
|
||||||
def get_bytes_sent(self):
|
def get_bytes_sent(self):
|
||||||
"""
|
"""
|
||||||
Returns the number of bytes sent to the daemon.
|
Returns the number of bytes sent to the daemon.
|
||||||
|
|
||||||
:returns: the number of bytes sent
|
:returns: the number of bytes sent
|
||||||
:rtype: int
|
:rtype: int
|
||||||
"""
|
"""
|
||||||
return self._daemon_proxy.get_bytes_sent()
|
return self._daemon_proxy.get_bytes_sent()
|
||||||
|
|
||||||
# This is the object clients will use
|
# This is the object clients will use
|
||||||
client = Client()
|
client = Client()
|
||||||
|
|
|
@ -40,6 +40,7 @@ all the interfaces.
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
import logging
|
||||||
import urlparse
|
import urlparse
|
||||||
|
|
||||||
import locale
|
import locale
|
||||||
|
@ -51,9 +52,10 @@ except ImportError:
|
||||||
|
|
||||||
from deluge import bencode
|
from deluge import bencode
|
||||||
from deluge.common import decode_string, path_join
|
from deluge.common import decode_string, path_join
|
||||||
from deluge.log import LOG as log
|
|
||||||
import deluge.configmanager
|
import deluge.configmanager
|
||||||
|
|
||||||
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
class TorrentInfo(object):
|
class TorrentInfo(object):
|
||||||
"""
|
"""
|
||||||
Collects information about a torrent file.
|
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 twisted.internet import defer
|
||||||
|
|
||||||
from deluge.ui.console.main import BaseCommand
|
from deluge.ui.console.main import BaseCommand
|
||||||
import deluge.ui.console.colors as colors
|
import deluge.ui.console.colors as colors
|
||||||
from deluge.ui.client import client
|
from deluge.ui.client import client
|
||||||
import deluge.component as component
|
import deluge.component as component
|
||||||
from deluge.log import LOG as log
|
|
||||||
|
|
||||||
from optparse import make_option
|
log = logging.getLogger(__name__)
|
||||||
import re
|
|
||||||
|
|
||||||
import cStringIO, tokenize
|
|
||||||
|
|
||||||
def atom(next, token):
|
def atom(next, token):
|
||||||
"""taken with slight modifications from http://effbot.org/zone/simple-iterator-parser.htm"""
|
"""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.component as component
|
||||||
import deluge.common
|
import deluge.common
|
||||||
import colors
|
import colors
|
||||||
from deluge.ui.client import client
|
from deluge.ui.client import client
|
||||||
|
|
||||||
from deluge.log import LOG as log
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
class EventLog(component.Component):
|
class EventLog(component.Component):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -34,7 +34,9 @@
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
|
|
||||||
import os, sys
|
import os
|
||||||
|
import sys
|
||||||
|
import logging
|
||||||
import optparse
|
import optparse
|
||||||
import shlex
|
import shlex
|
||||||
import locale
|
import locale
|
||||||
|
@ -50,9 +52,10 @@ from deluge.ui.console.statusbars import StatusBars
|
||||||
from deluge.ui.console.eventlog import EventLog
|
from deluge.ui.console.eventlog import EventLog
|
||||||
import screen
|
import screen
|
||||||
import colors
|
import colors
|
||||||
from deluge.log import LOG as log
|
|
||||||
from deluge.ui.ui import _UI
|
from deluge.ui.ui import _UI
|
||||||
|
|
||||||
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
class Console(_UI):
|
class Console(_UI):
|
||||||
|
|
||||||
help = """Starts the Deluge console interface"""
|
help = """Starts the Deluge console interface"""
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
import logging
|
||||||
try:
|
try:
|
||||||
import curses
|
import curses
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
@ -48,9 +49,10 @@ try:
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
from deluge.log import LOG as log
|
|
||||||
from twisted.internet import reactor
|
from twisted.internet import reactor
|
||||||
|
|
||||||
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
class CursesStdIO(object):
|
class CursesStdIO(object):
|
||||||
"""fake fd to be registered as a reader with the twisted reactor.
|
"""fake fd to be registered as a reader with the twisted reactor.
|
||||||
Curses classes needing input should extend this"""
|
Curses classes needing input should extend this"""
|
||||||
|
|
|
@ -34,9 +34,11 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
||||||
|
import logging
|
||||||
import deluge.component as component
|
import deluge.component as component
|
||||||
from deluge.ui.client import client
|
from deluge.ui.client import client
|
||||||
from deluge.log import LOG as log
|
|
||||||
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
class CoreConfig(component.Component):
|
class CoreConfig(component.Component):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|
|
@ -36,10 +36,12 @@
|
||||||
|
|
||||||
import pygtk
|
import pygtk
|
||||||
pygtk.require('2.0')
|
pygtk.require('2.0')
|
||||||
import gtk, gtk.glade
|
import gtk
|
||||||
|
import gtk.glade
|
||||||
import gettext
|
import gettext
|
||||||
import gobject
|
import gobject
|
||||||
import base64
|
import base64
|
||||||
|
import logging
|
||||||
import os
|
import os
|
||||||
|
|
||||||
import pkg_resources
|
import pkg_resources
|
||||||
|
@ -48,12 +50,13 @@ from deluge.ui.client import client
|
||||||
import deluge.component as component
|
import deluge.component as component
|
||||||
import listview
|
import listview
|
||||||
from deluge.configmanager import ConfigManager
|
from deluge.configmanager import ConfigManager
|
||||||
from deluge.log import LOG as log
|
|
||||||
import deluge.common
|
import deluge.common
|
||||||
import deluge.ui.common
|
import deluge.ui.common
|
||||||
import dialogs
|
import dialogs
|
||||||
import common
|
import common
|
||||||
|
|
||||||
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
class AddTorrentDialog(component.Component):
|
class AddTorrentDialog(component.Component):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
component.Component.__init__(self, "AddTorrentDialog")
|
component.Component.__init__(self, "AddTorrentDialog")
|
||||||
|
|
|
@ -39,15 +39,17 @@ import os
|
||||||
|
|
||||||
import pygtk
|
import pygtk
|
||||||
pygtk.require('2.0')
|
pygtk.require('2.0')
|
||||||
import gtk, gtk.glade
|
import gtk
|
||||||
|
import gtk.glade
|
||||||
|
import logging
|
||||||
import pkg_resources
|
import pkg_resources
|
||||||
|
|
||||||
from deluge.ui.client import client
|
from deluge.ui.client import client
|
||||||
import deluge.component as component
|
import deluge.component as component
|
||||||
from deluge.log import LOG as log
|
|
||||||
import deluge.common
|
import deluge.common
|
||||||
|
|
||||||
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
def get_logo(size):
|
def get_logo(size):
|
||||||
"""Returns a deluge logo pixbuf based on the size parameter."""
|
"""Returns a deluge logo pixbuf based on the size parameter."""
|
||||||
if deluge.common.windows_check() or deluge.common.osx_check():
|
if deluge.common.windows_check() or deluge.common.osx_check():
|
||||||
|
|
|
@ -38,6 +38,7 @@ import pkg_resources
|
||||||
import urlparse
|
import urlparse
|
||||||
import time
|
import time
|
||||||
import hashlib
|
import hashlib
|
||||||
|
import logging
|
||||||
from twisted.internet import reactor
|
from twisted.internet import reactor
|
||||||
|
|
||||||
import deluge.component as component
|
import deluge.component as component
|
||||||
|
@ -48,9 +49,10 @@ from deluge.ui.client import client
|
||||||
import deluge.ui.client
|
import deluge.ui.client
|
||||||
import deluge.ui.common
|
import deluge.ui.common
|
||||||
from deluge.configmanager import ConfigManager
|
from deluge.configmanager import ConfigManager
|
||||||
from deluge.log import LOG as log
|
|
||||||
import dialogs
|
import dialogs
|
||||||
|
|
||||||
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
DEFAULT_HOST = "127.0.0.1"
|
DEFAULT_HOST = "127.0.0.1"
|
||||||
DEFAULT_PORT = 58846
|
DEFAULT_PORT = 58846
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,7 @@ import pkg_resources
|
||||||
import os.path
|
import os.path
|
||||||
import gobject
|
import gobject
|
||||||
import base64
|
import base64
|
||||||
|
import logging
|
||||||
|
|
||||||
from twisted.internet.threads import deferToThread
|
from twisted.internet.threads import deferToThread
|
||||||
|
|
||||||
|
@ -48,7 +49,8 @@ import listview
|
||||||
import deluge.component as component
|
import deluge.component as component
|
||||||
import deluge.common
|
import deluge.common
|
||||||
from deluge.configmanager import ConfigManager
|
from deluge.configmanager import ConfigManager
|
||||||
from deluge.log import LOG as log
|
|
||||||
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
class CreateTorrentDialog:
|
class CreateTorrentDialog:
|
||||||
def show(self):
|
def show(self):
|
||||||
|
|
|
@ -34,14 +34,16 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
||||||
import gtk, gtk.glade
|
import gtk
|
||||||
|
import gtk.glade
|
||||||
|
import logging
|
||||||
|
|
||||||
from deluge.ui.client import client
|
from deluge.ui.client import client
|
||||||
import deluge.component as component
|
import deluge.component as component
|
||||||
from deluge.common import fsize, is_url
|
from deluge.common import fsize, is_url
|
||||||
from deluge.ui.gtkui.torrentdetails import Tab
|
from deluge.ui.gtkui.torrentdetails import Tab
|
||||||
|
|
||||||
from deluge.log import LOG as log
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
class DetailsTab(Tab):
|
class DetailsTab(Tab):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|
|
@ -34,14 +34,17 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
||||||
import gtk, gtk.glade
|
import gtk
|
||||||
|
import gtk.glade
|
||||||
|
import logging
|
||||||
import pkg_resources
|
import pkg_resources
|
||||||
|
|
||||||
import deluge.common
|
import deluge.common
|
||||||
import common
|
import common
|
||||||
from deluge.ui.client import client
|
from deluge.ui.client import client
|
||||||
import deluge.component as component
|
import deluge.component as component
|
||||||
from deluge.log import LOG as log
|
|
||||||
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
class EditTrackersDialog:
|
class EditTrackersDialog:
|
||||||
def __init__(self, torrent_id, parent=None):
|
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 gobject
|
||||||
import gettext
|
import gettext
|
||||||
import os.path
|
import os.path
|
||||||
import cPickle
|
import cPickle
|
||||||
|
import logging
|
||||||
|
|
||||||
from deluge.ui.gtkui.torrentdetails import Tab
|
from deluge.ui.gtkui.torrentdetails import Tab
|
||||||
from deluge.ui.client import client
|
from deluge.ui.client import client
|
||||||
|
@ -48,7 +51,7 @@ import deluge.component as component
|
||||||
import deluge.common
|
import deluge.common
|
||||||
import common
|
import common
|
||||||
|
|
||||||
from deluge.log import LOG as log
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
def cell_priority(column, cell, model, row, data):
|
def cell_priority(column, cell, model, row, data):
|
||||||
if model.get_value(row, 5) == -1:
|
if model.get_value(row, 5) == -1:
|
||||||
|
|
|
@ -37,14 +37,16 @@
|
||||||
|
|
||||||
import gtk
|
import gtk
|
||||||
import gtk.glade
|
import gtk.glade
|
||||||
|
import logging
|
||||||
import pkg_resources
|
import pkg_resources
|
||||||
|
|
||||||
import deluge.component as component
|
import deluge.component as component
|
||||||
import deluge.common
|
import deluge.common
|
||||||
from deluge.log import LOG as log
|
|
||||||
from deluge.ui.client import client
|
from deluge.ui.client import client
|
||||||
from deluge.configmanager import ConfigManager
|
from deluge.configmanager import ConfigManager
|
||||||
|
|
||||||
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
STATE_PIX = {
|
STATE_PIX = {
|
||||||
"All": "all",
|
"All": "all",
|
||||||
"Downloading": "downloading",
|
"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
|
# Force the theme to use an expander-size of 15 so that we don't cut out
|
||||||
# entries due to our indentation hack.
|
# entries due to our indentation hack.
|
||||||
gtk.rc_parse_string('style "treeview-style" { GtkTreeView::expander-size = 15 } class "GtkTreeView" style "treeview-style"')
|
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.set_model(self.treestore)
|
||||||
self.label_view.get_selection().connect("changed", self.on_selection_changed)
|
self.label_view.get_selection().connect("changed", self.on_selection_changed)
|
||||||
self.create_model_filter()
|
self.create_model_filter()
|
||||||
|
|
|
@ -32,7 +32,6 @@
|
||||||
# statement from all source files in the program, then also delete it here.
|
# statement from all source files in the program, then also delete it here.
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
from deluge.log import LOG as log
|
|
||||||
|
|
||||||
# Install the twisted reactor
|
# Install the twisted reactor
|
||||||
from twisted.internet import gtk2reactor
|
from twisted.internet import gtk2reactor
|
||||||
|
@ -42,8 +41,12 @@ import gobject
|
||||||
import gettext
|
import gettext
|
||||||
import locale
|
import locale
|
||||||
import pkg_resources
|
import pkg_resources
|
||||||
import gtk, gtk.glade
|
import gtk
|
||||||
|
import gtk.glade
|
||||||
import sys
|
import sys
|
||||||
|
import logging
|
||||||
|
|
||||||
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
# Initialize gettext
|
# Initialize gettext
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -37,22 +37,24 @@
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import base64
|
import base64
|
||||||
|
import logging
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import rencode
|
import rencode
|
||||||
except ImportError:
|
except ImportError:
|
||||||
import deluge.rencode as rencode
|
import deluge.rencode as rencode
|
||||||
|
|
||||||
import deluge.component as component
|
import deluge.component as component
|
||||||
from deluge.ui.client import client
|
from deluge.ui.client import client
|
||||||
import deluge.common
|
import deluge.common
|
||||||
from deluge.configmanager import ConfigManager
|
from deluge.configmanager import ConfigManager
|
||||||
from deluge.log import LOG as log
|
|
||||||
|
|
||||||
from twisted.internet.protocol import Factory, Protocol, ClientFactory
|
from twisted.internet.protocol import Factory, Protocol, ClientFactory
|
||||||
from twisted.internet import reactor
|
from twisted.internet import reactor
|
||||||
import twisted.internet.error
|
import twisted.internet.error
|
||||||
|
|
||||||
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
class IPCProtocolServer(Protocol):
|
class IPCProtocolServer(Protocol):
|
||||||
def dataReceived(self, data):
|
def dataReceived(self, data):
|
||||||
data = rencode.loads(data)
|
data = rencode.loads(data)
|
||||||
|
@ -62,11 +64,11 @@ class IPCProtocolClient(Protocol):
|
||||||
def connectionMade(self):
|
def connectionMade(self):
|
||||||
self.transport.write(rencode.dumps(self.factory.args))
|
self.transport.write(rencode.dumps(self.factory.args))
|
||||||
self.transport.loseConnection()
|
self.transport.loseConnection()
|
||||||
|
|
||||||
def connectionLost(self, reason):
|
def connectionLost(self, reason):
|
||||||
reactor.stop()
|
reactor.stop()
|
||||||
self.factory.stop = True
|
self.factory.stop = True
|
||||||
|
|
||||||
class IPCClientFactory(ClientFactory):
|
class IPCClientFactory(ClientFactory):
|
||||||
protocol = IPCProtocolClient
|
protocol = IPCProtocolClient
|
||||||
|
|
||||||
|
@ -74,11 +76,11 @@ class IPCClientFactory(ClientFactory):
|
||||||
self.stop = False
|
self.stop = False
|
||||||
self.args = args
|
self.args = args
|
||||||
self.connect_failed = connect_failed
|
self.connect_failed = connect_failed
|
||||||
|
|
||||||
def clientConnectionFailed(self, connector, reason):
|
def clientConnectionFailed(self, connector, reason):
|
||||||
log.info("Connection to running instance failed. Starting new one..")
|
log.info("Connection to running instance failed. Starting new one..")
|
||||||
reactor.stop()
|
reactor.stop()
|
||||||
|
|
||||||
class IPCInterface(component.Component):
|
class IPCInterface(component.Component):
|
||||||
def __init__(self, args):
|
def __init__(self, args):
|
||||||
component.Component.__init__(self, "IPCInterface")
|
component.Component.__init__(self, "IPCInterface")
|
||||||
|
@ -165,7 +167,7 @@ class IPCInterface(component.Component):
|
||||||
os.remove(socket)
|
os.remove(socket)
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
log.error("Unable to remove socket file: %s", e)
|
log.error("Unable to remove socket file: %s", e)
|
||||||
|
|
||||||
lock = socket + ".lock"
|
lock = socket + ".lock"
|
||||||
if os.path.lexists(lock):
|
if os.path.lexists(lock):
|
||||||
try:
|
try:
|
||||||
|
@ -180,7 +182,7 @@ class IPCInterface(component.Component):
|
||||||
log.error("Unable to start IPC listening socket: %s", e)
|
log.error("Unable to start IPC listening socket: %s", e)
|
||||||
finally:
|
finally:
|
||||||
process_args(args)
|
process_args(args)
|
||||||
|
|
||||||
def shutdown(self):
|
def shutdown(self):
|
||||||
if deluge.common.windows_check():
|
if deluge.common.windows_check():
|
||||||
import win32api
|
import win32api
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
|
|
||||||
import cPickle
|
import cPickle
|
||||||
import os.path
|
import os.path
|
||||||
|
import logging
|
||||||
|
|
||||||
import pygtk
|
import pygtk
|
||||||
pygtk.require('2.0')
|
pygtk.require('2.0')
|
||||||
|
@ -46,13 +47,13 @@ import gettext
|
||||||
from deluge.configmanager import ConfigManager
|
from deluge.configmanager import ConfigManager
|
||||||
import deluge.configmanager
|
import deluge.configmanager
|
||||||
import deluge.common
|
import deluge.common
|
||||||
from deluge.log import LOG as log
|
|
||||||
|
|
||||||
from gobject import signal_new, SIGNAL_RUN_LAST, TYPE_NONE
|
from gobject import signal_new, SIGNAL_RUN_LAST, TYPE_NONE
|
||||||
from gtk import gdk
|
from gtk import gdk
|
||||||
signal_new('button-press-event', gtk.TreeViewColumn,
|
signal_new('button-press-event', gtk.TreeViewColumn,
|
||||||
SIGNAL_RUN_LAST, TYPE_NONE, (gdk.Event,))
|
SIGNAL_RUN_LAST, TYPE_NONE, (gdk.Event,))
|
||||||
|
|
||||||
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
# Cell data functions to pass to add_func_column()
|
# Cell data functions to pass to add_func_column()
|
||||||
def cell_data_speed(column, cell, model, row, data):
|
def cell_data_speed(column, cell, model, row, data):
|
||||||
|
|
|
@ -36,8 +36,10 @@
|
||||||
|
|
||||||
import pygtk
|
import pygtk
|
||||||
pygtk.require('2.0')
|
pygtk.require('2.0')
|
||||||
import gtk, gtk.glade
|
import gtk
|
||||||
|
import gtk.glade
|
||||||
import gobject
|
import gobject
|
||||||
|
import logging
|
||||||
import pkg_resources
|
import pkg_resources
|
||||||
from urlparse import urlparse
|
from urlparse import urlparse
|
||||||
import urllib
|
import urllib
|
||||||
|
@ -51,7 +53,7 @@ from twisted.internet import reactor
|
||||||
import deluge.common
|
import deluge.common
|
||||||
import common
|
import common
|
||||||
|
|
||||||
from deluge.log import LOG as log
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
class MainWindow(component.Component):
|
class MainWindow(component.Component):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|
|
@ -36,7 +36,9 @@
|
||||||
|
|
||||||
import pygtk
|
import pygtk
|
||||||
pygtk.require('2.0')
|
pygtk.require('2.0')
|
||||||
import gtk, gtk.glade
|
import gtk
|
||||||
|
import gtk.glade
|
||||||
|
import logging
|
||||||
import pkg_resources
|
import pkg_resources
|
||||||
|
|
||||||
import deluge.error
|
import deluge.error
|
||||||
|
@ -46,7 +48,7 @@ import deluge.common
|
||||||
import common
|
import common
|
||||||
from deluge.configmanager import ConfigManager
|
from deluge.configmanager import ConfigManager
|
||||||
|
|
||||||
from deluge.log import LOG as log
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
class MenuBar(component.Component):
|
class MenuBar(component.Component):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|
|
@ -34,13 +34,15 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
||||||
|
import logging
|
||||||
import deluge.component as component
|
import deluge.component as component
|
||||||
import deluge.common
|
import deluge.common
|
||||||
import common
|
import common
|
||||||
from deluge.log import LOG as log
|
|
||||||
from deluge.configmanager import ConfigManager
|
from deluge.configmanager import ConfigManager
|
||||||
from deluge.ui.client import client
|
from deluge.ui.client import client
|
||||||
|
|
||||||
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
class Notification:
|
class Notification:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.config = ConfigManager("gtkui.conf")
|
self.config = ConfigManager("gtkui.conf")
|
||||||
|
@ -53,7 +55,9 @@ class Notification:
|
||||||
self.get_torrent_status(torrent_id)
|
self.get_torrent_status(torrent_id)
|
||||||
|
|
||||||
def get_torrent_status(self, 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):
|
def _on_get_torrent_status(self, status):
|
||||||
if status is None:
|
if status is None:
|
||||||
|
@ -77,7 +81,10 @@ class Notification:
|
||||||
if not pynotify.init("Deluge"):
|
if not pynotify.init("Deluge"):
|
||||||
return
|
return
|
||||||
title = deluge.common.xml_encode(_("Torrent complete"))
|
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 = pynotify.Notification(title, message)
|
||||||
self.note.set_icon_from_pixbuf(common.get_logo(48))
|
self.note.set_icon_from_pixbuf(common.get_logo(48))
|
||||||
if not self.note.show():
|
if not self.note.show():
|
||||||
|
@ -106,9 +113,12 @@ class Notification:
|
||||||
headers = "From: %s\r\nTo: %s\r\nSubject: %s\r\n\r\n" % (
|
headers = "From: %s\r\nTo: %s\r\nSubject: %s\r\n\r\n" % (
|
||||||
self.config["ntf_email_add"], self.config["ntf_email_add"],
|
self.config["ntf_email_add"], self.config["ntf_email_add"],
|
||||||
"Finished torrent %s" % (status["name"]))
|
"Finished torrent %s" % (status["name"]))
|
||||||
text = _("This email is to inform you that Deluge has finished downloading %(name)s , \
|
text = _("This email is to inform you that Deluge has finished "
|
||||||
which includes %(num_files)i files.\nTo stop receiving these alerts, simply turn off \
|
"downloading %(name)s , which includes %(num_files)i files.\n"
|
||||||
email notification in Deluge's preferences.\n\nThank you,\nDeluge") % {"name": status["name"], "num_files": status["num_files"]}
|
"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
|
message = headers + text
|
||||||
if self.config["ntf_security"] == 'SSL':
|
if self.config["ntf_security"] == 'SSL':
|
||||||
port = 465
|
port = 465
|
||||||
|
|
|
@ -34,7 +34,9 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
||||||
import gtk, gtk.glade
|
import gtk
|
||||||
|
import gtk.glade
|
||||||
|
import logging
|
||||||
import os.path
|
import os.path
|
||||||
import cPickle
|
import cPickle
|
||||||
import pkg_resources
|
import pkg_resources
|
||||||
|
@ -48,9 +50,10 @@ import deluge.component as component
|
||||||
import deluge.common
|
import deluge.common
|
||||||
from deluge.ui.gtkui.listview import cell_data_speed as cell_data_speed
|
from deluge.ui.gtkui.listview import cell_data_speed as cell_data_speed
|
||||||
from deluge.ui.gtkui.torrentdetails import Tab
|
from deluge.ui.gtkui.torrentdetails import Tab
|
||||||
from deluge.log import LOG as log
|
|
||||||
from deluge.ui.countries import COUNTRIES
|
from deluge.ui.countries import COUNTRIES
|
||||||
|
|
||||||
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
def cell_data_progress(column, cell, model, row, data):
|
def cell_data_progress(column, cell, model, row, data):
|
||||||
value = model.get_value(row, data)
|
value = model.get_value(row, data)
|
||||||
cell.set_property("value", value * 100)
|
cell.set_property("value", value * 100)
|
||||||
|
|
|
@ -34,11 +34,13 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
||||||
|
import logging
|
||||||
import deluge.component as component
|
import deluge.component as component
|
||||||
import deluge.pluginmanagerbase
|
import deluge.pluginmanagerbase
|
||||||
from deluge.ui.client import client
|
from deluge.ui.client import client
|
||||||
from deluge.configmanager import ConfigManager
|
from deluge.configmanager import ConfigManager
|
||||||
from deluge.log import LOG as log
|
|
||||||
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
class PluginManager(deluge.pluginmanagerbase.PluginManagerBase,
|
class PluginManager(deluge.pluginmanagerbase.PluginManagerBase,
|
||||||
component.Component):
|
component.Component):
|
||||||
|
|
|
@ -36,11 +36,12 @@
|
||||||
|
|
||||||
import pygtk
|
import pygtk
|
||||||
pygtk.require('2.0')
|
pygtk.require('2.0')
|
||||||
import gtk, gtk.glade
|
import gtk
|
||||||
|
import gtk.glade
|
||||||
|
import logging
|
||||||
import pkg_resources
|
import pkg_resources
|
||||||
|
|
||||||
import deluge.component as component
|
import deluge.component as component
|
||||||
from deluge.log import LOG as log
|
|
||||||
from deluge.ui.client import client
|
from deluge.ui.client import client
|
||||||
import deluge.common
|
import deluge.common
|
||||||
import deluge.error
|
import deluge.error
|
||||||
|
@ -48,13 +49,15 @@ import common
|
||||||
from deluge.configmanager import ConfigManager
|
from deluge.configmanager import ConfigManager
|
||||||
import deluge.configmanager
|
import deluge.configmanager
|
||||||
|
|
||||||
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
class Preferences(component.Component):
|
class Preferences(component.Component):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
component.Component.__init__(self, "Preferences")
|
component.Component.__init__(self, "Preferences")
|
||||||
self.window = component.get("MainWindow")
|
self.window = component.get("MainWindow")
|
||||||
self.glade = gtk.glade.XML(
|
self.glade = gtk.glade.XML(pkg_resources.resource_filename(
|
||||||
pkg_resources.resource_filename("deluge.ui.gtkui",
|
"deluge.ui.gtkui", "glade/preferences_dialog.glade"
|
||||||
"glade/preferences_dialog.glade"))
|
))
|
||||||
self.pref_dialog = self.glade.get_widget("pref_dialog")
|
self.pref_dialog = self.glade.get_widget("pref_dialog")
|
||||||
self.pref_dialog.set_icon(common.get_deluge_icon())
|
self.pref_dialog.set_icon(common.get_deluge_icon())
|
||||||
self.treeview = self.glade.get_widget("treeview")
|
self.treeview = self.glade.get_widget("treeview")
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue