summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2017-06-26 16:12:11 -0400
committerJoseph Hunkeler <jhunkeler@gmail.com>2017-06-26 16:12:11 -0400
commitf663134d2a509da522701b995a2b1964133a8b6c (patch)
tree6db22a3364b2edb2f621ad2cb463fd370fb063e1
parentc3fbab8a95adffb2bc39aaa646c5793e0869623a (diff)
downloadgroovy-sandbox-f663134d2a509da522701b995a2b1964133a8b6c.tar.gz
Break down
-rw-r--r--src/org/stsci/CondaInstaller.groovy61
-rw-r--r--src/org/stsci/OSInfo.groovy17
-rw-r--r--src/org/stsci/conda.groovy83
3 files changed, 80 insertions, 81 deletions
diff --git a/src/org/stsci/CondaInstaller.groovy b/src/org/stsci/CondaInstaller.groovy
new file mode 100644
index 0000000..bf2299e
--- /dev/null
+++ b/src/org/stsci/CondaInstaller.groovy
@@ -0,0 +1,61 @@
+class CondaInstaller {
+ OSInfo os
+ String prefix
+ String dist_version
+ String url
+ def dist = [:]
+
+ CondaInstaller(prefix, dist="miniconda", variant="3", version="latest") {
+ def distributions = [
+ miniconda: [name: 'Miniconda',
+ variant: variant,
+ baseurl: 'https://repo.continuum.io/miniconda'],
+ anaconda: [name: 'Anaconda',
+ variant: variant,
+ baseurl: 'https://repo.continuum.io/archive']
+ ]
+ this.os = new OSInfo()
+ this.dist = distributions."${dist}"
+ this.dist_version = version
+ this.prefix = prefix
+ this.url = "${this.dist.baseurl}/" +
+ "${this.dist.name}${this.dist.variant}-" +
+ "${this.dist_version}-${this.os.name}-${this.os.arch}.sh"
+ }
+
+ void download() {
+
+ println("Downloading $url")
+ File fp = new File('installer.sh')
+ def installer = fp.newOutputStream()
+ installer << new URL(this.url).openStream()
+ installer.close()
+ println("Received ${fp.length()} bytes")
+ }
+
+ int install() {
+ if (new File(this.prefix).exists()) {
+ println("Skipping installation: ${this.prefix} exists.")
+ return 0xFF
+ }
+
+ if (!new File('installer.sh').exists()) {
+ this.download()
+ }
+
+ def cmd = "bash installer.sh -b -p ${this.prefix}"
+ def proc = cmd.execute()
+ def stdout = new StringBuffer()
+
+ proc.inputStream.eachLine { println(it) }
+
+ //proc.waitForProcessOutput(stdout, System.err)
+ //print(stdout.toString())
+
+ return proc.exitValue()
+ }
+
+ private void detect() {
+ }
+}
+
diff --git a/src/org/stsci/OSInfo.groovy b/src/org/stsci/OSInfo.groovy
new file mode 100644
index 0000000..cc1ddca
--- /dev/null
+++ b/src/org/stsci/OSInfo.groovy
@@ -0,0 +1,17 @@
+class OSInfo {
+ public String name
+ public String version
+ public String arch
+
+ OSInfo () {
+ name = 'uname -s'.execute().text.trim()
+ if (name == 'Darwin') { name = 'MacOSX' }
+ arch = 'uname -p'.execute().text.trim()
+ if (arch.matches('^i.*86$')) { arch = 'x86' }
+
+ this.name = name
+ this.arch = arch
+ this.version = 'uname -r'.execute().text.trim()
+ }
+
+}
diff --git a/src/org/stsci/conda.groovy b/src/org/stsci/conda.groovy
index a8e2fb7..ea0d240 100644
--- a/src/org/stsci/conda.groovy
+++ b/src/org/stsci/conda.groovy
@@ -1,82 +1,3 @@
-class OSInfo {
- public String name
- public String version
- public String arch
-
- OSInfo () {
- name = 'uname -s'.execute().text.trim()
- if (name == 'Darwin') { name = 'MacOSX' }
- arch = 'uname -p'.execute().text.trim()
- if (arch.matches('^i.*86$')) { arch = 'x86' }
-
- this.name = name
- this.arch = arch
- this.version = 'uname -r'.execute().text.trim()
- }
-
-}
-
-class CondaInstaller {
- OSInfo os
- String prefix
- String dist_version
- String url
- def dist = [:]
-
- CondaInstaller(prefix, dist="miniconda", variant="3", version="latest") {
- def distributions = [
- miniconda: [name: 'Miniconda',
- variant: variant,
- baseurl: 'https://repo.continuum.io/miniconda'],
- anaconda: [name: 'Anaconda',
- variant: variant,
- baseurl: 'https://repo.continuum.io/archive']
- ]
- this.os = new OSInfo()
- this.dist = distributions."${dist}"
- this.dist_version = version
- this.prefix = prefix
- this.url = "${this.dist.baseurl}/" +
- "${this.dist.name}${this.dist.variant}-" +
- "${this.dist_version}-${this.os.name}-${this.os.arch}.sh"
- }
-
- void download() {
-
- println("Downloading $url")
- File fp = new File('installer.sh')
- def installer = fp.newOutputStream()
- installer << new URL(this.url).openStream()
- installer.close()
- println("Received ${fp.length()} bytes")
- }
-
- int install() {
- if (new File(this.prefix).exists()) {
- println("Skipping installation: ${this.prefix} exists.")
- return 0xFF
- }
-
- if (!new File('installer.sh').exists()) {
- this.download()
- }
-
- def cmd = "bash installer.sh -b -p ${this.prefix}"
- def proc = cmd.execute()
- def stdout = new StringBuffer()
-
- proc.inputStream.eachLine { println(it) }
-
- //proc.waitForProcessOutput(stdout, System.err)
- //print(stdout.toString())
-
- return proc.exitValue()
- }
-
- private void detect() {
- }
-}
-
class Conda {
public String prefix
public boolean prefix_exists
@@ -246,6 +167,7 @@ class Conda {
}
}
+/*
static void main(String[] args) {
final String PREFIX = "/tmp/miniconda3"
final String NAME = "astroconda35"
@@ -270,5 +192,4 @@ static void main(String[] args) {
assert c.environment_name == NAME
assert c.provides(NAME) == true
}
-
-
+*/