|
3 | 3 | # License: CC0 1.0 Universal: http://creativecommons.org/publicdomain/zero/1.0/
|
4 | 4 |
|
5 | 5 | $MINICONDA_URL = "http://repo.continuum.io/miniconda/"
|
6 |
| -$BASE_URL = "https://www.python.org/ftp/python/" |
| 6 | +$FSAVERAGE_URL = "http://faculty.washington.edu/larsoner/fsaverage_min.tar.gz" |
| 7 | + |
| 8 | +function DownloadExtractFsaverage () { |
| 9 | + $webclient = New-Object System.Net.WebClient |
| 10 | + $basedir = $pwd.Path + "\" |
| 11 | + $filepath = $basedir + "fsaverage_min.zip" |
| 12 | + # Download and retry up to 3 times in case of network transient errors. |
| 13 | + $url = $FSAVERAGE_URL |
| 14 | + Write-Host "Downloading" $url |
| 15 | + $retry_attempts = 2 |
| 16 | + for($i=0; $i -lt $retry_attempts; $i++){ |
| 17 | + try { |
| 18 | + $webclient.DownloadFile($url, $filepath) |
| 19 | + break |
| 20 | + } |
| 21 | + Catch [Exception]{ |
| 22 | + Start-Sleep 1 |
| 23 | + } |
| 24 | + } |
| 25 | + if (Test-Path $filepath) { |
| 26 | + Write-Host "File saved at" $filepath |
| 27 | + } else { |
| 28 | + # Retry once to get the error message if any at the last try |
| 29 | + $webclient.DownloadFile($url, $filepath) |
| 30 | + } |
| 31 | + # Now we extract |
| 32 | + $subjects_dir = $basedir + "\subjects" |
| 33 | + New-Item -ItemType directory -Path $subjects_dir |
| 34 | + $shell = new-object -com shell.application |
| 35 | + $zip = $shell.NameSpace($filepath) |
| 36 | + foreach($item in $zip.items()) |
| 37 | + { |
| 38 | + $shell.Namespace($subjects_dir).copyhere($item) |
| 39 | + } |
| 40 | +} |
7 | 41 |
|
8 | 42 |
|
9 | 43 | function DownloadMiniconda ($python_version, $platform_suffix) {
|
@@ -33,14 +67,14 @@ function DownloadMiniconda ($python_version, $platform_suffix) {
|
33 | 67 | Catch [Exception]{
|
34 | 68 | Start-Sleep 1
|
35 | 69 | }
|
36 |
| - } |
37 |
| - if (Test-Path $filepath) { |
38 |
| - Write-Host "File saved at" $filepath |
39 |
| - } else { |
40 |
| - # Retry once to get the error message if any at the last try |
41 |
| - $webclient.DownloadFile($url, $filepath) |
42 |
| - } |
43 |
| - return $filepath |
| 70 | + } |
| 71 | + if (Test-Path $filepath) { |
| 72 | + Write-Host "File saved at" $filepath |
| 73 | + } else { |
| 74 | + # Retry once to get the error message if any at the last try |
| 75 | + $webclient.DownloadFile($url, $filepath) |
| 76 | + } |
| 77 | + return $filepath |
44 | 78 | }
|
45 | 79 |
|
46 | 80 |
|
@@ -86,6 +120,7 @@ function InstallMinicondaPip ($python_home) {
|
86 | 120 |
|
87 | 121 |
|
88 | 122 | function main () {
|
| 123 | + DownloadExtractFsaverage |
89 | 124 | InstallMiniconda $env:PYTHON_VERSION $env:PYTHON_ARCH $env:PYTHON
|
90 | 125 | InstallMinicondaPip $env:PYTHON
|
91 | 126 | }
|
|
0 commit comments