generate_config: Check yaml arg is really a file 21/51221/1
authorAlexandru Avadanii <Alexandru.Avadanii@enea.com>
Fri, 26 Jan 2018 20:32:07 +0000 (21:32 +0100)
committerAlexandru Avadanii <Alexandru.Avadanii@enea.com>
Fri, 26 Jan 2018 20:45:10 +0000 (21:45 +0100)
In order to support bash process substition, e.g.
$ ./generate_config.py -j /path/to/template.j2 -y <(echo stuff);
do not consume the contents of ARGS.yaml unless it is a file.

Change-Id: I89053cfaadc158f6a15f85836892b21980081772
Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
config/utils/generate_config.py

index 5dbdb7d..b2b52f0 100755 (executable)
@@ -65,7 +65,7 @@ ENV.filters['dpkg_arch'] = dpkg_arch
 # Run `eyaml decrypt` on the whole file, but only if PDF data is encrypted
 # Note: eyaml return code is 0 even if keys are not available
 try:
-    if 'ENC[PKCS7' in open(ARGS.yaml).read():
+    if os.path.isfile(ARGS.yaml) and 'ENC[PKCS7' in open(ARGS.yaml).read():
         DICT = yaml.safe_load(check_output(['eyaml', 'decrypt',
                                             '-f', ARGS.yaml]))
 except CalledProcessError as ex: