Skip to content

Commit 12144fe

Browse files
JustinWonjaeParksoimkim
authored andcommitted
Amend to print output file name and deal with format option error
1 parent 68a3d64 commit 12144fe

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

src/fosslight_source/cli.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ def main():
8080

8181
start_time = datetime.now().strftime('%Y%m%d_%H%M%S')
8282
success, msg, output_path, output_file, output_extension = check_output_format(output_file_name, format)
83+
if not success:
84+
logger.error(f"Format error. {msg}")
85+
sys.exit(1)
8386
logger, _result_log = init_log(os.path.join(output_path, "fosslight_src_log_"+start_time+".txt"),
8487
True, logging.INFO, logging.DEBUG, _PKG_NAME, path_to_scan)
8588

@@ -143,11 +146,11 @@ def create_report_file(start_time, scanned_result, license_list, selected_scanne
143146
sheet_list["matched_text"] = get_license_list_to_print(license_list)
144147

145148
output_file_without_ext = os.path.join(output_path, output_file)
146-
success_to_write, writing_msg = write_output_file(output_file_without_ext, output_extension, sheet_list, extended_header)
147-
logger.info("Writing Output file(" + output_file + output_extension + "):"
148-
+ str(success_to_write) + " " + writing_msg)
149+
success_to_write, writing_msg, result_file = write_output_file(output_file_without_ext, output_extension, sheet_list, extended_header)
149150
if success_to_write:
150-
_result_log["Output file"] = output_file_without_ext + output_extension
151+
logger.info(f"Writing Output file({result_file}, success:{success_to_write}")
152+
else:
153+
logger.error(f"Fail to generate result file. msg:({writing_msg})")
151154

152155

153156
def run_all_scanners(path_to_scan, output_file_name="", _write_json_file=False, num_cores=-1,

src/fosslight_source/run_scancode.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,12 @@ def run_scan(path_to_scan, output_file_name="",
106106

107107
output_file_without_ext = os.path.join(output_path, output_file)
108108
if not called_by_cli:
109-
success_to_write, writing_msg = write_output_file(output_file_without_ext, output_extension,
109+
success_to_write, writing_msg, result_file= write_output_file(output_file_without_ext, output_extension,
110110
sheet_list)
111-
logger.info("Writing Output file(" + output_file + output_extension + "):" + str(success_to_write)
112-
+ " " + writing_msg)
113111
if success_to_write:
114-
_result_log["Output file"] = output_file_without_ext + output_extension
112+
logger.info(f"Writing Output file({result_file}, success:{success_to_write}")
113+
else:
114+
logger.error(f"Fail to generate result file. msg:({writing_msg})")
115115

116116
except Exception as ex:
117117
success = False

0 commit comments

Comments
 (0)