diff options
author | Joseph Hunkeler <jhunkeler@gmail.com> | 2015-06-26 00:59:48 -0400 |
---|---|---|
committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2015-06-26 00:59:48 -0400 |
commit | 973725aa1985ca4fab62bff0afe29a8fb8f96b6d (patch) | |
tree | c33587e5969ddafc73e3ad505b7870106f498fd9 /cbc | |
parent | 1b865a917491370d89a3c3c8259520b5e243de30 (diff) | |
download | cbc-973725aa1985ca4fab62bff0afe29a8fb8f96b6d.tar.gz |
Initial commit of utils.py
Diffstat (limited to 'cbc')
-rw-r--r-- | cbc/utils.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/cbc/utils.py b/cbc/utils.py new file mode 100644 index 0000000..096e156 --- /dev/null +++ b/cbc/utils.py @@ -0,0 +1,30 @@ +from subprocess import Popen, PIPE, check_output, CalledProcessError + + +def conda_search(pkgname): + command = ['conda', 'list', pkgname] + proc = Popen(command, stdout=PIPE) + out, _ = proc.communicate() + + for line in out.decode('utf-8').splitlines(): + if line.startswith('#'): + continue + line = line.split(); + break + + if not line: + return '' + + return '-'.join(line) + + +def conda_install(pkgname): + # Until I can figure out a good way to build with the conda API + # we'll use the CLI interface: + command = 'conda install --use-local --yes {0}'.format(pkgname).split() + try: + for line in (check_output(command).decode('utf-8').splitlines()): + print(line) + except CalledProcessError as cpe: + print('{0}\nexit={1}'.format(' '.join(cpe.cmd), cpe.returncode)) +
\ No newline at end of file |