88import logging
99import shutil
1010import copy
11+ import traceback
1112from fosslight_util .constant import LOGGER_NAME , FOSSLIGHT_SOURCE , FOSSLIGHT_BINARY , FOSSLIGHT_DEPENDENCY
1213from fosslight_util .write_scancodejson import write_scancodejson
1314from fosslight_util .oss_item import OssItem , FileItem
@@ -177,7 +178,10 @@ def correct_scanner_result(all_scan_item):
177178 bin_empty_license_exists = all (not oss_item .license for oss_item in bin_fileitem .oss_items )
178179
179180 if src_all_licenses_non_empty and bin_empty_license_exists :
180- exclude = bin_fileitem .oss_items [0 ].exclude
181+ if bin_fileitem .oss_items :
182+ exclude = bin_fileitem .oss_items [0 ].exclude
183+ else :
184+ exclude = False
181185 bin_fileitem .oss_items = []
182186 for src_oss_item in src_fileitem .oss_items :
183187 src_oss_item .exclude = exclude
@@ -190,13 +194,11 @@ def correct_scanner_result(all_scan_item):
190194 for i in sorted (remove_src_idx_list , reverse = True ):
191195 del src_fileitems [i ]
192196 except Exception as ex :
193- logger .warning (f"correct the scanner result:{ ex } " )
197+ logger .warning (f"Fail to correct the scanner result:{ ex } " )
198+ logger .warning (traceback .format_exc ())
194199
195- try :
196- if duplicates :
197- logger .info ('Success to correct the src/bin scanner result' )
198- except Exception as ex :
199- logger .warning (f"Corrected src/bin scanner result:{ ex } " )
200+ if duplicates :
201+ logger .info ('Success to correct the src/bin scanner result' )
200202 return all_scan_item
201203
202204
0 commit comments