O'Reilly logo

JUNOS Automation Cookbook by Adam Chappell

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Instantiating the template

Produce a simplistic Python template instantiation tool, render-graph.py, that will combine a graph.json file with a graph.html.template file in order to produce a final graph.html file.

#!/usr/bin/env pythonimport sysimport argparseimport osimport iofrom string import Template# Error handlingdef onError(exception_type, exception, traceback):    print "%s: %s" % (exception_type.__name__, exception)sys.excepthook = onErrorcmdline = argparse.ArgumentParser(description="Python Graph processor")cmdline.add_argument("graph", help="JSON file describing graph")cmdline.add_argument("-t", metavar="template", help="Template file",                             default="graph.html.template")cmdline.add_argument("-o", metavar="output filename", help="File ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required