|
44 | 44 | _start_time = "" |
45 | 45 | _executed_path = "" |
46 | 46 | SRC_DIR_FROM_LINK_PREFIX = "fosslight_src_dir_" |
| 47 | +SCANNER_MODE = ["compare", "reuse", "prechecker", "binary", "bin", "src", "source", "dependency", "dep"] |
47 | 48 |
|
48 | 49 |
|
49 | 50 | def run_dependency(path_to_analyze, output_file_with_path, params=""): |
@@ -352,48 +353,64 @@ def run_main(mode, path_arg, dep_arguments, output_file_or_dir, file_format, url |
352 | 353 | run_dep = False |
353 | 354 | run_prechecker = False |
354 | 355 | remove_downloaded_source = False |
| 356 | + mode_list = [] |
355 | 357 |
|
356 | | - if mode == "prechecker" or mode == "reuse": |
357 | | - run_prechecker = True |
358 | | - elif mode == "binary" or mode == "bin": |
359 | | - run_bin = True |
360 | | - elif mode == "source" or mode == "src": |
361 | | - run_src = True |
362 | | - elif mode == "dependency" or mode == "dep": |
363 | | - run_dep = True |
364 | | - else: |
| 358 | + if mode: |
| 359 | + mode_list = mode.split(',') |
| 360 | + mode_list = [item.strip() for item in mode_list] |
| 361 | + |
| 362 | + if "compare" in mode_list: |
| 363 | + logger.error("Compare mode cannot be run together with other modes.") |
| 364 | + sys.exit(1) |
| 365 | + elif "all" in mode_list or (not mode): |
365 | 366 | run_src = True |
366 | 367 | run_bin = True |
367 | 368 | run_dep = True |
368 | 369 | run_prechecker = True |
369 | | - |
370 | | - if src_path == "" and url_to_analyze == "": |
371 | | - src_path, dep_arguments, url_to_analyze = get_input_mode(_executed_path, mode) |
372 | | - |
373 | | - if not hide_progressbar: |
374 | | - timer = TimerThread() |
375 | | - timer.setDaemon(True) |
376 | | - timer.start() |
377 | | - |
378 | | - if url_to_analyze != "": |
379 | | - remove_downloaded_source = True |
380 | | - default_oss_name = extract_name_from_link(url_to_analyze) |
381 | | - success, src_path = download_source(url_to_analyze, output_path) |
382 | | - |
383 | | - if output_extension == ".yaml": |
384 | | - correct_mode = False |
385 | | - correct_fpath = "" |
386 | 370 | else: |
387 | | - if not correct_fpath: |
388 | | - correct_fpath = src_path |
389 | | - |
390 | | - if src_path != "": |
391 | | - run_scanner(src_path, dep_arguments, output_path, keep_raw_data, |
392 | | - run_src, run_bin, run_dep, run_prechecker, |
393 | | - remove_downloaded_source, {}, output_file, |
394 | | - output_extension, num_cores, db_url, |
395 | | - default_oss_name, url_to_analyze, |
396 | | - correct_mode, correct_fpath, ui_mode) |
| 371 | + if "prechecker" in mode_list or "reuse" in mode_list: |
| 372 | + run_prechecker = True |
| 373 | + if "binary" in mode_list or "bin" in mode_list: |
| 374 | + run_bin = True |
| 375 | + if "source" in mode_list or "src" in mode_list: |
| 376 | + run_src = True |
| 377 | + if "dependency" in mode_list or "dep" in mode_list: |
| 378 | + run_dep = True |
| 379 | + mode_not_supported = list(set(mode_list).difference(SCANNER_MODE)) |
| 380 | + if len(mode_not_supported) > 0: |
| 381 | + logger.error(f"An unsupported mode was entered.:{mode_not_supported}") |
| 382 | + sys.exit(1) |
| 383 | + |
| 384 | + if run_dep or run_src or run_bin or run_prechecker: |
| 385 | + if src_path == "" and url_to_analyze == "": |
| 386 | + src_path, dep_arguments, url_to_analyze = get_input_mode(_executed_path, mode) |
| 387 | + |
| 388 | + if not hide_progressbar: |
| 389 | + timer = TimerThread() |
| 390 | + timer.setDaemon(True) |
| 391 | + timer.start() |
| 392 | + |
| 393 | + if url_to_analyze != "": |
| 394 | + remove_downloaded_source = True |
| 395 | + default_oss_name = extract_name_from_link(url_to_analyze) |
| 396 | + success, src_path = download_source(url_to_analyze, output_path) |
| 397 | + |
| 398 | + if output_extension == ".yaml": |
| 399 | + correct_mode = False |
| 400 | + correct_fpath = "" |
| 401 | + else: |
| 402 | + if not correct_fpath: |
| 403 | + correct_fpath = src_path |
| 404 | + |
| 405 | + if src_path != "": |
| 406 | + run_scanner(src_path, dep_arguments, output_path, keep_raw_data, |
| 407 | + run_src, run_bin, run_dep, run_prechecker, |
| 408 | + remove_downloaded_source, {}, output_file, |
| 409 | + output_extension, num_cores, db_url, |
| 410 | + default_oss_name, url_to_analyze, |
| 411 | + correct_mode, correct_fpath, ui_mode) |
| 412 | + else: |
| 413 | + logger.error("No mode has been selected for analysis.") |
397 | 414 | try: |
398 | 415 | if not keep_raw_data: |
399 | 416 | logger.debug(f"Remove temporary files: {_output_dir}") |
|
0 commit comments