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
def main(): """Main entry point for Command Line Interface""" logger.initialize() plugin.load_plugins(exec_parser) options = core_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 getattr(options, 'func', False): options.func(manager, options) elif options.subcommand == 'exec': 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()