Skip to content

Commit

Permalink
Add engine option to graph generation (#476)
Browse files Browse the repository at this point in the history
  • Loading branch information
aarontp committed Dec 9, 2019
1 parent 598898c commit 37fbc99
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions tools/turbinia_job_graph.py
@@ -1,4 +1,4 @@
#!/usr/bin/env python -v #!/usr/bin/env python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright 2018 Google Inc. # Copyright 2018 Google Inc.
# #
Expand Down Expand Up @@ -54,16 +54,36 @@ def create_graph():
description='Create Turbinia evidence graph.') description='Create Turbinia evidence graph.')
parser.add_argument( parser.add_argument(
'-f', '--format', default='png', '-f', '--format', default='png',
help='The format of the output file you wish to generate. Supported ' help='The format of the output file you wish to generate. Specify '
'types are here: http://www.graphviz.org/doc/info/output.html') '"list" to list out the available output types. More info is here: '
'http://www.graphviz.org/doc/info/output.html')
parser.add_argument(
'-e', '--engine', default='dot',
help='The graphviz engine used to generate the graph layout. Specify '
'"list" to list out the available engines.')
parser.add_argument('filename', type=unicode, help='where to save the file') parser.add_argument('filename', type=unicode, help='where to save the file')
args = parser.parse_args() args = parser.parse_args()


if args.format == 'list':
formats = ' '.join(graphviz.FORMATS)
print('Available format types: {0:s}'.format(formats))
sys.exit(0)

if args.format not in graphviz.FORMATS: if args.format not in graphviz.FORMATS:
print('Format type {0:s} is not supported'.format(args.format)) print('Format type {0:s} is not supported'.format(args.format))
sys.exit(1) sys.exit(1)


if args.engine == 'list':
engines = ' '.join(graphviz.ENGINES)
print('Available graph layout engines: {0:s}'.format(engines))
sys.exit(0)

if args.engine not in graphviz.ENGINES:
print('Layout engine type {0:s} is not supported'.format(args.engine))
sys.exit(1)

graph = create_graph() graph = create_graph()
graph.engine = args.engine
output_file = args.filename.replace('.png', '') output_file = args.filename.replace('.png', '')


try: try:
Expand Down

0 comments on commit 37fbc99

Please sign in to comment.