Example #1
0
 def test_load(self):
     plugin.load_plugins()
     plugin_path = os.path.dirname(plugins.__file__)
     plugin_modules = set(
         os.path.basename(i) for k in ("/*.py", "/*/*.py") for i in glob.glob(plugin_path + k)
     )
     assert len(plugin_modules) >= 10, "Less than 10 plugin modules looks fishy"
Example #2
0
def main(args=None):
    """Main entry point for Command Line Interface"""

    logger.initialize()

    plugin.load_plugins()

    options = get_parser().parse_args(args)

    manager = Manager(options)

    log_level = logging.getLevelName(options.loglevel.upper())
    log_file = os.path.expanduser(manager.options.logfile)
    # If an absolute path is not specified, use the config directory.
    if not os.path.isabs(log_file):
        log_file = os.path.join(manager.config_base, log_file)
    logger.start(log_file, log_level)
    if options.profile:
        try:
            import cProfile as profile
        except ImportError:
            import profile
        profile.runctx('manager.start()', globals(), locals(),
                       os.path.join(manager.config_base, options.profile))
    else:
        manager.start()
Example #3
0
def setup_once(pytestconfig, request):
    #    os.chdir(os.path.join(pytestconfig.rootdir.strpath, 'flexget', 'tests'))
    flexget.logger.initialize(True)
    m = MockManager('tasks: {}', 'init')  # This makes sure our template environment is set up before any tests are run
    m.shutdown()
    logging.getLogger().setLevel(logging.DEBUG)
    load_plugins()
Example #4
0
 def config(self, request):
     os.environ['FLEXGET_PLUGIN_PATH'] = request.fspath.dirpath().join('external_plugins').strpath
     plugin.load_plugins()
     # fire the config register event again so that task schema is rebuilt with new plugin
     fire_event('config.register')
     yield self._config
     del os.environ['FLEXGET_PLUGIN_PATH']
Example #5
0
def main(args=None):
    """Main entry point for Command Line Interface"""

    logger.initialize()

    plugin.load_plugins()

    options = get_parser().parse_args(args)

    manager = Manager(options)

    log_level = logging.getLevelName(options.loglevel.upper())
    log_file = os.path.expanduser(manager.options.logfile)
    # If an absolute path is not specified, use the config directory.
    if not os.path.isabs(log_file):
        log_file = os.path.join(manager.config_base, log_file)
    logger.start(log_file, log_level)
    if options.profile:
        try:
            import cProfile as profile
        except ImportError:
            import profile
        profile.runctx('manager.start()', globals(), locals(),
                       os.path.join(manager.config_base, options.profile))
    else:
        manager.start()
Example #6
0
 def test_load(self):
     plugin.load_plugins()
     plugin_path = os.path.dirname(plugins.__file__)
     plugin_modules = set(
         os.path.basename(i) for k in ("/*.py", "/*/*.py") for i in glob.glob(plugin_path + k)
     )
     assert len(plugin_modules) >= 10, "Less than 10 plugin modules looks fishy"
Example #7
0
def main():
    """Main entry point for Command Line Interface"""

    logger.initialize()

    parser = CoreArgumentParser()
    plugin.load_plugins(parser)

    options = parser.parse_args()

    try:
        manager = Manager(options)
    except IOError as e:
        # failed to load config, TODO: why should it be handled here? So sys.exit isn't called in webui?
        log.critical(e)
        logger.flush_logging_to_console()
        sys.exit(1)

    log_level = logging.getLevelName(options.loglevel.upper())
    log_file = os.path.expanduser(manager.options.logfile)
    # If an absolute path is not specified, use the config directory.
    if not os.path.isabs(log_file):
        log_file = os.path.join(manager.config_base, log_file)
    logger.start(log_file, log_level)

    if options.profile:
        try:
            import cProfile as profile
        except ImportError:
            import profile
        profile.runctx('manager.execute()', globals(), locals(), os.path.join(manager.config_base, 'flexget.profile'))
    else:
        manager.execute()
    manager.shutdown()
Example #8
0
 def config(self, request):
     os.environ['FLEXGET_PLUGIN_PATH'] = request.fspath.dirpath().join('external_plugins').strpath
     plugin.load_plugins()
     # fire the config register event again so that task schema is rebuilt with new plugin
     fire_event('config.register')
     yield self._config
     del os.environ['FLEXGET_PLUGIN_PATH']
