コード例 #1
0
ファイル: __init__.py プロジェクト: EnJens/Flexget
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()
コード例 #2
0
ファイル: __init__.py プロジェクト: awesome-python/Flexget
def main(args=None):
    """Main entry point for Command Line Interface"""

    try:
        logger.initialize()

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

        try:
            if manager.options.profile:
                try:
                    import cProfile as profile
                except ImportError:
                    import profile
                profile.runctx('manager.start()', globals(), locals(),
                               os.path.join(manager.config_base, manager.options.profile))
            else:
                manager.start()
        except (IOError, ValueError) as e:
            print('Could not start manager: %s' % e, file=sys.stderr)
            sys.exit(1)
    except KeyboardInterrupt:
        print('Killed with keyboard interrupt.', file=sys.stderr)
        sys.exit(1)
コード例 #3
0
ファイル: __init__.py プロジェクト: edetaillac/Flexget
def main(args=None):
    """Main entry point for Command Line Interface"""

    try:
        logger.initialize()

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

        try:
            if manager.options.profile:
                try:
                    import cProfile as profile
                except ImportError:
                    import profile
                profile.runctx(
                    'manager.start()', globals(), locals(),
                    os.path.join(manager.config_base, manager.options.profile))
            else:
                manager.start()
        except (IOError, ValueError) as e:
            print('Could not start manager: %s' % e, file=sys.stderr)
            sys.exit(1)
    except KeyboardInterrupt:
        print('Killed with keyboard interrupt.', file=sys.stderr)
        sys.exit(1)
コード例 #4
0
def seen_forget(manager: Manager, options):
    forget_name = options.forget_value
    if is_imdb_url(forget_name):
        imdb_id = extract_id(forget_name)
        if imdb_id:
            forget_name = imdb_id

    tasks = None
    if options.tasks:
        tasks = []
        for task in options.tasks:
            try:
                tasks.extend(m for m in manager.matching_tasks(task) if m not in tasks)
            except ValueError as e:
                console(e)
                continue

    # If tasks are specified it should use pattern matching as search
    if tasks:
        forget_name = forget_name.replace("%", "\\%").replace("_", "\\_")
        forget_name = forget_name.replace("*", "%").replace("?", "_")

    count, fcount = db.forget(forget_name, tasks=tasks, test=options.test)
    console(f'Removed {count} titles ({fcount} fields)')
    manager.config_changed()
コード例 #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()
コード例 #6
0
ファイル: manager.py プロジェクト: achuprin/Flexget
 def find_config(self):
     """If no config file is found by the webui, a blank one is created."""
     try:
         Manager.find_config(self)
     except IOError:
         # No config file found, create a blank one in the home path
         config_path = os.path.join(os.path.expanduser('~'), '.flexget')
         if not os.path.exists(config_path):
             os.mkdir(config_path)
         config_filename = os.path.join(config_path, self.options.config)
         log.info('Config file %s not found. Creating new config %s' % (self.options.config, config_filename))
         newconfig = file(config_filename, 'w')
         # Write empty feeds and presets to the config
         newconfig.write(yaml.dump({'presets': {}, 'feeds': {}}))
         newconfig.close()
         self.load_config(config_filename)
コード例 #7
0
ファイル: __init__.py プロジェクト: andir/Flexget
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()
コード例 #8
0
ファイル: __init__.py プロジェクト: crawln45/Flexget
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()
コード例 #9
0
ファイル: manager.py プロジェクト: Donavan/Flexget
 def find_config(self):
     """If no config file is found by the webui, a blank one is created."""
     try:
         Manager.find_config(self)
     except IOError:
         # No config file found, create a blank one in the home path
         if sys.platform.startswith('win'):
             # On windows machines do not use a dot in folder name
             folder = 'flexget'
         else:
             folder = '.flexget'
         config_path = os.path.join(os.path.expanduser('~'), folder)
         if not os.path.exists(config_path):
             os.mkdir(config_path)
         config_filename = os.path.join(config_path, self.options.config)
         log.info('Config file %s not found. Creating new config %s' % (self.options.config, config_filename))
         newconfig = file(config_filename, 'w')
         # Write empty tasks and presets to the config
         newconfig.write(yaml.dump({'presets': {}, 'tasks': {}}))
         newconfig.close()
         self.load_config(config_filename)
