3434except ModuleNotFoundError :
3535 fosslight_source_installed = False
3636
37- OUTPUT_EXCEL_PREFIX = "FOSSLight-Report_"
38- OUTPUT_YAML_PREFIX = "fosslight-sbom-info_"
37+ OUTPUT_REPORT_PREFIX = "fosslight_report_"
3938PKG_NAME = "fosslight_scanner"
4039logger = logging .getLogger (constant .LOGGER_NAME )
4140warnings .simplefilter (action = 'ignore' , category = FutureWarning )
42- _output_dir = "fosslight_raw_data_ "
41+ _output_dir = "fosslight_raw_data "
4342_log_file = "fosslight_log_"
4443_start_time = ""
4544_executed_path = ""
@@ -111,11 +110,7 @@ def run_scanner(src_path, dep_arguments, output_path, keep_raw_data=False,
111110 success , final_excel_dir , result_log = init (output_path )
112111
113112 if output_file == "" :
114- if output_extension == ".yaml" :
115- output_prefix = OUTPUT_YAML_PREFIX
116- else :
117- output_prefix = OUTPUT_EXCEL_PREFIX
118- output_file = output_prefix + _start_time
113+ output_file = OUTPUT_REPORT_PREFIX + _start_time
119114
120115 if output_extension == "" :
121116 output_extension = ".xlsx"
@@ -126,11 +121,11 @@ def run_scanner(src_path, dep_arguments, output_path, keep_raw_data=False,
126121 abs_path = os .path .abspath (src_path )
127122
128123 if success :
129- output_files = {"SRC" : f"FL_Source { output_extension } " ,
130- "BIN" : f"FL_Binary { output_extension } " ,
131- "BIN_TXT" : "FL_Binary .txt" ,
132- "DEP" : f"FL_Dependency { output_extension } " ,
133- "PRECHECKER" : "FL_Prechecker .yaml" }
124+ output_files = {"SRC" : f"fosslight_src_ { _start_time } { output_extension } " ,
125+ "BIN" : f"fosslight_bin_ { _start_time } { output_extension } " ,
126+ "BIN_TXT" : f"fosslight_binary_ { _start_time } .txt" ,
127+ "DEP" : f"fosslight_dep_ { _start_time } { output_extension } " ,
128+ "PRECHECKER" : f"fosslight_lint_ { _start_time } .yaml" }
134129 if run_prechecker :
135130 output_prechecker = os .path .join (_output_dir , output_files ["PRECHECKER" ])
136131 success , result = call_analysis_api (src_path , "Prechecker Lint" ,
@@ -210,9 +205,6 @@ def run_scanner(src_path, dep_arguments, output_path, keep_raw_data=False,
210205 logger .warning (f"Error to write final report: { ex } " )
211206
212207 try :
213- if not keep_raw_data :
214- logger .debug (f"Remove temporary files: { _output_dir } " )
215- rmdir (_output_dir )
216208 if remove_src_data :
217209 logger .debug (f"Remove temporary source: { src_path } " )
218210 rmdir (src_path )
@@ -250,9 +242,8 @@ def init(output_path="", make_outdir=True):
250242
251243 result_log = {}
252244 output_root_dir = ""
253- _start_time = datetime .now ().strftime ('%Y %m%d_%H%M%S ' )
245+ _start_time = datetime .now ().strftime ('%y %m%d_%H%M' )
254246
255- _output_dir = _output_dir + _start_time
256247 if output_path != "" :
257248 _output_dir = os .path .join (output_path , _output_dir )
258249 output_root_dir = output_path
@@ -297,6 +288,9 @@ def run_main(mode, path_arg, dep_arguments, output_file_or_dir, file_format, url
297288
298289 success , msg , output_path , output_file , output_extension = check_output_format (output_file_or_dir , file_format ,
299290 CUSTOMIZED_FORMAT )
291+ if output_path == "" :
292+ output_path = _executed_path
293+
300294 if not success :
301295 logger .error (msg )
302296 sys .exit (1 )
@@ -311,22 +305,16 @@ def run_main(mode, path_arg, dep_arguments, output_file_or_dir, file_format, url
311305 if not os .path .exists (os .path .join (_executed_path , after_comp_f )):
312306 logger .error ("Cannot find after FOSSLight report file (2nd param with -y option)." )
313307 return False
314- ret , final_excel_dir , result_log = init (output_path , False )
315- if output_path == "" :
316- output_path = _executed_path
317- else :
318- output_path = os .path .abspath (output_path )
308+ ret , final_excel_dir , result_log = init (output_path )
319309
320310 run_compare (os .path .join (_executed_path , before_comp_f ), os .path .join (_executed_path , after_comp_f ),
321- output_path , output_file , output_extension , _start_time )
311+ final_excel_dir , output_file , output_extension , _start_time , _output_dir )
322312 else :
323313 run_src = False
324314 run_bin = False
325315 run_dep = False
326316 run_prechecker = False
327317 remove_downloaded_source = False
328- if output_path == "" :
329- output_path = _executed_path
330318
331319 if mode == "prechecker" or mode == "reuse" :
332320 run_prechecker = True
@@ -361,7 +349,12 @@ def run_main(mode, path_arg, dep_arguments, output_file_or_dir, file_format, url
361349 remove_downloaded_source , {}, output_file ,
362350 output_extension , num_cores , db_url ,
363351 default_oss_name , url_to_analyze )
364-
352+ try :
353+ if not keep_raw_data :
354+ logger .debug (f"Remove temporary files: { _output_dir } " )
355+ rmdir (_output_dir )
356+ except Exception as ex :
357+ logger .debug (f"Error to remove temp files:{ ex } " )
365358 except Exception as ex :
366359 logger .warning (str (ex ))
367360 return False
0 commit comments