summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2018-01-27 14:43:19 -0500
committerJoseph Hunkeler <jhunkeler@gmail.com>2018-01-27 14:43:19 -0500
commit8e885359f4959036720632e2e075bf4d56d9f3a5 (patch)
tree2110977f75b20368a61b3a002805bc08c3d4fd8e /src
parentb35d9586dbb35d79f83d066153ae460b25dc82d4 (diff)
downloadgroovy-sandbox-8e885359f4959036720632e2e075bf4d56d9f3a5.tar.gz
Too much vodka, still
Diffstat (limited to 'src')
-rw-r--r--src/edu/stsci/CondaInstaller.groovy30
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()