def cli(template, json_in, out_file, filter, report_type, name): """Generate builtin or custom Jinja reports based on test results data Example: neoload report --template builtin:transactions-csv See more templates, examples, filters with "neoload report" """ rest_crud.set_current_command() if all(v is None for v in [template, json_in, out_file, filter]): print_extended_help() tools.system_exit({'code': 1, 'message': ''}) return global gprint model = initialize_model(filter, template) logger = logging.getLogger() # if intent is to produce JSON directly to stdout, hide print statements if out_file is None: gprint = lambda msg: logger.info(msg) gprint("Export started: {}".format(datetime.now())) json_data = parse_source_data_spec(json_in, model, report_type, name) json_data['cli'] = { 'arguments': { 'template': template, 'json_in': json_in, 'out_file': out_file, 'filter': filter, 'report_type': report_type, 'name': name }, 'debug': logging.getLogger().level == logging.DEBUG, 'internals': { 'version': tools.compute_version() } } final_output = process_final_output(template, model.get("template_text"), json_data) if tools.__is_color_terminal(): final_output = displayer.colorize_text(final_output) if out_file is not None: set_file_text(out_file, final_output) if tools.is_user_interactive() and (out_file.lower().endswith(".html") or out_file.lower().endswith(".htm")): webbrowser.open_new_tab("file://" + out_file) else: print(final_output) gprint("Export ended: {}".format(datetime.now()))
with open(fn) as f: code = compile(f.read(), fn, 'exec') eval(code, ns, ns) return ns['cli'] else: raise cli_exception.CliException("\"" + name + "\" is not a neoload command") @click.command(cls=NeoLoadCLI, help='', chain=True) @click.option('--debug', default=False, is_flag=True) @click.option('--batch', default=False, is_flag=True, help="Don't ask a question or read stdin") @click.version_option(tools.compute_version()) def cli(debug, batch): if debug: logging.basicConfig() logging.getLogger().setLevel(logging.DEBUG) requests_log = logging.getLogger("requests.packages.urllib3") requests_log.setLevel(logging.DEBUG) requests_log.propagate = True cli_exception.CliException.set_debug(True) tools.set_batch(batch) if batch: sys.stdin = open(os.devnull, 'r') if tools.is_color_terminal(): coloredlogs.install(level=logging.getLogger().level)