Example #9
0
def setup_once(pytestconfig, request):
    #    os.chdir(os.path.join(pytestconfig.rootdir.strpath, 'flexget', 'tests'))
    flexget.logger.initialize(True)
    m = MockManager('tasks: {}', 'init')  # This makes sure our template environment is set up before any tests are run
    m.shutdown()
    logging.getLogger().setLevel(logging.DEBUG)
    load_plugins()
Example #10
0
def setup_once():
    global plugins_loaded, test_arguments
    if not plugins_loaded:
        flexget.logger.initialize(True)
        setup_logging_level()
        load_plugins()
        # store options for MockManager
        test_arguments = get_parser().parse_args(['execute'])
        plugins_loaded = True
Example #11
0
def setup_once():
    global plugins_loaded, test_arguments
    if not plugins_loaded:
        flexget.logger.initialize(True)
        setup_logging_level()
        load_plugins(exec_parser)
        # store options for MockManager
        test_arguments = core_parser.parse_args(['--del-db', 'exec'])
        plugins_loaded = True
Example #12
0
def setup_once():
    global plugins_loaded, test_arguments
    if not plugins_loaded:
        flexget.logger.initialize(True)
        setup_logging_level()
        load_plugins()
        # store options for MockManager
        test_arguments = get_parser().parse_args(['execute'])
        plugins_loaded = True
Example #13
0
def setup_once():
    global plugins_loaded, test_arguments
    if not plugins_loaded:
        flexget.logger.initialize(True)
        setup_logging_level()
        warnings.simplefilter('error', DeprecationWarning)
        load_plugins()
        # store options for MockManager
        test_arguments = get_parser().parse_args(['execute'])
        plugins_loaded = True
Example #14
0
def setup_once():
    global plugins_loaded, test_options
    if not plugins_loaded:
        flexget.logger.initialize(True)
        setup_logging_level()
        parser = CoreOptionParser(True)
        load_plugins(parser)
        # store options for MockManager
        test_options = parser.parse_args()[0]
        plugins_loaded = True
Example #15
0
    def test_load(self):
        from flexget.options import CoreArgumentParser

        plugin.load_plugins(CoreArgumentParser())
        plugin_path = os.path.dirname(plugins.__file__)
        plugin_modules = set(os.path.basename(i)
            for k in ("/*.py", "/*/*.py")
            for i in glob.glob(plugin_path + k))
        assert len(plugin_modules) >= 10, "Less than 10 plugin modules looks fishy"
        assert len(plugin.plugins) >= len(plugin_modules) - 1, "Less plugins than plugin modules"
Example #16
0
def setup_once():
    global plugins_loaded, test_arguments
    if not plugins_loaded:
        flexget.logger.initialize(True)
        setup_logging_level()
        parser = CoreArgumentParser(True)
        load_plugins(parser)
        # store options for MockManager
        test_arguments = parser.parse_args()
        plugins_loaded = True
Example #17
0
    def test_load(self):
        from flexget.options import CoreArgumentParser

        plugin.load_plugins(CoreArgumentParser())
        plugin_path = os.path.dirname(plugins.__file__)
        plugin_modules = set(
            os.path.basename(i) for k in ("/*.py", "/*/*.py")
            for i in glob.glob(plugin_path + k))
        assert len(
            plugin_modules) >= 10, "Less than 10 plugin modules looks fishy"
        assert len(
            plugin.plugins
        ) >= len(plugin_modules) - 1, "Less plugins than plugin modules"
Example #18
0
def setup_once():
    global plugins_loaded, test_arguments
    if not plugins_loaded:
        flexget.logger.initialize(True)
        setup_logging_level()
        # VCR.py mocked functions not handle ssl verification well. Older versions of urllib3 don't have this
        if VCR_RECORD_MODE != 'off':
            try:
                from requests.packages.urllib3.exceptions import SecurityWarning
                warnings.simplefilter('ignore', SecurityWarning)
            except ImportError:
                pass
        load_plugins()
        plugins_loaded = True
Example #19
0
def setup_once():
    global plugins_loaded, test_arguments
    if not plugins_loaded:
        flexget.logger.initialize(True)
        setup_logging_level()
        # VCR.py mocked functions not handle ssl verification well. Older versions of urllib3 don't have this
        if VCR_RECORD_MODE != 'off':
            try:
                from requests.packages.urllib3.exceptions import SecurityWarning
                warnings.simplefilter('ignore', SecurityWarning)
            except ImportError:
                pass
        load_plugins()
        plugins_loaded = True
Example #20
0
def main():
    """Main entry point for Command Line Interface"""

    logger.initialize()

    parser = CoreArgumentParser()
    plugin.load_plugins(parser)

    options = parser.parse_args()

    try:
        manager = Manager(options)
    except IOError, e:
        # failed to load config, TODO: why should it be handled here? So sys.exit isn't called in webui?
        log.critical(e)
        logger.flush_logging_to_console()
        sys.exit(1)
Example #21
0
def main():
    """Main entry point for Command Line Interface"""

    logger.initialize()

    parser = CoreOptionParser()
    plugin.load_plugins(parser)

    options = parser.parse_args()[0]

    try:
        manager = Manager(options)
    except IOError, e:
        # failed to load config, TODO: why should it be handled here?
        log.exception(e)
        logger.flush_logging_to_console()
        sys.exit(1)
Example #22
0
def main(args=None):
    """Main entry point for Command Line Interface"""

    logger.initialize()

    plugin.load_plugins()

    options = get_parser().parse_args(args)

    manager = Manager(options)

    log_level = logging.getLevelName(options.loglevel.upper())
    log_file = os.path.expanduser(manager.options.logfile)
    # If an absolute path is not specified, use the config directory.
    if not os.path.isabs(log_file):
        log_file = os.path.join(manager.config_base, log_file)
    logger.start(log_file, log_level)
    manager.run_cli_command()
Example #23
0
def main():
    """Main entry point for FlexGet UI"""

    logger.initialize()

    # The core plugins need a core parser to add their options to
    core_parser = CoreArgumentParser()
    plugin.load_plugins(core_parser)

    # Use the ui options parser to parse the cli
    parser = UIArgumentParser(core_parser)
    options = parser.parse_args()
    try:
        manager = UIManager(options, core_parser)
    except IOError, e:
        # failed to load config
        log.critical(e.message)
        logger.flush_logging_to_console()
        sys.exit(1)
Example #24
0
    def initialize(self):
        """
        Load plugins, database, and config. Also initializes (but does not start) the task queue and ipc server.
        This should only be called after obtaining a lock.
        """
        if self.initialized:
            raise RuntimeError(
                'Cannot call initialize on an already initialized manager.')

        plugin.load_plugins(
            extra_plugins=[os.path.join(self.config_base, 'plugins')],
            extra_components=[os.path.join(self.config_base, 'components')],
        )

        # Reparse CLI options now that plugins are loaded
        if not self.args:
            self.args = ['--help']
        self.options = get_parser().parse_args(self.args)

        self.task_queue = TaskQueue()
        self.ipc_server = IPCServer(self, self.options.ipc_port)

        self.setup_yaml()
        self.init_sqlalchemy()
        fire_event('manager.initialize', self)
        try:
            self.load_config()
        except ValueError as e:
            log.critical('Failed to load config file: %s' % e.args[0])
            raise

        # cannot be imported at module level because of circular references
        from flexget.utils.simple_persistence import SimplePersistence

        self.persist = SimplePersistence('manager')

        if db_schema.upgrade_required():
            log.info('Database upgrade is required. Attempting now.')
            fire_event('manager.upgrade', self)
            if manager.db_upgraded:
                fire_event('manager.db_upgraded', self)
        fire_event('manager.startup', self)
        self.initialized = True
Example #25
0
    def initialize(self):
        """
        Load plugins, database, and config. Also initializes (but does not start) the task queue and ipc server.
        This should only be called after obtaining a lock.
        """
        if self.initialized:
            raise RuntimeError('Cannot call initialize on an already initialized manager.')

        plugin.load_plugins(
            extra_plugins=[os.path.join(self.config_base, 'plugins')],
            extra_components=[os.path.join(self.config_base, 'components')],
        )

        # Reparse CLI options now that plugins are loaded
        if not self.args:
            self.args = ['--help']
        self.options = get_parser().parse_args(self.args)

        self.task_queue = TaskQueue()
        self.ipc_server = IPCServer(self, self.options.ipc_port)

        self.setup_yaml()
        self.init_sqlalchemy()
        fire_event('manager.initialize', self)
        try:
            self.load_config()
        except ValueError as e:
            log.critical('Failed to load config file: %s' % e.args[0])
            raise

        # cannot be imported at module level because of circular references
        from flexget.utils.simple_persistence import SimplePersistence

        self.persist = SimplePersistence('manager')

        if db_schema.upgrade_required():
            log.info('Database upgrade is required. Attempting now.')
            fire_event('manager.upgrade', self)
            if manager.db_upgraded:
                fire_event('manager.db_upgraded', self)
        fire_event('manager.startup', self)
        self.initialized = True
