diff options
author | Vincent Guittot <vincent.guittot@linaro.org> | 2014-09-19 09:03:51 -0700 |
---|---|---|
committer | Vincent Guittot <vincent.guittot@linaro.org> | 2014-09-24 11:24:25 +0200 |
commit | 50fea4febace8ad7504a6a1d31f212148fd3922d (patch) | |
tree | fa730d87c82f575b629af70d593f182e2ec0679b /doc | |
parent | 79d4a9768a129cf9a5c6655177c1f06aac059a6a (diff) |
rename check_id into workgen
check unique key in the json file and call rt-app with the output file
Diffstat (limited to 'doc')
-rwxr-xr-x | doc/workgen (renamed from doc/check-id.py) | 75 |
1 files changed, 46 insertions, 29 deletions
diff --git a/doc/check-id.py b/doc/workgen index 91f1982..7bef6e8 100755 --- a/doc/check-id.py +++ b/doc/workgen @@ -3,45 +3,27 @@ import os import sys import getopt +import subprocess +import signal -outfile = "unikid.json" -selfupdate = 0 -verbose = 0 - -try: - opts, args = getopt.getopt(sys.argv[1:], "o:av") -except getopt.GetoptError as err: - print str(err) # will print something like "option -a not recognized" - sys.exit(2) - -for o, a in opts: - if o == "-o": - outfile = a - if o == "-a": - selfupate = 1 - if o == "-v": - verbose = 1 - -for f in args: - if not os.path.exists(f): - print "WARN: %s does not exist", f +def check_unikid_json(infile, outfile, verbose=0): + if not os.path.exists(infile): + print "WARN: %s does not exist", infile try: - fp = open(f, "r") + fi = open(infile, "r") except IOError: - print "WARN: Unable to open %s", f + print "WARN: Unable to open %s", infile sys.exit(2) - if selfupdate: - outfile = f try: fo = open(outfile, "w+") except IOError: print "WARN: Unable to open %s", f sys.exit(2) - lines = fp.readlines() - fp.close() + lines = fi.readlines() + fi.close() curid = 1 refcount = 0 @@ -90,8 +72,43 @@ for f in args: fo.write(myline) -fp.close() -fo.close() + fo.close() + + return + +if __name__ == '__main__': + + def handleSigTERM(signum, frame): + sys.exit + + signal.signal(signal.SIGTERM, handleSigTERM) + signal.signal(signal.SIGINT, handleSigTERM) + + outfile = "unikid.json" + selfupdate = 0 + verbose = 0 + + try: + opts, args = getopt.getopt(sys.argv[1:], "o:av") + except getopt.GetoptError as err: + print str(err) # will print something like "option -a not recognized" + sys.exit(2) + + for o, a in opts: + if o == "-o": + outfile = a + if o == "-a": + selfupate = 1 + if o == "-v": + verbose = 1 + + if selfupdate: + outfile = f + + for f in args: + check_unikid_json(f, outfile) + + subprocess.call(["rt-app", outfile]) |