Skip to content

Commit 003ba4c

Browse files
committed
Add returning item parameter
1 parent 3e396d6 commit 003ba4c

File tree

4 files changed

+50
-4
lines changed

4 files changed

+50
-4
lines changed

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
if __name__ == "__main__":
1515
setup(
1616
name='fosslight_source',
17-
version='1.4.4',
17+
version='1.4.5',
1818
package_dir={"": "src"},
1919
packages=find_packages(where='src'),
2020
description='FOSSLight Source',

src/fosslight_source/run_scancode.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,18 @@ def main():
5656
timer = TimerThread()
5757
timer.setDaemon(True)
5858
timer.start()
59-
success, result_log = run_scan(_path_to_scan, _output_file, _write_json_file, -1)
59+
run_scan(_path_to_scan, _output_file, _write_json_file, -1, False)
6060

6161

6262
def run_scan(path_to_scan, output_file_name="",
63-
_write_json_file=False, num_cores=-1):
63+
_write_json_file=False, num_cores=-1, return_results=False):
6464
global logger
6565

6666
success = True
6767
msg = ""
6868
_str_final_result_log = ""
6969
_result_log = {}
70+
results = {}
7071

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

132+
if not return_results:
133+
results = {}
131134
scan_result_msg = str(success)+" "+msg
132135
_result_log["Scan Result"] = scan_result_msg.strip()
133136
_result_log["Output Directory"] = output_dir
@@ -136,7 +139,7 @@ def run_scan(path_to_scan, output_file_name="",
136139
logger.warn("\n"+_str_final_result_log)
137140
except Exception as ex:
138141
logger.warn(_ERROR_PREFIX+"Failed to print result log. "+ str(ex))
139-
return success, _str_final_result_log
142+
return success, _str_final_result_log, results
140143

141144

142145
if __name__ == '__main__':

test/cli_test.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
# Copyright (c) 2020 LG Electronics Inc.
4+
# SPDX-License-Identifier: Apache-2.0
5+
6+
import getopt
7+
import os
8+
import sys
9+
import json
10+
from datetime import datetime
11+
import logging
12+
import fosslight_util.constant as constant
13+
from fosslight_util.set_log import init_log
14+
from fosslight_source.run_scancode import run_scan
15+
16+
logger = logging.getLogger(constant.LOGGER_NAME)
17+
18+
19+
def main():
20+
global logger
21+
22+
argv = sys.argv[1:]
23+
path_to_find_bin = os.path.abspath("test/test")
24+
start_time = datetime.now().strftime('%Y-%m-%d_%H-%M-%S')
25+
output_file_name = ""
26+
27+
oss_report_name = "test_result_func_call/result"
28+
output_dir = os.path.dirname(os.path.abspath(output_file_name))
29+
30+
logger = init_log(os.path.join(output_dir, "fosslight_src_log_"+start_time+".txt"))
31+
32+
ret = run_scan(path_to_find_bin, oss_report_name, True, -1, True)
33+
34+
logger.warn("[Scan] Result: %s" % (ret[0]))
35+
logger.warn("[Scan] Result_msg: %s" % (ret[1]))
36+
37+
if len(ret) > 2:
38+
logger.warn("[Scan] Result_items: %s" % (str(ret[2])))
39+
40+
41+
if __name__ == '__main__':
42+
main()

tox.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@ commands =
1616
cat test_scan/scan_result.csv
1717
fosslight_convert -p test_scan/scan_result.json -o test_convert/convert_result
1818
cat test_convert/convert_result.csv
19+
python test/cli_test.py

0 commit comments

Comments
 (0)