|
| 1 | +################################################################################ |
| 2 | +# Copyright (c) Microsoft. All rights reserved. |
| 3 | +# |
| 4 | +# Apache 2.0 License |
| 5 | +# |
| 6 | +# You may obtain a copy of the License at |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or |
| 12 | +# implied. See the License for the specific language governing |
| 13 | +# permissions and limitations under the License. |
| 14 | +# |
| 15 | +################################################################################ |
| 16 | +param([string]$DestDir) |
| 17 | + |
| 18 | +$web_client = new-object System.Net.WebClient |
| 19 | + |
| 20 | + |
| 21 | +function DownloadRawFromGitWithFileList($base_url, $file_list_name, $destination_dir) |
| 22 | +{ |
| 23 | + # Download the list so we can iterate over it. |
| 24 | + $tempPath = [IO.Path]::GetTempFileName() |
| 25 | + $url = $base_url + $file_list_name |
| 26 | + $web_client.DownloadFile($url, $tempPath) |
| 27 | + |
| 28 | + # Iterate over the different lines in the file and add them to the machine |
| 29 | + $reader = [System.IO.File]::OpenText($tempPath) |
| 30 | + try { |
| 31 | + for(;;) { |
| 32 | + $line = $reader.ReadLine() |
| 33 | + if ($line -eq $null) { break } |
| 34 | + |
| 35 | + # download the file specified by this line... |
| 36 | + $url = $base_url + $line |
| 37 | + $destination = Join-Path $destination_dir $line |
| 38 | + $web_client.DownloadFile($url, $destination) |
| 39 | + } |
| 40 | + } |
| 41 | + finally { |
| 42 | + $reader.Close() |
| 43 | + } |
| 44 | +} |
| 45 | + |
| 46 | +function GetSampleFilesFromGit($gitdir_name, $list_name, $destination_dir){ |
| 47 | + #Write-Output "Getting Sample Notebooks from Azure-MachineLearning-DataScience Git Repository" |
| 48 | + $file_url = "https://raw.githubusercontent.com/Azure/Azure-MachineLearning-DataScience/master/Misc/" + $gitdir_name + "/" |
| 49 | + DownloadRawFromGitWithFileList $file_url $list_name $destination_dir |
| 50 | +} |
| 51 | + |
| 52 | + |
| 53 | +###################### End of Functions / Start of Script ###################### |
| 54 | +if (!(Test-Path $DestDir)) { |
| 55 | + Write-Output "$DestDir does not exist and is created." |
| 56 | + mkdir $DestDir |
| 57 | +} |
| 58 | +Write-Output "Start downloading the data file to $DestDir. It may take a while..." |
| 59 | +$file_url = "http://getgoing.blob.core.windows.net/public/nyctaxi1pct.csv" |
| 60 | +$file_dest = Join-Path $DestDir "nyctaxi1pct.csv" |
| 61 | +$web_client.DownloadFile($file_url, $file_dest) |
| 62 | +Write-Output "Fetching the sample script files to $DestDir..." |
| 63 | +GetSampleFilesFromGit "RSQL" "FilestoDownload_SQL_Walkthrough.txt" $DestDir |
| 64 | +Write-Output "Fetching the sample script files completed." |
| 65 | +Write-Output "Now entering the destination directory $DestDir." |
| 66 | +cd $DestDir |
0 commit comments