@@ -466,38 +466,31 @@ def get_pretty_params(args):
466
466
467
467
468
468
def run_scan (location , output_file , run_scan_args ):
469
- """
470
- Scan the `location` content and write the results into an `output_file`.
471
- If `raise_on_error` is enabled, a ScancodeError will be raised if an error occurs
472
- during the scan.
473
- """
474
- run_args = settings .SCANCODE_TOOLKIT_RUN_SCAN_ARGS .copy ()
475
- # The run_scan_args should override any values provided in the settings
476
- run_args .update (run_scan_args )
477
-
478
- if "timeout" in run_args :
479
- run_args ["timeout" ] = int (run_args .get ("timeout" ))
480
-
481
- success , results = scancode_run_scan (
469
+ """Scan the `location` content and write the results into an `output_file`."""
470
+ _success , results = scancode_run_scan (
482
471
input = shlex .quote (location ),
483
472
processes = get_max_workers (keep_available = 1 ),
484
473
quiet = True ,
485
474
verbose = False ,
486
475
return_results = True ,
487
476
echo_func = None ,
488
- pretty_params = get_pretty_params (run_args ),
489
- ** run_args ,
477
+ pretty_params = get_pretty_params (run_scan_args ),
478
+ timeout = settings .SCANCODEIO_SCAN_FILE_TIMEOUT ,
479
+ ** run_scan_args ,
490
480
)
491
481
492
- if success :
482
+ # ``_success`` will be False if any scanning errors occur, but we still want
483
+ # to generate the results output in that case.
484
+ if results :
493
485
Path (output_file ).write_text (json .dumps (results , indent = 2 ))
494
- return
495
486
496
- errors = {}
487
+ # Capture scan errors logged at the files level.
488
+ scanning_errors = {}
497
489
for file in results .get ("files" , []):
498
- if scan_errors := file .get ("scan_errors" ):
499
- errors [file .get ("path" )] = scan_errors
500
- return errors
490
+ if errors := file .get ("scan_errors" ):
491
+ scanning_errors [file .get ("path" )] = errors
492
+
493
+ return scanning_errors
501
494
502
495
503
496
def get_virtual_codebase (project , input_location ):
0 commit comments