From bbb132414c4ac4659680f11d1c82461ac3441732 Mon Sep 17 00:00:00 2001 From: "Joshua M. Boniface" Date: Wed, 23 Jun 2021 05:26:50 -0400 Subject: [PATCH] Restore shebang and don't do store if completion --- client-cli/pvc/pvc.py | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/client-cli/pvc/pvc.py b/client-cli/pvc/pvc.py index 784bcca7..63a477c0 100755 --- a/client-cli/pvc/pvc.py +++ b/client-cli/pvc/pvc.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python3 + # pvc.py - PVC client command-line interface # Part of the Parallel Virtual Cluster (PVC) system # @@ -42,6 +44,7 @@ import pvc.cli_lib.provisioner as pvc_provisioner myhostname = socket.gethostname().split('.')[0] zk_host = '' +is_completion = True if os.environ.get('_PVC_COMPLETE', '') == 'complete' else False default_store_data = { 'cfgfile': '/etc/pvc/pvcapid.yaml' @@ -131,20 +134,21 @@ def update_store(store_path, store_data): fh.write(json.dumps(store_data, sort_keys=True, indent=4)) -pvc_client_dir = os.environ.get('PVC_CLIENT_DIR', None) -home_dir = os.environ.get('HOME', None) -if pvc_client_dir: - store_path = '{}'.format(pvc_client_dir) -elif home_dir: - store_path = '{}/.config/pvc'.format(home_dir) -else: - print('WARNING: No client or home config dir found, using /tmp instead') - store_path = '/tmp/pvc' +if not is_completion: + pvc_client_dir = os.environ.get('PVC_CLIENT_DIR', None) + home_dir = os.environ.get('HOME', None) + if pvc_client_dir: + store_path = '{}'.format(pvc_client_dir) + elif home_dir: + store_path = '{}/.config/pvc'.format(home_dir) + else: + print('WARNING: No client or home config dir found, using /tmp instead') + store_path = '/tmp/pvc' -if not os.path.isdir(store_path): - os.makedirs(store_path) -if not os.path.isfile(store_path + '/pvc-cli.json'): - update_store(store_path, {"local": default_store_data}) + if not os.path.isdir(store_path): + os.makedirs(store_path) + if not os.path.isfile(store_path + '/pvc-cli.json'): + update_store(store_path, {"local": default_store_data}) CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help'], max_content_width=120)