コード例 #10
0
ファイル: __init__.py プロジェクト: gazpachoking/Flexget
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()
コード例 #11
0
ファイル: manager.py プロジェクト: gazpachoking/Flexget
 def find_config(self):
     """If no config file is found by the webui, a blank one is created."""
     try:
         Manager.find_config(self)
     except IOError:
         # No config file found, create a blank one in the home path
         if sys.platform.startswith('win'):
             # On windows machines do not use a dot in folder name
             folder = 'flexget'
         else:
             folder = '.flexget'
         config_path = os.path.join(os.path.expanduser('~'), folder)
         if not os.path.exists(config_path):
             os.mkdir(config_path)
         config_filename = os.path.join(config_path, self.options.config)
         log.info('Config file %s not found. Creating new config %s' %
                  (self.options.config, config_filename))
         newconfig = file(config_filename, 'w')
         # Write empty tasks and presets to the config
         newconfig.write(yaml.dump({'presets': {}, 'tasks': {}}))
         newconfig.close()
         self.load_config(config_filename)
コード例 #12
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()
コード例 #13
0
ファイル: __init__.py プロジェクト: s-m-b/Flexget
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)
コード例 #14
0
def seen_search(manager: Manager, options, session=None):
    search_term = options.search_term
    if is_imdb_url(search_term):
        console('IMDB url detected, parsing ID')
        imdb_id = extract_id(search_term)
        if imdb_id:
            search_term = imdb_id
        else:
            console("Could not parse IMDB ID")
    else:
        search_term = search_term.replace("%", "\\%").replace("_", "\\_")
        search_term = search_term.replace("*", "%").replace("?", "_")

    tasks = None
    if options.tasks:
        tasks = []
        for task in options.tasks:
            try:
                tasks.extend(m for m in manager.matching_tasks(task) if m not in tasks)
            except ValueError as e:
                console(e)
                continue

    seen_entries = db.search(value=search_term, status=None, tasks=tasks, session=session)
    table = TerminalTable('Field', 'Value', table_type=options.table_type)
    for se in seen_entries.all():
        table.add_row('Title', se.title)
        for sf in se.fields:
            if sf.field.lower() == 'title':
                continue
            table.add_row('{}'.format(sf.field.upper()), str(sf.value))
        table.add_row('Task', se.task)
        if se.local:
            table.add_row('Local', 'Yes')
        table.add_row('Added', se.added.strftime('%Y-%m-%d %H:%M'), end_section=True)
    if not table.rows:
        console('No results found for search')
        return
    console(table)
コード例 #15
0
ファイル: manager.py プロジェクト: Donavan/Flexget
 def execute(self, *args, **kwargs):
     # Update task instances to match config
     self.update_tasks()
     Manager.execute(self, *args, **kwargs)
コード例 #16
0
ファイル: manager.py プロジェクト: Donavan/Flexget
 def __init__(self, options, coreparser):
     Manager.__init__(self, options)
     self.parser = StoreErrorArgumentParser(coreparser)
コード例 #17
0
ファイル: manager.py プロジェクト: gray/Flexget
 def execute(self, *args, **kwargs):
     # Update feed instances to match config
     self.update_feeds()
     Manager.execute(self, *args, **kwargs)
コード例 #18
0
ファイル: manager.py プロジェクト: gazpachoking/Flexget
 def __init__(self, options, coreparser):
     Manager.__init__(self, options)
     self.parser = StoreErrorArgumentParser(coreparser)
コード例 #19
0
ファイル: manager.py プロジェクト: gazpachoking/Flexget
 def check_lock(self):
     if self.options.autoreload:
         log.info('autoreload enabled, not checking for lock file')
         return False
     return Manager.check_lock(self)
コード例 #20
0
ファイル: manager.py プロジェクト: Donavan/Flexget
 def check_lock(self):
     if self.options.autoreload:
         log.info('autoreload enabled, not checking for lock file')
         return False
     return Manager.check_lock(self)
コード例 #21
0
ファイル: __init__.py プロジェクト: achuprin/Flexget
 def __init__(self, config_text, config_name):
     self.config_text = config_text
     self.config_name = config_name
     self.config = None
     self.config_base = None
     Manager.__init__(self, test_options)
コード例 #22
0
ファイル: manager.py プロジェクト: gazpachoking/Flexget
 def execute(self, *args, **kwargs):
     # Update task instances to match config
     self.update_tasks()
     Manager.execute(self, *args, **kwargs)