def main(): """main command-line entrypoint; calls parse_args, sets up logging, and either lists steps or instantiates a CustodianRunner and calls run().""" args = parse_args(sys.argv[1:]) # set logging level if args.verbose > 1: set_log_debug(logger) elif args.verbose == 1: set_log_info(logger) if args.ACTION == 'list': for x in CustodianRunner.ordered_step_classes: print(x.name) raise SystemExit(0) if args.ACTION == 'accounts': accts = ManheimConfig.list_accounts(args.config) for acctname in sorted(accts.keys()): print("%s (%s)" % (acctname, accts[acctname])) raise SystemExit(0) cr = CustodianRunner(args.ACCT_NAME, args.config) if args.assume_role: assume_role(cr.config) cr.run( args.ACTION, args.regions, step_names=args.steps, skip_steps=args.skip )
def main(): global logger # setup logging for direct command-line use FORMAT = "[%(asctime)s %(levelname)s] %(message)s" logging.basicConfig(level=logging.WARNING, format=FORMAT) logger = logging.getLogger() # suppress boto3 internal logging below WARNING level boto3_log = logging.getLogger("boto3") boto3_log.setLevel(logging.WARNING) boto3_log.propagate = True # suppress botocore internal logging below WARNING level botocore_log = logging.getLogger("botocore") botocore_log.setLevel(logging.WARNING) botocore_log.propagate = True # end setup logging args = parse_args(sys.argv[1:]) # set logging level if args.verbose > 1: set_log_debug(logger) elif args.verbose == 1: set_log_info(logger) conf = ManheimConfig.from_file(args.config, args.ACCOUNT_NAME) DryRunDiffer(conf).run(git_dir=args.git_dir, diff_against=args.diff_against)
def main(): # setup logging for direct command-line use global logger FORMAT = "[%(asctime)s %(levelname)s] %(message)s" logging.basicConfig(level=logging.INFO, format=FORMAT) logger = logging.getLogger() # suppress boto3 internal logging below WARNING level boto3_log = logging.getLogger("boto3") boto3_log.setLevel(logging.WARNING) boto3_log.propagate = True # suppress botocore internal logging below WARNING level botocore_log = logging.getLogger("botocore") botocore_log.setLevel(logging.WARNING) botocore_log.propagate = True # end setup logging args = parse_args(sys.argv[1:]) # set logging level if args.verbose > 1: set_log_debug(logger) elif args.verbose == 1: set_log_info(logger) S3Archiver(args.REGION_NAME, args.BUCKET_NAME, args.CONF_FILE, dryrun=args.dryrun).run()
def test_set_log_debug(self): mock_log = Mock(spec_set=logging.Logger) with patch('%s.set_log_level_format' % pbm, autospec=True) as mock_set: set_log_debug(mock_log) assert mock_set.mock_calls == [ call(mock_log, logging.DEBUG, "%(asctime)s [%(levelname)s %(filename)s:%(lineno)s - " "%(name)s.%(funcName)s() ] %(message)s") ]
def main(): args = parse_args(sys.argv[1:]) # set logging level if args.verbose > 1: set_log_debug(logger) elif args.verbose == 1: set_log_info(logger) conf = ManheimConfig.from_file(args.config, args.ACCOUNT_NAME) if args.assume_role: assume_role(conf) CustodianErrorReporter(conf, args.REGION_NAME).run()