From bf0aed612b7eddf50a8ac0115eb7735375a129c5 Mon Sep 17 00:00:00 2001 From: Jaekwon Bang Date: Tue, 10 Aug 2021 14:20:43 +0900 Subject: [PATCH 1/4] Merge init_log & init_log_item functiions --- src/fosslight_source/convert_scancode.py | 10 ++++------ src/fosslight_source/run_scancode.py | 5 ++--- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/fosslight_source/convert_scancode.py b/src/fosslight_source/convert_scancode.py index 4130a3e..9faf178 100755 --- a/src/fosslight_source/convert_scancode.py +++ b/src/fosslight_source/convert_scancode.py @@ -11,7 +11,6 @@ import logging import fosslight_util.constant as constant from fosslight_util.set_log import init_log -from fosslight_util.set_log import init_log_item import yaml from ._parsing_scancode_file_item import parsing_file_item, get_error_from_header from fosslight_util.write_excel import write_excel_and_csv @@ -21,9 +20,8 @@ _PKG_NAME = "fosslight_source" -def convert_json_to_excel(scancode_json, excel_name): +def convert_json_to_excel(scancode_json, excel_name, _result_log): file_list = [] - _result_log = init_log_item(_PKG_NAME) msg = "" success = True @@ -117,9 +115,9 @@ def main(): oss_report_name = output_file_name output_dir = os.path.dirname(os.path.abspath(output_file_name)) - logger = init_log(os.path.join(output_dir, "fosslight_src_log_" + start_time + ".txt")) - - convert_json_to_excel(path_to_find_bin, oss_report_name) + logger, _result_log = init_log(os.path.join(output_dir, "fosslight_src_log_" + start_time + ".txt"), + True, logging.INFO, logging.DEBUG, _PKG_NAME) + convert_json_to_excel(path_to_find_bin, oss_report_name, _result_log) if __name__ == '__main__': diff --git a/src/fosslight_source/run_scancode.py b/src/fosslight_source/run_scancode.py index d85d304..58126b8 100755 --- a/src/fosslight_source/run_scancode.py +++ b/src/fosslight_source/run_scancode.py @@ -15,7 +15,6 @@ from datetime import datetime import fosslight_util.constant as constant from fosslight_util.set_log import init_log -from fosslight_util.set_log import init_log_item from fosslight_util.timer_thread import TimerThread from ._parsing_scancode_file_item import parsing_file_item from ._parsing_scancode_file_item import get_error_from_header @@ -76,8 +75,8 @@ def run_scan(path_to_scan, output_file_name="", output_json_file = output_file_name output_dir = os.path.dirname(os.path.abspath(output_file_name)) - logger = init_log(os.path.join(output_dir, "fosslight_src_log_"+start_time+".txt")) - _result_log = init_log_item(_PKG_NAME, path_to_scan) + logger = init_log(os.path.join(output_dir, "fosslight_src_log_"+start_time+".txt"), + True, logging.INFO, logging.DEBUG, _PKG_NAME, path_to_scan) if path_to_scan == "": if _windows: From 52613110a93d8f079b9cf9e5ae756b1719df09a6 Mon Sep 17 00:00:00 2001 From: Jaekwon Bang Date: Thu, 12 Aug 2021 16:03:55 +0900 Subject: [PATCH 2/4] Add missed second return variable --- src/fosslight_source/run_scancode.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fosslight_source/run_scancode.py b/src/fosslight_source/run_scancode.py index 58126b8..230edf6 100755 --- a/src/fosslight_source/run_scancode.py +++ b/src/fosslight_source/run_scancode.py @@ -75,7 +75,7 @@ def run_scan(path_to_scan, output_file_name="", output_json_file = output_file_name output_dir = os.path.dirname(os.path.abspath(output_file_name)) - logger = init_log(os.path.join(output_dir, "fosslight_src_log_"+start_time+".txt"), + logger, _result_log = init_log(os.path.join(output_dir, "fosslight_src_log_"+start_time+".txt"), True, logging.INFO, logging.DEBUG, _PKG_NAME, path_to_scan) if path_to_scan == "": From 16e46fb9e161d54b7b9f093a4ef132606e71f894 Mon Sep 17 00:00:00 2001 From: Soim Kim Date: Thu, 12 Aug 2021 16:08:40 +0900 Subject: [PATCH 3/4] Update fosslight_util functions --- src/fosslight_source/run_scancode.py | 2 +- tests/cli_test.py | 2 +- tox.ini | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/fosslight_source/run_scancode.py b/src/fosslight_source/run_scancode.py index 230edf6..d854df5 100755 --- a/src/fosslight_source/run_scancode.py +++ b/src/fosslight_source/run_scancode.py @@ -76,7 +76,7 @@ def run_scan(path_to_scan, output_file_name="", output_dir = os.path.dirname(os.path.abspath(output_file_name)) logger, _result_log = init_log(os.path.join(output_dir, "fosslight_src_log_"+start_time+".txt"), - True, logging.INFO, logging.DEBUG, _PKG_NAME, path_to_scan) + True, logging.INFO, logging.DEBUG, _PKG_NAME, path_to_scan) if path_to_scan == "": if _windows: diff --git a/tests/cli_test.py b/tests/cli_test.py index 20618b3..bf00d87 100755 --- a/tests/cli_test.py +++ b/tests/cli_test.py @@ -23,7 +23,7 @@ def main(): fosslight_report_name = "test_result_func_call/result" output_dir = os.path.dirname(os.path.abspath(output_file_name)) - logger = init_log(os.path.join(output_dir, "fosslight_src_log_"+start_time+".txt")) + logger, result_item = init_log(os.path.join(output_dir, "fosslight_src_log_"+start_time+".txt")) ret = run_scan(path_to_find_bin, fosslight_report_name, True, -1, True) diff --git a/tox.ini b/tox.ini index d774e6e..c90dd08 100644 --- a/tox.ini +++ b/tox.ini @@ -24,7 +24,7 @@ commands = cat test_scan/scan_result.csv fosslight_convert -p tests/json_result/scan_has_error.json -o test_convert/convert_result2 fosslight_convert -p test_scan/scan_result.json -o test_convert/convert_result - cat test_convert/convert_result.csv + cat test_convert/convert_result_SRC.csv python tests/cli_test.py [testenv:release] @@ -38,6 +38,6 @@ commands = cat test_scan/scan_result.csv fosslight_convert -p tests/json_result/scan_has_error.json -o test_convert/convert_result2 fosslight_convert -p test_scan/scan_result.json -o test_convert/convert_result - cat test_convert/convert_result.csv + cat test_convert/convert_result_SRC.csv python tests/cli_test.py pytest -v --flake8 From 1b0a0f4e732e00c9f827be1570d888b5c98ee5e0 Mon Sep 17 00:00:00 2001 From: Soim Kim Date: Thu, 12 Aug 2021 16:17:17 +0900 Subject: [PATCH 4/4] Update output file in tox --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index c90dd08..da3d272 100644 --- a/tox.ini +++ b/tox.ini @@ -35,7 +35,7 @@ commands = fosslight_source -h fosslight_convert -h fosslight_source -p tests/test_files -j -o test_scan/scan_result - cat test_scan/scan_result.csv + cat test_scan/scan_result_SRC.csv fosslight_convert -p tests/json_result/scan_has_error.json -o test_convert/convert_result2 fosslight_convert -p test_scan/scan_result.json -o test_convert/convert_result cat test_convert/convert_result_SRC.csv