<commit_before>import logging
import time
import os
import base64
import urllib2
from flexget.plugin import *
from httplib import BadStatusLine

log = logging.getLogger('deluge')
        

class OutputDeluge:

    """
        Add the torrents directly to deluge, supporting custom save paths.
    """

    def validator(self):
        from flexget import validator
        root = validator.factory()
        root.accept('boolean')
        deluge = root.accept('dict')
        deluge.accept('text', key='host')
        deluge.accept('number', key='port')
        deluge.accept('text', key='user')
        deluge.accept('text', key='pass')
        deluge.accept('text', key='path')
        deluge.accept('text', key='movedone')
        deluge.accept('text', key='label')
        deluge.accept('boolean', key='queuetotop')
        deluge.accept('boolean', key='automanaged')
        deluge.accept('decimal', key='maxupspeed')
        deluge.accept('decimal', key='maxdownspeed')
        deluge.accept('number', key='maxconnections')
        deluge.accept('number', key='maxupslots')
        deluge.accept('decimal', key='ratio')
        deluge.accept('boolean', key='removeatratio')
        deluge.accept('boolean', key='addpaused')
        deluge.accept('boolean', key='compact')
        deluge.accept('boolean', key='enabled')
        return root

    def get_config(self, feed):
        config = feed.config.get('deluge', {})
        if isinstance(config, bool):
            config = {'enabled': config}
        config.setdefault('host', 'localhost')
        config.setdefault('port', 58846)
        config.setdefault('user', '')
        config.setdefault('pass', '')
        config.setdefault('enabled', True)
        config.setdefault('path', '')
        config.setdefault('movedone', '')
        config.setdefault('label', '')
        config.setdefault('queuetotop', None)
        for key in self.options.iterkeys():
            config.setdefault(key, None)
        return config

    def __init__(self):
        self.deluge12 = False
        self.reactorRunning = 0
        self.options = {'maxupspeed': 'max_upload_speed', 'maxdownspeed': 'max_download_speed', \
            'maxconnections': 'max_connections', 'maxupslots': 'max_upload_slots', \
            'automanaged': 'auto_managed', 'ratio': 'stop_ratio', 'removeatratio': 'remove_at_ratio', \
            'addpaused': 'add_paused', 'compact': 'compact_allocation'}

    def on_process_start(self, feed):
        """
            Register the usable set: keywords. Detect what version of deluge
            is loaded, start the reactor process if using the deluge 1.2 api.
        """
        set_plugin = get_plugin_by_name('set')
        set_plugin.instance.register_keys({'path': 'text', 'movedone': 'text', \
            'queuetotop': 'boolean', 'label': 'text', 'automanaged': 'boolean', \
            'maxupspeed': 'decimal', 'maxdownspeed': 'decimal', 'maxupslots': 'number', \
            'maxconnections': 'number', 'ratio': 'decimal', 'removeatratio': 'boolean', \
            'addpaused': 'boolean', 'compact': 'boolean'})
        if not self.deluge12:
            try:
                log.debug("Testing for deluge 1.1 API")
                from deluge.ui.client import sclient
                log.debug("1.1 API found")
            except:
                log.debug("Testing for deluge 1.2 API")
                try:
                    from multiprocessing import Process, Queue
                except:
                    raise PluginError('Python 2.6 required to use deluge 1.2 api', log)
                try:
                    from deluge.ui.client import client
                except:
                    raise PluginError('Deluge module required.', log)
                try:
                    from twisted.internet import reactor
                except:
                    raise PluginError('Twisted module required', log)
                log.info("Using deluge 1.2 api")
                self.deluge12 = True
            else:
                log.info("Using deluge 1.1 api foofoo")
                self.deluge12 = False
                
    def on_feed_download(self, feed):
        """
            call the feed_download method of download plugin
            this will generate the temp files we will load into deluge
            we don't need to call this if download plugin is loaded on this feed
        """
        config = self.get_config(feed)
        if not config['enabled']:
            return<commit_msg>Remove silly log message leftover from testing<commit_after>import logging
import time
import os
import base64
import urllib2
from flexget.plugin import *
from httplib import BadStatusLine

