<#.SynopsisUploads from a VSTS release build layout to python.org.DescriptionGiven the downloaded/extracted build artifact from a releasebuild run on python.visualstudio.com, this script uploadsthe files to the correct locations..Parameter buildThe location on disk of the extracted build artifact..Parameter userThe username to use when logging into the host..Parameter serverThe host or PuTTY session name..Parameter targetThe subdirectory on the host to copy files to..Parameter testsThe path to run download tests in..Parameter doc_htmlhelpOptional path besides -build to locate CHM files..Parameter embedOptional path besides -build to locate ZIP files..Parameter skipuploadSkip uploading.Parameter skippurgeSkip purging the CDN.Parameter skiptestSkip the download tests.Parameter skiphashSkip displaying hashes#>param([Parameter(Mandatory=$true)][string]$build,[Parameter(Mandatory=$true)][string]$user,[string]$server="python-downloads",[string]$target="/srv/www.python.org/ftp/python",[string]$tests=${env:TEMP},[string]$doc_htmlhelp=$null,[string]$embed=$null,[switch]$skipupload,[switch]$skippurge,[switch]$skiptest,[switch]$skiphash)if(-not$build){throw"-build option is required"}if(-not$user){throw"-user option is required"}$tools=$script:MyInvocation.MyCommand.Path|Split-Path-parent;if(-not((Test-Path"$build\win32\python-*.exe")-or(Test-Path"$build\amd64\python-*.exe"))){throw"-build argument does not look like a 'build' directory"}functionfind-putty-tool{param([string]$n)$t=gcm$n-EA0if(-not$t){$t=gcm".\$n"-EA0}if(-not$t){$t=gcm"${env:ProgramFiles}\PuTTY\$n"-EA0}if(-not$t){$t=gcm"${env:ProgramFiles(x86)}\PuTTY\$n"-EA0}if(-not$t){throw"Unable to locate $n.exe. Please put it on $PATH"}returngi$t.Path}$p=gci-r"$build\python-*.exe"|`?{$_.Name-match'^python-(\d+\.\d+\.\d+)((a|b|rc)\d+)?-.+'}|`select-first1|`%{$Matches[1],$Matches[2]}"Uploading version $($p[0])$($p[1])"" from: $build"" to: $($server):$target/$($p[0])"""if(-not$skipupload){# Upload files to the server$pscp=find-putty-tool"pscp"$plink=find-putty-tool"plink""Upload using $pscp and $plink"""if($doc_htmlhelp){pushd$doc_htmlhelp}else{pushd$build}$chm=gcipython*.chm,python*.chm.ascpopd$d="$target/$($p[0])/"&$plink-batch$user@$servermkdir$d&$plink-batch$user@$serverchgrpdownloads$d&$plink-batch$user@$serverchmodg-x,o+rx$d&$pscp-batch$chm.FullName"$user@${server}:$d"if(-not$?){throw"Failed to upload $chm"}$dirs=gci"$build"-Directoryif($embed){$dirs=($dirs,(gi$embed))|%{$_}}foreach($ain$dirs){"Uploading files from $($a.FullName)"pushd"$($a.FullName)"$exe=gci*.exe,*.exe.asc,*.zip,*.zip.asc$msi=gci*.msi,*.msi.asc,*.msu,*.msu.ascpopdif($exe){&$pscp-batch$exe.FullName"$user@${server}:$d"if(-not$?){throw"Failed to upload $exe"}}if($msi){$sd="$d$($a.Name)$($p[1])/"&$plink-batch$user@$servermkdir$sd&$plink-batch$user@$serverchgrpdownloads$sd&$plink-batch$user@$serverchmodg-x,o+rx$sd&$pscp-batch$msi.FullName"$user@${server}:$sd"if(-not$?){throw"Failed to upload $msi"}&$plink-batch$user@$serverchgrpdownloads$sd*&$plink-batch$user@$serverchmodg-x,o+r$sd*}}&$plink-batch$user@$serverchgrpdownloads$d*&$plink-batch$user@$serverchmodg-x,o+r$d*&$pscp-ls"$user@${server}:$d"}if(-not$skippurge){# Run a CDN purgepy$tools\purge.py"$($p[0])$($p[1])"}if(-not$skiptest){# Use each web installer to produce a layout. This will download# each referenced file and validate their signatures/hashes.gci"$build\*-webinstall.exe"-r-File|%{$d=mkdir"$tests\$($_.BaseName)"-Forcegci$d-r-File|del$ic=copy$_$d-PassThru"Checking layout for $($ic.Name)"Start-Process-wait$ic"/passive","/layout","$d\layout","/log","$d\log\install.log"if(-not$?){Write-Error"Failed to validate layout of $($inst.Name)"}}}if(-not$skiphash){# Display MD5 hash and size of each downloadable filepushd$build$files=gcipython*.chm,*\*.exe,*\*.zipif($doc_htmlhelp){cd$doc_htmlhelp$files=($files,(gcipython*.chm))|%{$_}}if($embed){cd$embed$files=($files,(gci*.zip))|%{$_}}popd$hashes=$files|`Sort-ObjectName|`Format-TableName,@{Label="MD5";Expression={(Get-FileHash$_-AlgorithmMD5).Hash}},Length-AutoSize|`Out-String-Width4096$hashes|clip$hashes}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。