Skip to content

Commit 289bdff

Browse files
Fix bug while removing temp files (#244)
* Fix on removing temp file from SCANOSS * Restore wfp file delete code for legacy env --------- Signed-off-by: Wonjae Park <j.wonjae.park@gmail.com>
1 parent b6d69fb commit 289bdff

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
pyparsing
2-
scanoss>=1.18.0
2+
scanoss>=1.19.0
33
XlsxWriter
44
fosslight_util>=2.1.37
55
PyYAML

src/fosslight_source/run_scanoss.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,14 @@
1313
from ._parsing_scanoss_file import parsing_scan_result # scanoss
1414
from ._parsing_scanoss_file import parsing_extra_info # scanoss
1515
from scanoss.scanner import Scanner, ScanType
16+
from scanoss.scanoss_settings import ScanossSettings
1617
import io
1718
import contextlib
1819

1920
logger = logging.getLogger(constant.LOGGER_NAME)
2021
warnings.filterwarnings("ignore", category=FutureWarning)
2122
_PKG_NAME = "fosslight_source"
23+
SCANOSS_RESULT_FILE = "scanner_output.wfp"
2224
SCANOSS_OUTPUT_FILE = "scanoss_raw_result.json"
2325

2426

@@ -51,16 +53,19 @@ def run_scanoss_py(path_to_scan: str, output_path: str = "", format: list = [],
5153
return scanoss_file_list, api_limit_exceed
5254

5355
output_json_file = os.path.join(output_path, SCANOSS_OUTPUT_FILE)
56+
output_wfp_file = os.path.join(output_path, SCANOSS_RESULT_FILE)
5457
if os.path.exists(output_json_file):
5558
os.remove(output_json_file)
5659

5760
try:
61+
scanoss_settings = ScanossSettings()
5862
scanner = Scanner(
5963
ignore_cert_errors=True,
6064
skip_folders=list(path_to_exclude) if path_to_exclude else [],
6165
scan_output=output_json_file,
6266
scan_options=ScanType.SCAN_SNIPPETS.value,
63-
nb_threads=num_threads if num_threads > 0 else 10
67+
nb_threads=num_threads if num_threads > 0 else 10,
68+
scanoss_settings=scanoss_settings
6469
)
6570

6671
output_buffer = io.StringIO()
@@ -80,14 +85,15 @@ def run_scanoss_py(path_to_scan: str, output_path: str = "", format: list = [],
8085
with open(output_json_file, "r") as st_json:
8186
st_python = json.load(st_json)
8287
scanoss_file_list = parsing_scan_result(st_python, excluded_files)
83-
84-
if not write_json_file:
85-
if os.path.isfile(output_json_file):
86-
os.remove(output_json_file)
87-
8888
except Exception as error:
8989
logger.debug(f"SCANOSS Parsing {path_to_scan}: {error}")
9090

91+
if not write_json_file:
92+
if os.path.isfile(output_json_file):
93+
os.remove(output_json_file)
94+
if os.path.isfile(output_wfp_file):
95+
os.remove(output_wfp_file)
96+
9197
logger.info(f"|---Number of files detected with SCANOSS: {(len(scanoss_file_list))}")
9298

9399
return scanoss_file_list, api_limit_exceed

0 commit comments

Comments
 (0)