Ejemplo n.º 1
0
 def setup_logger(self):
     """
     Set up all the logging paramters for SpiderBro
     """
     start_day = str(datetime.today()).split(" ")[0]
     setupLogger()
     self.logger = logging.getLogger("spiderbro")
     if (self.config.debug_logging == True):
         self.logger.setLevel(logging.DEBUG)
     else:
         self.logger.setLevel(logging.INFO)
     formatter = logging.Formatter(
         '[%(asctime)s] [%(levelname)s] %(message)s')
     handler_stream = logging.StreamHandler()
     handler_stream.setFormatter(formatter)
     handler_stream.setLevel(logging.CRITICAL)
     self.logger.addHandler(handler_stream)
     handler_file = logging.FileHandler('%s/spiderBro_%s.log' %
                                        (self.config.log_dir, start_day))
     handler_file.setFormatter(formatter)
     self.logger.addHandler(handler_file)
     self.logger.info("")
     self.logger.info("SpiderBro, SpiderBro")
     self.logger.info("Finding episodes for your shows")
     self.log_debug_info()
     return self.logger
Ejemplo n.º 2
0
def start_ui():
    """Entry point for ui script"""
    import deluge.common
    deluge.common.setup_translations()

    # Setup the argument parser
    parser = OptionParser(usage="%prog [options] [actions]")
    parser.add_option("-v", "--version", action="callback", callback=version_callback,
        help="Show program's version number and exit")
    parser.add_option("-u", "--ui", dest="ui",
        help="""The UI that you wish to launch.  The UI choices are:\n
        \t gtk -- A GTK-based graphical user interface (default)\n
        \t web -- A web-based interface (http://localhost:8112)\n
        \t console -- A console or command-line interface""", action="store", type="str")
    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")
    parser.add_option("-a", "--args", dest="args",
        help="Arguments to pass to UI, -a '--option args'", action="store", type="str")
    parser.add_option("-c", "--config", dest="config",
        help="Set the config folder location", action="store", type="str")
    parser.add_option("-l", "--logfile", dest="logfile",
        help="Output to designated logfile instead of stdout", action="store", type="str")
    parser.add_option("-L", "--loglevel", dest="loglevel",
        help="Set the log level: none, info, warning, error, critical, debug", action="store", type="str")
    parser.add_option("-q", "--quiet", dest="quiet",
        help="Sets the log level to 'none', this is the same as `-L none`", action="store_true", default=False)
    parser.add_option("-r", "--rotate-logs",
        help="Rotate logfiles.", action="store_true", default=False)

    # Get the options and args from the OptionParser
    (options, args) = parser.parse_args(deluge.common.unicode_argv()[1:])

    # Setup the logger
    if options.quiet:
        options.loglevel = "none"
    if options.loglevel:
        options.loglevel = options.loglevel.lower()
    logfile_mode = 'w'
    if options.rotate_logs:
        logfile_mode = 'a'
    setupLogger(level=options.loglevel, filename=options.logfile, filemode=logfile_mode)
    log = getLogger(__name__)

    if options.config:
        if not os.path.exists(options.config):
            # Try to create the config folder if it doesn't exist
            try:
                os.makedirs(options.config)
            except Exception, e:
                pass
        elif not os.path.isdir(options.config):
            log.error("Config option needs to be a directory!")
            sys.exit(1)
Ejemplo n.º 3
0
 def setup_logger(self):
     """
     Set up all the logging paramters for SpiderBro
     """
     start_day = str(datetime.today()).split(" ")[0]
     setupLogger()
     self.logger = logging.getLogger("spiderbro")
     if (self.config.debug_logging == True):
         self.logger.setLevel(logging.DEBUG)
     else:
         self.logger.setLevel(logging.INFO)
     formatter = logging.Formatter('[%(asctime)s] [%(levelname)s] %(message)s')
     handler_stream = logging.StreamHandler()
     handler_stream.setFormatter(formatter)
     handler_stream.setLevel(logging.CRITICAL)
     self.logger.addHandler(handler_stream)
     handler_file = logging.FileHandler('%s/spiderBro_%s.log' % (self.config.log_dir, start_day))
     handler_file.setFormatter(formatter)
     self.logger.addHandler(handler_file)
     self.logger.info("")
     self.logger.info("SpiderBro, SpiderBro")
     self.logger.info("Finding episodes for your shows")
     self.log_debug_info()
     return self.logger
Ejemplo n.º 4
0
from Downloader import Downloader
from yaml import load
from deluge.ui.client import client
from twisted.internet.defer import inlineCallbacks, returnValue
from utils.exceptions import SchedulerError
# Set up the logger to print out errors
from deluge.log import setupLogger, LOG
setupLogger(level='info')


