Skip to content

Commit ffe4950

Browse files
authored
Merge pull request #93 from fosslight/develop_filename
Change the output file name
2 parents 38cd581 + c7ff7c4 commit ffe4950

File tree

6 files changed

+21
-28
lines changed

6 files changed

+21
-28
lines changed

src/fosslight_source/cli.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,12 @@ def main():
8383
timer.setDaemon(True)
8484
timer.start()
8585

86-
start_time = datetime.now().strftime('%Y%m%d_%H%M%S')
86+
_start_time = datetime.now().strftime('%y%m%d_%H%M')
8787
success, msg, output_path, output_file, output_extension = check_output_format(output_file_name, format)
8888
if not success:
8989
logger.error(f"Format error. {msg}")
9090
sys.exit(1)
91-
logger, _result_log = init_log(os.path.join(output_path, "fosslight_src_log_"+start_time+".txt"),
91+
logger, _result_log = init_log(os.path.join(output_path, f"fosslight_log_{_start_time}.txt"),
9292
True, logging.INFO, logging.DEBUG, _PKG_NAME, path_to_scan)
9393

9494
if os.path.isdir(path_to_scan):
@@ -107,7 +107,7 @@ def main():
107107
else:
108108
print_help_msg_source()
109109
sys.exit(1)
110-
create_report_file(start_time, scanned_result, license_list, selected_scanner, print_matched_text,
110+
create_report_file(_start_time, scanned_result, license_list, selected_scanner, print_matched_text,
111111
output_path, output_file, output_extension)
112112
try:
113113
logger.info(yaml.safe_dump(_result_log, allow_unicode=True, sort_keys=True))
@@ -118,7 +118,7 @@ def main():
118118
sys.exit(1)
119119

120120

121-
def create_report_file(start_time, scanned_result, license_list, selected_scanner, need_license=False,
121+
def create_report_file(_start_time, scanned_result, license_list, selected_scanner, need_license=False,
122122
output_path="", output_file="", output_extension=""):
123123
"""
124124
Create report files for given scanned result.
@@ -131,7 +131,6 @@ def create_report_file(start_time, scanned_result, license_list, selected_scanne
131131
extended_header = {}
132132
sheet_list = {}
133133
_json_ext = ".json"
134-
_yaml_ext = ".yaml"
135134

136135
if output_path == "":
137136
output_path = os.getcwd()
@@ -140,11 +139,9 @@ def create_report_file(start_time, scanned_result, license_list, selected_scanne
140139

141140
if output_file == "":
142141
if output_extension == _json_ext:
143-
output_file = f"Opossum_input_{start_time}"
144-
if output_extension == _yaml_ext:
145-
output_file = f"fosslight-sbom-info_{start_time}"
142+
output_file = f"fosslight_opossum_{_start_time}"
146143
else:
147-
output_file = f"FOSSLight-Report_{start_time}"
144+
output_file = f"fosslight_report_{_start_time}"
148145

149146
if scanned_result:
150147
scanned_result = sorted(scanned_result, key=lambda row: (''.join(row.licenses)))

src/fosslight_source/convert_scancode.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@ def convert_json_to_output_report(scancode_json, output_file_name, need_license=
4242

4343
if output_file == "":
4444
if output_extension == _json_ext:
45-
output_file = "Opossum_input_" + start_time
45+
output_file = "fosslight_opossum_" + start_time
4646
else:
47-
output_file = "FOSSLight-Report_" + start_time
47+
output_file = "fosslight_report_" + start_time
4848
else:
4949
output_path = os.getcwd()
5050

51-
logger, result_log = init_log(os.path.join(output_path, "fosslight_src_log_" + start_time + ".txt"),
51+
logger, result_log = init_log(os.path.join(output_path, "fosslight_log_" + start_time + ".txt"),
5252
True, logging.INFO, logging.DEBUG, _PKG_NAME)
5353
if not success:
5454
logger.error("Fail to convert scancode: " + msg)

src/fosslight_source/run_scancode.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,7 @@ def run_scan(path_to_scan, output_file_name="",
3535
result_list = []
3636
license_list = []
3737
_json_ext = ".json"
38-
_yaml_ext = ".yaml"
39-
40-
start_time = datetime.now().strftime('%Y%m%d_%H%M%S')
38+
_start_time = datetime.now().strftime('%y%m%d_%H%M')
4139

4240
success, msg, output_path, output_file, output_extension = check_output_format(output_file_name, format)
4341
if success:
@@ -49,19 +47,17 @@ def run_scan(path_to_scan, output_file_name="",
4947
if not called_by_cli:
5048
if output_file == "":
5149
if output_extension == _json_ext:
52-
output_file = f"Opossum_input_{start_time}"
53-
elif output_extension == _yaml_ext:
54-
output_file = f"fosslight-sbom-info_{start_time}"
50+
output_file = f"fosslight_opossum_{_start_time}"
5551
else:
56-
output_file = f"FOSSLight-Report_{start_time}"
52+
output_file = f"fosslight_report_{_start_time}"
5753

5854
if _write_json_file:
5955
output_json_file = os.path.join(output_path, "scancode_raw_result.json")
6056
else:
6157
output_json_file = ""
6258

6359
if not called_by_cli:
64-
logger, _result_log = init_log(os.path.join(output_path, f"fosslight_src_log_{start_time}.txt"),
60+
logger, _result_log = init_log(os.path.join(output_path, f"fosslight_log_{_start_time}.txt"),
6561
True, logging.INFO, logging.DEBUG, _PKG_NAME, path_to_scan)
6662

6763
num_cores = multiprocessing.cpu_count() - 1 if num_cores < 0 else num_cores

src/fosslight_source/run_scanoss.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ def run_scanoss_py(path_to_scan, output_file_name="", format="", called_by_cli=F
4444

4545
if not called_by_cli:
4646
global logger
47-
start_time = datetime.now().strftime('%Y%m%d_%H%M%S')
48-
logger, _result_log = init_log(os.path.join(output_path, f"fosslight_src_log_{start_time}.txt"),
47+
_start_time = datetime.now().strftime('%y%m%d_%H%M')
48+
logger, _result_log = init_log(os.path.join(output_path, f"fosslight_log_{_start_time}.txt"),
4949
True, logging.INFO, logging.DEBUG, _PKG_NAME, path_to_scan)
5050

5151
scanoss_file_list = []

tests/cli_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ def main():
1717
global logger
1818

1919
path_to_find_bin = os.path.abspath("tests/test_files/test")
20-
start_time = datetime.now().strftime('%Y-%m-%d_%H-%M-%S')
20+
_start_time = datetime.now().strftime('%y%m%d_%H%M')
2121
output_file_name = ""
2222

2323
fosslight_report_name = "test_result_func_call/result"
2424
output_dir = os.path.dirname(os.path.abspath(output_file_name))
2525

26-
logger, result_item = init_log(os.path.join(output_dir, "fosslight_src_log_"+start_time+".txt"))
26+
logger, result_item = init_log(os.path.join(output_dir, "fosslight_log_"+_start_time+".txt"))
2727

2828
ret = run_all_scanners(path_to_find_bin, fosslight_report_name, True, -1, True, "", False)
2929

tests/test_files/run_scancode.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,18 +67,18 @@ def run_scan(path_to_scan, output_file_name="",
6767
result_list = []
6868

6969
_windows = platform.system() == "Windows"
70-
start_time = datetime.now().strftime('%Y%m%d_%H%M%S')
70+
_start_time = datetime.now().strftime('%y%m%d_%H%M')
7171

7272
if output_file_name == "":
73-
output_file = f"FOSSLight-Report_{start_time}"
74-
output_json_file = f"scancode_{start_time}"
73+
output_file = f"fosslight_report_{_start_time}"
74+
output_json_file = f"scancode_{_start_time}"
7575
output_dir = os.getcwd()
7676
else:
7777
output_file = output_file_name
7878
output_json_file = output_file_name
7979
output_dir = os.path.dirname(os.path.abspath(output_file_name))
8080

81-
logger, _result_log = init_log(os.path.join(output_dir, f"fosslight_src_log_{start_time}.txt"),
81+
logger, _result_log = init_log(os.path.join(output_dir, f"fosslight_log_{_start_time}.txt"),
8282
True, logging.INFO, logging.DEBUG, _PKG_NAME, path_to_scan)
8383

8484
if path_to_scan == "":

0 commit comments

Comments
 (0)