def check_run_names(client, check_names): """ Check if the given names are valid runs on the server. If any of the names is not found then the script finishes. Otherwise a dictionary returns which maps run names to runs. The dictionary contains only the runs in check_names or all runs if check_names is empty or None. """ run_filter = ttypes.RunFilter() run_filter.names = check_names run_filter.exactMatch = check_names is not None run_info = {run.name: run for run in client.getRunData(run_filter)} if not check_names: return run_info missing_name = False for name in check_names: if not run_info.get(name): LOG.warning("The run named '" + name + "' was not found.") missing_name = True if missing_name: print("Possible run names are:") for name, _ in run_info.items(): print(name) sys.exit(1) return run_info
def handle_list_runs(args): # If the given output format is not 'table', redirect logger's output to # the stderr. stream = None if 'output_format' in args and args.output_format != 'table': stream = 'stderr' init_logger(args.verbose if 'verbose' in args else None, stream) client = setup_client(args.product_url) run_filter = None if 'names' in args: run_filter = ttypes.RunFilter() run_filter.names = args.names runs = client.getRunData(run_filter) if args.output_format == 'json': results = [] for run in runs: results.append({run.name: run}) print(CmdLineOutputEncoder().encode(results)) else: # plaintext, csv header = ['Name', 'Number of unresolved reports', 'Analyzer statistics', 'Storage date', 'Version tag', 'Duration', 'CodeChecker version'] rows = [] for run in runs: duration = str(timedelta(seconds=run.duration)) \ if run.duration > -1 else 'Not finished' analyzer_statistics = [] for analyzer in run.analyzerStatistics: stat = run.analyzerStatistics[analyzer] num_of_all_files = stat.successful + stat.failed analyzer_statistics.append(analyzer + ' (' + str(num_of_all_files) + '/' + str(stat.successful) + ')') codechecker_version = run.codeCheckerVersion \ if run.codeCheckerVersion else '' rows.append((run.name, str(run.resultCount), ', '.join(analyzer_statistics), run.runDate, run.versionTag if run.versionTag else '', duration, codechecker_version)) print(twodim_to_str(args.output_format, header, rows))
def get_runs(client, run_names): run_filter = ttypes.RunFilter() run_filter.names = run_names return client.getRunData(run_filter)