class DelugeDownloader(Downloader):
    def __init__(self, on_download_completed_callback):

        fr = open('./config/config.yml', 'r')
        config = load(fr)
        self.delugeConfig = config['deluge']

        self.__on_download_completed_callback = on_download_completed_callback

    def __on_connect_success(self, result):
        """
        : add event handlers
        """
        LOG.info('Connection was successful')
        client.register_event_handler('TorrentFinishedEvent',
                                      self.__on_download_completed)
        return result

    def __on_connect_fail(self, result):
        """
        :throw a exception
Ejemplo n.º 5
0
#

import gtk
import re
import os

from deluge.log import LOG as log
from deluge.log import setupLogger
from deluge.ui.client import client
from deluge.plugins.pluginbase import GtkPluginBase
import deluge.component as component
import deluge.common
from deluge.core.torrent import Torrent

from common import get_resource
setupLogger()


class RenameFiles():
    """Class to wrap up the GUI and all filename processing functions"""

    def __init__(self, tor_id, files):
        self.tor_id = tor_id
        self.files = files

    def run(self):
        """Build the GUI and display it."""
        self.glade = gtk.glade.XML(get_resource("rename.glade"))
        self.window = self.glade.get_widget("RenameDialog")
        self.window.set_transient_for(component.get("MainWindow").window)
        self.find_field = self.glade.get_widget("find_field")
Ejemplo n.º 6
0
 def setUp(self):
     setupLogger("warning", "log_file")
     self.website = Site(TopLevelResource())
     self.webserver = reactor.listenTCP(51242, self.website)
Ejemplo n.º 7
0
#!/usr/bin/python

import sys
from deluge.ui.client import client
from twisted.internet import reactor

# Set up the logger to print out errors
from deluge.log import setupLogger
setupLogger()

d = client.connect()

torrent_id = sys.argv[1]

def on_connect_success(result):
    def on_get_torrent_status(torrent):
        print torrent["label"]
        client.disconnect()
        reactor.stop()

    client.core.get_torrent_status(torrent_id, ["label"]).addCallback(on_get_torrent_status)

d.addCallback(on_connect_success)

def on_connect_fail(result):
        print result
        reactor.stop() 

d.addErrback(on_connect_fail)

reactor.run()
Ejemplo n.º 8
0
 def setUp(self):
     setupLogger("warning", "log_file")
     self.website = Site(TopLevelResource())
     self.webserver = reactor.listenTCP(51242, self.website)
Ejemplo n.º 9
0
 def setUp(self):
     setupLogger(logging.DEBUG)
Ejemplo n.º 10
0
from Downloader import Downloader
from yaml import load
from deluge.ui.client import client
from twisted.internet.defer import inlineCallbacks, returnValue
# Set up the logger to print out errors
from deluge.log import setupLogger, LOG
setupLogger(level='info')


class DelugeDownloader(Downloader):

    def __init__(self, on_download_completed_callback):

        fr = open('./config/config.yml', 'r')
        config = load(fr)
        self.delugeConfig = config['deluge']

        self.__on_download_completed_callback = on_download_completed_callback

    def __on_connect_success(self, result):
        '''
        : add event handlers
        '''
        LOG.info('Connection was successful')
        client.register_event_handler('TorrentFinishedEvent', self.__on_download_completed)
        return result

    def __on_connect_fail(self, result):
        '''
        :throw a exception
        '''
Ejemplo n.º 11
0
 def setUp(self):
     setupLogger(logging.DEBUG)
Ejemplo n.º 12
0
    # Setup the logger
    if options.quiet:
        options.loglevel = "none"
    if options.logfile:
        # Try to create the logfile's directory if it doesn't exist
        try:
            os.makedirs(os.path.abspath(os.path.dirname(options.logfile)))
        except OSError, e:
            if e.errno != EEXIST:
                print "There was an error creating the log directory, exiting... (%s)" % e
                sys.exit(1)
    logfile_mode = 'w'
    if options.rotate_logs:
        logfile_mode = 'a'
    setupLogger(level=options.loglevel, filename=options.logfile, filemode=logfile_mode)
    log = getLogger(__name__)

    import deluge.configmanager
    if options.config:
        if not deluge.configmanager.set_config_dir(options.config):
            log.error("There was an error setting the config directory! Exiting...")
            sys.exit(1)

    # Sets the options.logfile to point to the default location
    def open_logfile():
        if not options.logfile:
            options.logfile = deluge.configmanager.get_config_dir("deluged.log")
            file_handler = FileHandler(options.logfile)
            log.addHandler(file_handler)
Ejemplo n.º 13
0
from twisted.trial import unittest

from deluge.ui.tracker_icons import TrackerIcons, TrackerIcon
from deluge.log import setupLogger

# Must come before import common
setupLogger("debug", "debug.log")

import common

common.set_tmp_config_dir()
icons = TrackerIcons()

class TrackerIconsTestCase(unittest.TestCase):
    def test_get_deluge_png(self):
        # Deluge has a png favicon link
        icon = TrackerIcon("../deluge.png")
        d = icons.get("deluge-torrent.org")
        d.addCallback(self.assertNotIdentical, None)
        d.addCallback(self.assertEquals, icon)
        return d

    def test_get_google_ico(self):
        # Google doesn't have any icon links
        # So instead we'll grab its favicon.ico
        icon = TrackerIcon("../google.ico")
        d = icons.get("www.google.com")
        d.addCallback(self.assertNotIdentical, None)
        d.addCallback(self.assertEquals, icon)
        return d
Ejemplo n.º 14
0
 def setUp(self):
     setupLogger("warning", "log_file")