def main(args): bs = get_binstar(args, cls=BinstarBuildAPI) worker_config = WorkerConfiguration.load(args.worker_id, bs, warn=True) WorkerConfiguration.validate_worker_name(bs, args.worker_id) if worker_config.hostname != WorkerConfiguration.HOSTNAME: log.warn(WRONG_HOSTNAME_MSG.format(worker_config.hostname, WorkerConfiguration.HOSTNAME)) args.conda_build_dir = args.conda_build_dir.format(platform=worker_config.platform) setup_logging(logging.getLogger('binstar_build_client'), args.log_level, args.color, show_tb=args.show_traceback) log.info("Using conda build directory: {}".format(args.conda_build_dir)) log.info(str(worker_config)) worker = Worker(bs, worker_config, args) worker.write_status(True, "Starting") worker.write_stats() try: with worker_config.running(): worker.work_forever() finally: worker.write_status(False, "Exited")
def main(args): bs = get_binstar(args, cls=BinstarBuildAPI) worker_config = WorkerConfiguration.load(args.worker_id, bs, warn=True) WorkerConfiguration.validate_worker_name(bs, args.worker_id) if worker_config.hostname != WorkerConfiguration.HOSTNAME: log.warn( WRONG_HOSTNAME_MSG.format(worker_config.hostname, WorkerConfiguration.HOSTNAME)) args.conda_build_dir = args.conda_build_dir.format( platform=worker_config.platform) setup_logging(logging.getLogger('binstar_build_client'), args.log_level, args.color, show_tb=args.show_traceback) log.info("Using conda build directory: {}".format(args.conda_build_dir)) log.info(str(worker_config)) worker = Worker(bs, worker_config, args) worker.write_status(True, "Starting") worker.write_stats() try: with worker_config.running(): worker.work_forever() finally: worker.write_status(False, "Exited")
def binstar_main(sub_command_module, args=None, exit=True, description=None, version=None, epilog=None): parser = ArgumentParser(description=description, epilog=epilog, formatter_class=RawDescriptionHelpFormatter) add_default_arguments(parser, version) bgroup = parser.add_argument_group('anaconda-client options') bgroup.add_argument('-t', '--token', type=file_or_token, help="Authentication token to use. " "May be a token or a path to a file containing a token") bgroup.add_argument('-s', '--site', help='select the anaconda-client site to use', default=None) add_subparser_modules(parser, sub_command_module, 'conda_server.subcommand') if not exists(USER_LOGDIR): makedirs(USER_LOGDIR) logfile = join(USER_LOGDIR, 'cli.log') args = parser.parse_args(args) # Let clyent handle the logging logger.disabled = True logger.propagate = False logger.addHandler(logging.NullHandler()) setup_logging( logger, args.log_level, use_color=args.color, logfile=logfile, show_tb=args.show_traceback ) try: try: if not hasattr(args, 'main'): parser.error("A sub command must be given. " "To show all available sub commands, run:\n\n\t anaconda -h\n") return args.main(args) except errors.Unauthorized: if not sys.stdin.isatty() or args.token: # Don't try the interactive login # Just exit raise logger.info('The action you are performing requires authentication, ' 'please sign in:') interactive_login(args) return args.main(args) except errors.ShowHelp: args.sub_parser.print_help() if exit: raise SystemExit(1) else: return 1
def main(args=None, exit=True): parser = ArgumentParser(description=__doc__) add_default_arguments(parser, version) add_subparser_modules(parser, chalmers.commands) args = parser.parse_args(args) logfile = join(dirs.user_log_dir, 'cli.log') setup_logging(logger, args.log_level, use_color=args.color, show_tb=args.show_traceback, logfile=logfile) run_command(args, exit=exit)
def main(): parser = ArgumentParser(description=__doc__) parser.add_argument('--root', help='chalmers root config directory') parser.add_argument('name', help='name of program to run') args = parser.parse_args() if args.root: config.set_relative_dirs(args.root) logfile = config.main_logfile() setup_logging(logger, logging.INFO, use_color='never', logfile=logfile, show_tb=True) cli_logger.error("Starting program: %s" % args.name) prog = Program(args.name) prog.start_sync()
def main(args=None, exit=True): parser = ArgumentParser(description=__doc__) add_default_arguments(parser, version) add_subparser_modules(parser, chalmers.commands) args = parser.parse_args(args) logfile = config.main_logfile() setup_logging(logger, args.log_level, use_color=args.color, show_tb=args.show_traceback, logfile=logfile) if not hasattr(args, 'main'): parser.error('too few arguments') run_command(args, exit=exit)
def binstar_main(sub_command_module, args=None, exit=True, description=None, version=None, epilog=None): parser = ArgumentParser(description=description, epilog=epilog, formatter_class=RawDescriptionHelpFormatter) add_default_arguments(parser, version) bgroup = parser.add_argument_group('anaconda-client options') bgroup.add_argument('-t', '--token', type=file_or_token, help="Authentication token to use. " "May be a token or a path to a file containing a token") bgroup.add_argument('-s', '--site', help='select the anaconda-client site to use', default=None) add_subparser_modules(parser, sub_command_module, 'conda_server.subcommand') if not exists(USER_LOGDIR): makedirs(USER_LOGDIR) logfile = join(USER_LOGDIR, 'cli.log') args = parser.parse_args(args) setup_logging(logger, args.log_level, use_color=args.color, logfile=logfile, show_tb=args.show_traceback) try: try: if not hasattr(args, 'main'): parser.error("A sub command must be given. " "To show all available sub commands, run:\n\n\t anaconda -h\n") return args.main(args) except errors.Unauthorized: if not sys.stdin.isatty() or args.token: # Don't try the interactive login # Just exit raise logger.info('The action you are performing requires authentication, ' 'please sign in:') interactive_login(args) return args.main(args) except errors.ShowHelp: args.sub_parser.print_help() if exit: raise SystemExit(1) else: return 1
def main(args): if docker is None: raise errors.UserError("anaconda worker docker_run requires docker and docker-py to be installed\n" "Run:\n\tpip install docker-py") bs = get_binstar(args, cls=BinstarBuildAPI) worker_config = WorkerConfiguration.load(args.worker_id, bs, warn=True) WorkerConfiguration.validate_worker_name(bs, args.worker_id) if worker_config.hostname != WorkerConfiguration.HOSTNAME: log.warn(WRONG_HOSTNAME_MSG.format(worker_config.hostname, WorkerConfiguration.HOSTNAME)) setup_logging(logging.getLogger('binstar_build_client'), args.log_level, args.color, show_tb=args.show_traceback) worker = DockerWorker(bs, worker_config, args) worker.write_stats() worker.work_forever()
def main(args): if docker is None: raise errors.UserError( "anaconda worker docker_run requires docker and docker-py to be installed\n" "Run:\n\tpip install docker-py") bs = get_binstar(args, cls=BinstarBuildAPI) worker_config = WorkerConfiguration.load(args.worker_id, bs, warn=True) WorkerConfiguration.validate_worker_name(bs, args.worker_id) if worker_config.hostname != WorkerConfiguration.HOSTNAME: log.warn( WRONG_HOSTNAME_MSG.format(worker_config.hostname, WorkerConfiguration.HOSTNAME)) setup_logging(logging.getLogger('binstar_build_client'), args.log_level, args.color, show_tb=args.show_traceback) worker = DockerWorker(bs, worker_config, args) worker.write_stats() worker.work_forever()