diff options
author | Vishwanatha Subbanna <vishwa@linux.vnet.ibm.com> | 2017-07-21 19:02:37 +0530 |
---|---|---|
committer | Vishwanatha Subbanna <vishwa@linux.vnet.ibm.com> | 2017-08-02 22:52:39 +0530 |
commit | 6add0b810bfd859ad21cb6b3f98b0bbfaa15aa62 (patch) | |
tree | 6ad789b4d8617d8b19f749c020a04e843bd647b4 /sensor_gen.py | |
parent | 5f031f3c722f0a4d10e562f5cfa54ba32d12958e (diff) | |
download | openpower-occ-control-6add0b810bfd859ad21cb6b3f98b0bbfaa15aa62.tar.gz openpower-occ-control-6add0b810bfd859ad21cb6b3f98b0bbfaa15aa62.zip |
Use generated occ to sensor ID map
Change-Id: I948cc33ef05c2c49353277f4d5df958012a9801f
Signed-off-by: Vishwanatha Subbanna <vishwa@linux.vnet.ibm.com>
Diffstat (limited to 'sensor_gen.py')
-rwxr-xr-x | sensor_gen.py | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/sensor_gen.py b/sensor_gen.py new file mode 100755 index 0000000..bedf4f8 --- /dev/null +++ b/sensor_gen.py @@ -0,0 +1,43 @@ +#!/usr/bin/env python + +import os +import yaml +import argparse +from mako.template import Template +import contextlib + +if __name__ == '__main__': + script_dir = os.path.dirname(os.path.realpath(__file__)) + parser = argparse.ArgumentParser() + parser.add_argument( + "-f", "--filename", + default='occ_sensor.yaml', + help="Input File Name") + parser.add_argument( + "-i", "--input-dir", + dest='inputdir', + default=script_dir, + help="Input directory") + + args = parser.parse_args() + + # Default to the one that is in the current. + yaml_dir = script_dir + yaml_file = os.path.join(yaml_dir, 'occ_sensor.yaml') + + if args.inputdir: + yaml_dir = args.inputdir + + if args.filename: + yaml_file = os.path.join(yaml_dir, args.filename) + + with open(yaml_file, 'r') as fd: + ifile = yaml.safe_load(fd) + + # Render the mako template + template = os.path.join(script_dir, 'occ_sensor.mako.hpp') + t = Template(filename=template) + with open('occ_sensor.hpp', 'w') as fd: + fd.write( + t.render( + occDict=ifile)) |