Skip to content

Commit a0fe9a7

Browse files
committed
Print the extension to the output file of the result log
1 parent 0205a7e commit a0fe9a7

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

src/fosslight_binary/binary_analysis.py

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
_error_logs = []
4040
_root_path = ""
4141
_start_time = ""
42+
windows = False
4243

4344

4445
def init(path_to_find_bin, output_file_name, format):
@@ -129,6 +130,8 @@ def find_binaries(path_to_find_bin, output_dir, format, dburl=""):
129130
total_bin_cnt = 0
130131
total_file_cnt = 0
131132
db_loaded_cnt = 0
133+
success_to_write = False
134+
writing_msg = ""
132135

133136
try:
134137
if not os.path.isdir(path_to_find_bin):
@@ -166,14 +169,25 @@ def find_binaries(path_to_find_bin, output_dir, format, dburl=""):
166169

167170
success_to_write, writing_msg = write_output_file(result_report, output_extension,
168171
sheet_list)
169-
logger.info("Writing Output file(" + os.path.basename(result_report) + output_extension
170-
+ "):" + str(success_to_write) + " " + writing_msg)
171-
if success_to_write:
172-
_result_log["Output file"] = result_report + output_extension
173-
174172
except Exception as ex:
175173
error_occured(error_msg=str(ex), exit=False)
176174

175+
# Print Result
176+
try:
177+
output_files = []
178+
if output_extension == "":
179+
output_extension = ".xlsx"
180+
if not windows:
181+
output_files.append(f"{result_report}.csv")
182+
output_files.insert(0, f"{result_report}{output_extension}")
183+
184+
logger.info(f"Writing Output file ({output_files[0]}"
185+
f"):{success_to_write} {writing_msg}")
186+
if success_to_write:
187+
_result_log["Output file"] = output_files
188+
except Exception as ex:
189+
error_occured(error_msg=f"Print log:{ex}", exit=False)
190+
177191
print_result_log(success=True, result_log=_result_log,
178192
file_cnt=str(total_file_cnt), bin_file_cnt=str(total_bin_cnt),
179193
auto_bin_cnt=str(db_loaded_cnt))
@@ -241,6 +255,7 @@ def print_result_log(success=True, result_log={}, file_cnt="", bin_file_cnt="",
241255

242256

243257
def main():
258+
global windows
244259
argv = sys.argv[1:]
245260
output_dir = ""
246261
path_to_find_bin = ""
@@ -265,9 +280,9 @@ def main():
265280
except Exception:
266281
print_help_msg()
267282

268-
_windows = platform.system() == "Windows"
283+
windows = platform.system() == "Windows"
269284
if path_to_find_bin == "":
270-
if _windows:
285+
if windows:
271286
path_to_find_bin = os.getcwd()
272287
else:
273288
print_help_msg()

0 commit comments

Comments
 (0)