def call(self): super().__call__(LOG) for line in self.output: if self.returncode: if line: LOG.error(line) else: if line: LOG.trace(line) return self.output
def _get_db(self): host = self.config.getoption('db_host') port = int(self.config.getoption('db_port')) db_name = self.config.getoption('db_name') try: c = Connection(host=host, port=port) except ConnectionFailure, err: LOG.error("Could not connect to mongodb, %s" % err.message) sys.exit(1)
def dispatch_from_params(self, argv): main_help = 'jmake is a primary tool for JIRA devs.' parser = argparse.ArgumentParser(formatter_class=argparse.RawDescriptionHelpFormatter) self.__register_submodules(parser, MainModule(parser).get_submodules()) self.__discover_help(main_help, parser) if argv[1:]: args = parser.parse_args( [arg for arg in argv[1:] if arg != 'clean' or argv[1] == arg or argv[1] == 'auto-complete']) args.mvn_clean = 'clean' in argv[2:] if args.func.check_branch and not 'JMAKE_DRY' in os.environ: git_branch = GitBranchDiscovery() self.executor.append(git_branch) if not args.mvn_clean: self.executor.append(BranchInconsistencyCheck(git_branch)) self.executor.append_post(BranchInconsistencyMarker(git_branch)) try: args.func(args, self.executor) except Exception as e: self.executor.commands = [ lambda logger : logger.error('Exception occurred during preparing executor: %s' % str(e)) or Callable.success] self.executor.post_commands = [] traceback.print_exc() return self.executor.execute() if args.log_level: try: getattr(LOG, 'set_' + args.log_level)() except AttributeError: LOG.error('Cannot set log level to %s' % args.log_level) return Callable.failure if args.silent: args.func.prevent_post_commands = True if not args.func.prevent_post_commands: timer = ExecutionTimeCallable() self.executor.append_post(timer) if os.getenv('JMAKE_STFU') is None: self.executor.append_post(Notifier(timer)) if args.func.prevent_console_reset: self.executor.perform_console_reset = False if not args.func.prevent_post_diagnostics: self.__append_post_diagnostics() else: parser.print_help() self.__append_post_diagnostics() return self.executor.execute()