21
21
if platform .system () != 'Windows' :
22
22
from fosslight_util .write_spdx import write_spdx
23
23
from fosslight_util .cover import CoverItem
24
+ from fosslight_dependency ._graph_convertor import GraphConvertor
24
25
25
26
# Package Name
26
27
_PKG_NAME = "fosslight_dependency"
@@ -92,7 +93,8 @@ def find_package_manager(input_dir, abs_path_to_exclude=[]):
92
93
93
94
def run_dependency_scanner (package_manager = '' , input_dir = '' , output_dir_file = '' , pip_activate_cmd = '' ,
94
95
pip_deactivate_cmd = '' , output_custom_dir = '' , app_name = const .default_app_name ,
95
- github_token = '' , formats = [], direct = True , path_to_exclude = []):
96
+ github_token = '' , formats = [], direct = True , path_to_exclude = [], graph_path = '' ,
97
+ graph_size = (600 , 600 )):
96
98
global logger
97
99
98
100
ret = True
@@ -233,6 +235,15 @@ def run_dependency_scanner(package_manager='', input_dir='', output_dir_file='',
233
235
if cover_comment :
234
236
cover .comment += f', { cover_comment } '
235
237
238
+ if ret and graph_path :
239
+ graph_path = os .path .abspath (graph_path )
240
+ try :
241
+ converter = GraphConvertor (sheet_list [_sheet_name ])
242
+ converter .save (graph_path , graph_size )
243
+ logger .info (f"Output graph image file: { graph_path } " )
244
+ except Exception as e :
245
+ logger .error (f'Fail to make graph image: { e } ' )
246
+
236
247
combined_paths_and_files = [os .path .join (output_path , file ) for file in output_files ]
237
248
results = []
238
249
for i , output_extension in enumerate (output_extensions ):
@@ -276,6 +287,8 @@ def main():
276
287
app_name = const .default_app_name
277
288
github_token = ''
278
289
format = ''
290
+ graph_path = ''
291
+ graph_size = (600 , 600 )
279
292
direct = True
280
293
281
294
parser = argparse .ArgumentParser (add_help = False )
@@ -291,6 +304,8 @@ def main():
291
304
parser .add_argument ('-n' , '--appname' , nargs = 1 , type = str , required = False )
292
305
parser .add_argument ('-t' , '--token' , nargs = 1 , type = str , required = False )
293
306
parser .add_argument ('-f' , '--format' , nargs = "*" , type = str , required = False )
307
+ parser .add_argument ('--graph-path' , nargs = 1 , type = str , required = False )
308
+ parser .add_argument ('--graph-size' , nargs = 2 , type = int , metavar = ("WIDTH" , "HEIGHT" ), required = False )
294
309
parser .add_argument ('--direct' , choices = ('true' , 'false' ), default = 'True' , required = False )
295
310
parser .add_argument ('--notice' , action = 'store_true' , required = False )
296
311
@@ -324,6 +339,10 @@ def main():
324
339
github_token = '' .join (args .token )
325
340
if args .format : # -f option
326
341
format = list (args .format )
342
+ if args .graph_path :
343
+ graph_path = '' .join (args .graph_path )
344
+ if args .graph_size :
345
+ graph_size = args .graph_size
327
346
if args .direct : # --direct option
328
347
if args .direct == 'true' :
329
348
direct = True
@@ -343,7 +362,8 @@ def main():
343
362
sys .exit (0 )
344
363
345
364
run_dependency_scanner (package_manager , input_dir , output_dir , pip_activate_cmd , pip_deactivate_cmd ,
346
- output_custom_dir , app_name , github_token , format , direct , path_to_exclude )
365
+ output_custom_dir , app_name , github_token , format , direct , path_to_exclude ,
366
+ graph_path , graph_size )
347
367
348
368
349
369
if __name__ == '__main__' :
0 commit comments