Skip to content

Commit

Permalink
Merge init_log & init_log_item functions
Browse files Browse the repository at this point in the history
  • Loading branch information
soimkim authored Aug 12, 2021
2 parents f12514a + 1b0a0f4 commit 5d679ba
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 13 deletions.
10 changes: 4 additions & 6 deletions src/fosslight_source/convert_scancode.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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__':
Expand Down
5 changes: 2 additions & 3 deletions src/fosslight_source/run_scancode.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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, _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 == "":
if _windows:
Expand Down
2 changes: 1 addition & 1 deletion tests/cli_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
6 changes: 3 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -35,9 +35,9 @@ 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.csv
cat test_convert/convert_result_SRC.csv
python tests/cli_test.py
pytest -v --flake8

0 comments on commit 5d679ba

Please sign in to comment.