summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Guittot <vincent.guittot@linaro.org>2014-09-19 09:03:51 -0700
committerVincent Guittot <vincent.guittot@linaro.org>2014-09-24 11:24:25 +0200
commit50fea4febace8ad7504a6a1d31f212148fd3922d (patch)
treefa730d87c82f575b629af70d593f182e2ec0679b
parent79d4a9768a129cf9a5c6655177c1f06aac059a6a (diff)
rename check_id into workgen
check unique key in the json file and call rt-app with the output file
-rwxr-xr-xdoc/workgen (renamed from doc/check-id.py)75
-rw-r--r--src/Makefile.am2
2 files changed, 47 insertions, 30 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])
diff --git a/src/Makefile.am b/src/Makefile.am
index 600d468..ca734d2 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -4,4 +4,4 @@ bin_PROGRAMS = rt-app
rt_app_SOURCES= rt-app_types.h rt-app_args.h rt-app_utils.h rt-app_utils.c rt-app_args.c rt-app.h rt-app.c
rt_app_SOURCES += rt-app_parse_config.h rt-app_parse_config.c
rt_app_LDADD = $(QRESLIB) ../libdl/libdl.a $(LIBJSON)
-
+dist_bin_SCRIPTS = $(srcdir)/../doc/workgen