log = logging.getLogger('deluge')
        

class OutputDeluge:

    """
        Add the torrents directly to deluge, supporting custom save paths.
    """

    def validator(self):
        from flexget import validator
        root = validator.factory()
        root.accept('boolean')
        deluge = root.accept('dict')
        deluge.accept('text', key='host')
        deluge.accept('number', key='port')
        deluge.accept('text', key='user')
        deluge.accept('text', key='pass')
        deluge.accept('text', key='path')
        deluge.accept('text', key='movedone')
        deluge.accept('text', key='label')
        deluge.accept('boolean', key='queuetotop')
        deluge.accept('boolean', key='automanaged')
        deluge.accept('decimal', key='maxupspeed')
        deluge.accept('decimal', key='maxdownspeed')
        deluge.accept('number', key='maxconnections')
        deluge.accept('number', key='maxupslots')
        deluge.accept('decimal', key='ratio')
        deluge.accept('boolean', key='removeatratio')
        deluge.accept('boolean', key='addpaused')
        deluge.accept('boolean', key='compact')
        deluge.accept('boolean', key='enabled')
        return root

    def get_config(self, feed):
        config = feed.config.get('deluge', {})
        if isinstance(config, bool):
            config = {'enabled': config}
        config.setdefault('host', 'localhost')
        config.setdefault('port', 58846)
        config.setdefault('user', '')
        config.setdefault('pass', '')
        config.setdefault('enabled', True)
        config.setdefault('path', '')
        config.setdefault('movedone', '')
        config.setdefault('label', '')
        config.setdefault('queuetotop', None)
        for key in self.options.iterkeys():
            config.setdefault(key, None)
        return config

    def __init__(self):
        self.deluge12 = False
        self.reactorRunning = 0
        self.options = {'maxupspeed': 'max_upload_speed', 'maxdownspeed': 'max_download_speed', \
            'maxconnections': 'max_connections', 'maxupslots': 'max_upload_slots', \
            'automanaged': 'auto_managed', 'ratio': 'stop_ratio', 'removeatratio': 'remove_at_ratio', \
            'addpaused': 'add_paused', 'compact': 'compact_allocation'}

    def on_process_start(self, feed):
        """
            Register the usable set: keywords. Detect what version of deluge
            is loaded, start the reactor process if using the deluge 1.2 api.
        """
        set_plugin = get_plugin_by_name('set')
        set_plugin.instance.register_keys({'path': 'text', 'movedone': 'text', \
            'queuetotop': 'boolean', 'label': 'text', 'automanaged': 'boolean', \
            'maxupspeed': 'decimal', 'maxdownspeed': 'decimal', 'maxupslots': 'number', \
            'maxconnections': 'number', 'ratio': 'decimal', 'removeatratio': 'boolean', \
            'addpaused': 'boolean', 'compact': 'boolean'})
        if not self.deluge12:
            try:
                log.debug("Testing for deluge 1.1 API")
                from deluge.ui.client import sclient
                log.debug("1.1 API found")
            except:
                log.debug("Testing for deluge 1.2 API")
                try:
                    from multiprocessing import Process, Queue
                except:
                    raise PluginError('Python 2.6 required to use deluge 1.2 api', log)
                try:
                    from deluge.ui.client import client
                except:
                    raise PluginError('Deluge module required.', log)
                try:
                    from twisted.internet import reactor
                except:
                    raise PluginError('Twisted module required', log)
                log.info("Using deluge 1.2 api")
                self.deluge12 = True
            else:
                log.info("Using deluge 1.1 api")
                self.deluge12 = False
                
    def on_feed_download(self, feed):
        """
            call the feed_download method of download plugin
            this will generate the temp files we will load into deluge
            we don't need to call this if download plugin is loaded on this feed
        """
        config = self.get_config(feed)
        if not config['enabled']:
            return
{'fraction_non_alphanumeric': 0.12444641275465013, 'fraction_numerical': 0.007307351638618246, 'mean_word_length': 2.16281512605042, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4869982', 'n_tokens_mistral': 2556, 'n_tokens_neox': 2432, 'n_words': 616}