Example #26
0
def main(args=None):
    """Main entry point for Command Line Interface"""

    logger.initialize()

    plugin.load_plugins()

    options = get_parser().parse_args(args)

    manager = Manager(options)

    if options.profile:
        try:
            import cProfile as profile
        except ImportError:
            import profile
        profile.runctx('manager.start()', globals(), locals(),
                       os.path.join(manager.config_base, options.profile))
    else:
        manager.start()
Example #27
0
    def test_register_by_class(self, execute_task):
        class TestPlugin(object):
            pass

        class Oneword(object):
            pass

        class TestHTML(object):
            pass

        assert 'test_plugin' not in plugin.plugins

        @event('plugin.register')
        def rp():
            plugin.register(TestPlugin, api_ver=2)
            plugin.register(Oneword, api_ver=2)
            plugin.register(TestHTML, api_ver=2)

        # Call load_plugins again to register our new plugins
        plugin.load_plugins()
        assert 'test_plugin' in plugin.plugins
        assert 'oneword' in plugin.plugins
        assert 'test_html' in plugin.plugins
Example #28
0
    def test_register_by_class(self, execute_task):
        class TestPlugin(object):
            pass

        class Oneword(object):
            pass

        class TestHTML(object):
            pass

        assert 'test_plugin' not in plugin.plugins

        @event('plugin.register')
        def rp():
            plugin.register(TestPlugin, api_ver=2)
            plugin.register(Oneword, api_ver=2)
            plugin.register(TestHTML, api_ver=2)

        # Call load_plugins again to register our new plugins
        plugin.load_plugins()
        assert 'test_plugin' in plugin.plugins
        assert 'oneword' in plugin.plugins
        assert 'test_html' in plugin.plugins
Example #29
0
def main(args=None):
    """Main entry point for Command Line Interface"""

    logger.initialize()

    plugin.load_plugins()

    options = get_parser().parse_args(args)

    try:
        manager = Manager(options)
    except (IOError, ValueError) as e:
        print('Could not initialize manager: %s' % e, file=sys.stderr)
        sys.exit(1)

    if options.profile:
        try:
            import cProfile as profile
        except ImportError:
            import profile
        profile.runctx('manager.start()', globals(), locals(),
                       os.path.join(manager.config_base, options.profile))
    else:
        manager.start()
Example #30
0
def main():
    """Main entry point for FlexGet UI"""

    logger.initialize()

    # The core plugins need a core parser to add their options to
    core_parser = CoreArgumentParser()
    plugin.load_plugins(core_parser)

    # Use the ui options parser to parse the cli
    parser = UIArgumentParser(core_parser)
    options = parser.parse_args()
    try:
        manager = UIManager(options, core_parser)
    except IOError as e:
        # failed to load config
        log.critical(e.message)
        logger.flush_logging_to_console()
        sys.exit(1)

    log_level = logging.getLevelName(options.loglevel.upper())
    logger.start(os.path.join(manager.config_base, 'flexget.log'), log_level)

    flexget.ui.webui.start(manager)
Example #31
0
 def setup(self):
     os.environ['FLEXGET_PLUGIN_PATH'] = os.path.join(
         self.base_path, 'external_plugins')
     plugin.load_plugins()
     super(TestExternalPluginLoading, self).setup()
Example #32
0
 def setup(self):
     os.environ['FLEXGET_PLUGIN_PATH'] = os.path.join(self.base_path, 'external_plugins')
     plugin.load_plugins(CoreArgumentParser())
     super(TestExternalPluginLoading, self).setup()
Example #33
0
    def test_no_dupes(self):
        from flexget.options import CoreArgumentParser
        plugin.load_plugins(CoreArgumentParser())

        assert plugin.PluginInfo.dupe_counter == 0, "Duplicate plugin names, see log"
Example #34
0
    def test_no_dupes(self):
        from flexget.options import CoreArgumentParser
        plugin.load_plugins(CoreArgumentParser())

        assert plugin.PluginInfo.dupe_counter == 0, "Duplicate plugin names, see log"
Example #35
0
    def test_no_dupes(self):
        plugin.load_plugins()

        assert plugin.PluginInfo.dupe_counter == 0, "Duplicate plugin names, see log"
Example #36
0
    def test_no_dupes(self):
        plugin.load_plugins()

        assert plugin.PluginInfo.dupe_counter == 0, "Duplicate plugin names, see log"