diff --git a/scripts/check_vcdat_update.py b/scripts/check_vcdat_update.py old mode 100644 new mode 100755 index 3473470..d8cf396 --- a/scripts/check_vcdat_update.py +++ b/scripts/check_vcdat_update.py @@ -6,7 +6,7 @@ import subprocess -def run_command(cmd, stdin=None): +def run_command(cmd, stdin=None, verbose=False): commands = cmd.split("|") if len(commands) > 1: p = subprocess.Popen( @@ -17,6 +17,7 @@ def run_command(cmd, stdin=None): stdin=stdin) return run_command("|".join(commands[1:]), stdin=p.stdout) else: + if verbose: print("Excuting:",cmd) cmd = shlex.split(cmd) p = subprocess.Popen( cmd, @@ -38,6 +39,7 @@ def run_command(cmd, stdin=None): help="update env if needed") P.add_argument("-C", "--copy", action="store_true", default=False, help="create a copy of the environment before updating") +P.add_argument("-v", "--verbose", default=False, action="store_true", help="verbose mode") P.add_argument( "-c", "--channels", @@ -53,17 +55,18 @@ def run_command(cmd, stdin=None): # retrieve cdat channels used cmd = "conda list | grep cdat | awk '{print $NF}'" channels = run_command(cmd).split() -channels.remove("") +if "" in channels: + channels.remove("") if channels[0].find(":") != -1: channels.pop(0) channels = list(set(channels)) if "cdat/label/nightly" in channels: channels.remove("cdat/label/nightly") channels.insert(0, "cdat/label/nightly") -channels += P.channels +channels = P.channels + channels # Did the user send us more channels cmd = "conda update --dry-run vcs-js vcdat -c {}".format(" -c ".join(channels)) -result = run_command(cmd) +result = run_command(cmd, verbose=P.verbose) update = result.find("UPDATED") if update > -1: spl = result[update + 8:].split("\n") @@ -84,4 +87,4 @@ def run_command(cmd, stdin=None): if answer[0].lower() == "y": cmd = "conda update -y vcs-js vcdat -c {}".format( " -c ".join(channels)) - run_command(cmd) + run_command(cmd, verbose=P.verbose)