|
24 | 24 | warnings.filterwarnings("ignore", category=FutureWarning)
|
25 | 25 | _sheet_name = "SRC"
|
26 | 26 | _fosslight_report = "FOSSLight-Report"
|
| 27 | +_xlsx_extension = '.xlsx' |
| 28 | +_csv_extension = '.csv' |
27 | 29 |
|
28 | 30 |
|
29 | 31 | def find_package_manager():
|
@@ -57,8 +59,19 @@ def run_dependency_scanner(package_manager='', input_dir='', output_dir='', pip_
|
57 | 59 | global logger
|
58 | 60 |
|
59 | 61 | ret = True
|
| 62 | + output_filename = '' |
60 | 63 |
|
61 | 64 | if output_dir:
|
| 65 | + dirname = os.path.dirname(output_dir) |
| 66 | + basename = os.path.basename(output_dir) |
| 67 | + |
| 68 | + if basename.endswith(_xlsx_extension) or basename.endswith(_csv_extension): |
| 69 | + output_filename = os.path.splitext(basename)[0] |
| 70 | + if dirname: |
| 71 | + output_dir = dirname |
| 72 | + else: |
| 73 | + output_dir = os.getcwd() |
| 74 | + |
62 | 75 | if os.path.isdir(output_dir):
|
63 | 76 | output_dir = os.path.abspath(output_dir)
|
64 | 77 | else:
|
@@ -130,15 +143,19 @@ def run_dependency_scanner(package_manager='', input_dir='', output_dir='', pip_
|
130 | 143 | if ret:
|
131 | 144 | sheet_list[_sheet_name].extend(package_sheet_list)
|
132 | 145 |
|
133 |
| - output_filename = _fosslight_report + '_' + start_time |
| 146 | + if not output_filename: |
| 147 | + output_filename = _fosslight_report + '_' + start_time |
| 148 | + |
134 | 149 | if sheet_list is not None:
|
135 | 150 | success, msg = write_excel_and_csv(os.path.join(output_dir, output_filename), sheet_list)
|
136 | 151 | if success:
|
| 152 | + output_xlsx_name = output_filename + _xlsx_extension |
137 | 153 | if platform.system() == const.WINDOWS:
|
138 |
| - logger.info("Generated {0}.xlsx into {1}!".format(output_filename, output_dir)) |
| 154 | + logger.info("Generated {0} into {1}!".format(output_xlsx_name, output_dir)) |
139 | 155 | else:
|
140 |
| - logger.info("Generated {0}.xlsx and {0}.csv into {1}!" |
141 |
| - .format(output_filename, output_dir)) |
| 156 | + output_csv_name = output_filename + '_' + _sheet_name + _csv_extension |
| 157 | + logger.info("Generated {0} and {1} into {2}!" |
| 158 | + .format(output_xlsx_name, output_csv_name, output_dir)) |
142 | 159 | else:
|
143 | 160 | ret = False
|
144 | 161 | logger.error("Fail to generate result file. msg:()" + msg)
|
|
0 commit comments