def main(args=None): parser = argparse.ArgumentParser( description="Releng API Command Line Tool") parser.add_argument("--quiet", '-q', action='store_true', help="Silence all logging below WARNING level") subparsers = parser.add_subparsers(help='sub-command help') # load each of the blueprints; this defines the subcommand classes. Note that # create_app does this again. for ep in (list(pkg_resources.iter_entry_points('relengapi_blueprints')) + list(pkg_resources.iter_entry_points('relengapi.blueprints'))): ep.load() subcommands = [cls() for cls in Subcommand.__subclasses__()] for subcommand in subcommands: subparser = subcommand.make_parser(subparsers) subparser.set_defaults(_subcommand=subcommand) args = parser.parse_args(args) if args._subcommand and args._subcommand.want_logging: setupConsoleLogging(args.quiet) # make the RELENGAPI_SETTINGS env var an absolute path; without this, Flask # uses the application's root_dir, which isn't especially helpful in a # development context. var_name = 'RELENGAPI_SETTINGS' if var_name in os.environ: os.environ[var_name] = os.path.abspath(os.environ[var_name]) app = relengapi.app.create_app(cmdline=True) with app.app_context(): args._subcommand.run(parser, args)
def main(args=None): parser = argparse.ArgumentParser( description="Releng API Command Line Tool") parser.add_argument("--quiet", '-q', action='store_true', help="Silence all logging below WARNING level") parser.add_argument("--disable-logging", '-Q', action='store_true', help="Silence all logging") subparsers = parser.add_subparsers(help='sub-command help') # each of the Subcommand subclasses was loaded when the blueprints were # imported in relengapi.app cmds = [cls() for cls in subcommands.Subcommand.__subclasses__()] for cmd in cmds: subparser = cmd.make_parser(subparsers) subparser.set_defaults(_subcommand=cmd) args = parser.parse_args(args) if args._subcommand and args._subcommand.want_logging and not args.disable_logging: setupConsoleLogging(args.quiet) else: # blueprints.slaveloan.bugzilla complains about not having a handler logging.getLogger().addHandler(logging.NullHandler()) # make the RELENGAPI_SETTINGS env var an absolute path; without this, Flask # uses the application's root_dir, which isn't especially helpful in a # development context. var_name = 'RELENGAPI_SETTINGS' if var_name in os.environ: os.environ[var_name] = os.path.abspath(os.environ[var_name]) app = relengapi.app.create_app(cmdline=True) with app.app_context(): args._subcommand.run(parser, args)
def main(args=None): parser = argparse.ArgumentParser( description="Releng API Command Line Tool") parser.add_argument("--quiet", '-q', action='store_true', help="Silence all logging below WARNING level") subparsers = parser.add_subparsers(help='sub-command help') # load each of the blueprints; this defines the subcommand classes. Note that # create_app does this again. for ep in (list(pkg_resources.iter_entry_points('relengapi_blueprints')) + list(pkg_resources.iter_entry_points('relengapi.blueprints'))): ep.load() subcommands = [cls() for cls in Subcommand.__subclasses__()] for subcommand in subcommands: subparser = subcommand.make_parser(subparsers) subparser.set_defaults(_subcommand=subcommand) args = parser.parse_args(args) if args._subcommand and args._subcommand.want_logging: setupConsoleLogging(args.quiet) app = relengapi.app.create_app(cmdline=True) with app.app_context(): args._subcommand.run(parser, args)
def main(): parser = argparse.ArgumentParser( description="Releng API Command Line Tool") subparsers = parser.add_subparsers(help='sub-command help') # load each of the blueprints; this defines the subcommand classes. Note that # create_app does this again. for ep in pkg_resources.iter_entry_points('relengapi_blueprints'): ep.load() subcommands = [cls() for cls in Subcommand.__subclasses__()] for subcommand in subcommands: subparser = subcommand.make_parser(subparsers) subparser.set_defaults(_subcommand=subcommand) args = parser.parse_args() if args._subcommand and args._subcommand.want_logging: setupConsoleLogging() app = relengapi.app.create_app(cmdline=True) with app.app_context(): args._subcommand.run(parser, args)