diff options
author | Joseph Hunkeler <jhunkeler@gmail.com> | 2018-01-27 14:43:19 -0500 |
---|---|---|
committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2018-01-27 14:43:19 -0500 |
commit | 8e885359f4959036720632e2e075bf4d56d9f3a5 (patch) | |
tree | 2110977f75b20368a61b3a002805bc08c3d4fd8e | |
parent | b35d9586dbb35d79f83d066153ae460b25dc82d4 (diff) | |
download | groovy-sandbox-8e885359f4959036720632e2e075bf4d56d9f3a5.tar.gz |
Too much vodka, still
-rw-r--r-- | src/edu/stsci/CondaInstaller.groovy | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/edu/stsci/CondaInstaller.groovy b/src/edu/stsci/CondaInstaller.groovy index 27f1b06..0b320b2 100644 --- a/src/edu/stsci/CondaInstaller.groovy +++ b/src/edu/stsci/CondaInstaller.groovy @@ -3,6 +3,7 @@ import edu.stsci.OSInfo class CondaInstaller implements Serializable { OSInfo os + public Map<String, String> shell_environment private String ident String prefix String dist_version @@ -25,11 +26,40 @@ class CondaInstaller implements Serializable { this.dist = distributions."${dist}" this.dist_version = version this.prefix = prefix + this.shell_environment = [:] this.installer = "${this.dist.name}${this.dist.variant}-" + "${this.dist_version}-${this.os.name}-${this.os.arch}.sh" this.url = "${this.dist.baseurl}/" + this.installer } + private def runshell(String args, silent=false) { + def cmd = new String[3] + def proc_env = [:] + + if (this.shell_environment) { + proc_env = this.shell_environment + } + + cmd[0] = 'bash' + cmd[1] = '-c' + cmd[2] = args + + def process = new ProcessBuilder(cmd) + process.redirectErrorStream(true) + Map<String, String> env_tmp = process.environment() + + if (proc_env) { + env_tmp <<= proc_env + } + + Process p = process.start() + if (!silent) { + p.inputStream.eachLine { println it} + } + p.waitFor() + return p + } + int download() { println("${this.ident} Downloading $url") def proc = ["bash", "-c", "curl -sLO ${this.url}"].execute() |