From: Alexandru Avadanii Date: Fri, 26 Jan 2018 20:32:07 +0000 (+0100) Subject: generate_config: Check yaml arg is really a file X-Git-Tag: 6.0.0~13 X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=commitdiff_plain;h=afed939379a5870cbbdf3bcb4d0ce8a4ebd789a5;p=pharos.git generate_config: Check yaml arg is really a file 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 --- diff --git a/config/utils/generate_config.py b/config/utils/generate_config.py index 5dbdb7d1..b2b52f0b 100755 --- a/config/utils/generate_config.py +++ b/config/utils/generate_config.py @@ -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: