Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
click==6.7
scancode-toolkit<=21.3.31
typecode_libmagic
XlsxWriter
fosslight_util
PyYAML
PyYAML
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
if __name__ == "__main__":
setup(
name='fosslight_source',
version='1.4.4',
version='1.4.5',
package_dir={"": "src"},
packages=find_packages(where='src'),
description='FOSSLight Source',
Expand Down
9 changes: 6 additions & 3 deletions src/fosslight_source/run_scancode.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,18 @@ def main():
timer = TimerThread()
timer.setDaemon(True)
timer.start()
success, result_log = run_scan(_path_to_scan, _output_file, _write_json_file, -1)
run_scan(_path_to_scan, _output_file, _write_json_file, -1, False)


def run_scan(path_to_scan, output_file_name="",
_write_json_file=False, num_cores=-1):
_write_json_file=False, num_cores=-1, return_results=False):
global logger

success = True
msg = ""
_str_final_result_log = ""
_result_log = {}
result_list = []

_windows = platform.system() == "Windows"
start_time = datetime.now().strftime('%Y-%m-%d_%H-%M-%S')
Expand Down Expand Up @@ -128,6 +129,8 @@ def run_scan(path_to_scan, output_file_name="",
success = False
msg = _ERROR_PREFIX+"Check the path to scan. :" + path_to_scan+"\n"

if not return_results:
result_list = []
scan_result_msg = str(success)+" "+msg
_result_log["Scan Result"] = scan_result_msg.strip()
_result_log["Output Directory"] = output_dir
Expand All @@ -136,7 +139,7 @@ def run_scan(path_to_scan, output_file_name="",
logger.warn("\n"+_str_final_result_log)
except Exception as ex:
logger.warn(_ERROR_PREFIX+"Failed to print result log. "+ str(ex))
return success, _str_final_result_log
return success, _str_final_result_log, result_list


if __name__ == '__main__':
Expand Down
46 changes: 46 additions & 0 deletions test/cli_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2020 LG Electronics Inc.
# SPDX-License-Identifier: Apache-2.0

import getopt
import os
import sys
import json
from datetime import datetime
import logging
import fosslight_util.constant as constant
from fosslight_util.set_log import init_log
from fosslight_source.run_scancode import run_scan

logger = logging.getLogger(constant.LOGGER_NAME)


def main():
global logger

argv = sys.argv[1:]
path_to_find_bin = os.path.abspath("test/test")
start_time = datetime.now().strftime('%Y-%m-%d_%H-%M-%S')
output_file_name = ""

oss_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"))

ret = run_scan(path_to_find_bin, oss_report_name, True, -1, True)

logger.warn("[Scan] Result: %s" % (ret[0]))
logger.warn("[Scan] Result_msg: %s" % (ret[1]))

if len(ret) > 2:
try:
for scan_item in ret[2]:
logger.warn(scan_item.get_row_to_print())
except Exception as ex:
logger.error("Error:"+str(ex))


if __name__ == '__main__':
main()
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ commands =
cat test_scan/scan_result.csv
fosslight_convert -p test_scan/scan_result.json -o test_convert/convert_result
cat test_convert/convert_result.csv
python test/cli_test.py