Skip to content

Commit

Permalink
Adds verbose and fixes channel order
Browse files Browse the repository at this point in the history
  • Loading branch information
James-Crean committed Mar 21, 2018
1 parent a65539e commit ed1c80c
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions scripts/check_vcdat_update.py 100644 → 100755
Expand Up @@ -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(
Expand All @@ -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,
Expand All @@ -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",
Expand All @@ -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("<pip>")
if "<pip>" in channels:
channels.remove("<pip>")
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")
Expand All @@ -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)

0 comments on commit ed1c80c

Please sign in to comment.