Skip to content

Commit 95f4cfa

Browse files
authored
Merge pull request #142 from fosslight/correct
Fix the correct bug
2 parents f582483 + 57bd4f5 commit 95f4cfa

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/fosslight_scanner/common.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import logging
99
import shutil
1010
import copy
11+
import traceback
1112
from fosslight_util.constant import LOGGER_NAME, FOSSLIGHT_SOURCE, FOSSLIGHT_BINARY, FOSSLIGHT_DEPENDENCY
1213
from fosslight_util.write_scancodejson import write_scancodejson
1314
from 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

Comments
 (0)