From 8e885359f4959036720632e2e075bf4d56d9f3a5 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Sat, 27 Jan 2018 14:43:19 -0500 Subject: Too much vodka, still --- src/edu/stsci/CondaInstaller.groovy | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) 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 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 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() -- cgit