Feature #2297 » chirpw_bat.patch
/dev/null Thu Jan 01 00:00:00 1970 +0000 → chirpw.bat Sat Feb 07 20:31:27 2015 +0100 | ||
---|---|---|
@PowerShell -Command Invoke-Expression $([String]::Join([char] 10, (Get-Content '%~f0') -notmatch '^^@PowerShell.*EOF$')) & pause & goto :EOF
|
||
|
||
function is_win64() {
|
||
return [IntPtr]::size -eq 8
|
||
}
|
||
|
||
function get_32bit_software_node() {
|
||
if (is_win64) {
|
||
return "HKLM:\SOFTWARE\Wow6432Node\"
|
||
}
|
||
|
||
return "HKLM:\SOFTWARE\"
|
||
}
|
||
|
||
function get_python_path([string]$version) {
|
||
$softNode = get_32bit_software_node
|
||
$basePath = "???"
|
||
|
||
try {
|
||
$regKey = Get-Item -erroraction stop -path "$softNode\Python\PythonCore\$version\InstallPath"
|
||
$installKey = Get-ItemProperty -path $regKey.PsPath
|
||
$basePath = $installKey.'(default)'
|
||
} catch {
|
||
throw "Unable to detect an installation of Python $version (32-bit)"
|
||
}
|
||
|
||
if (!(Test-Path $basePath)) {
|
||
throw "Windows' registry specified a non-existant folder for Python $version ($basePath)"
|
||
}
|
||
|
||
return $basePath
|
||
}
|
||
|
||
function get_python_executable([string]$version) {
|
||
$base = get_python_path($version)
|
||
$exec = "$base\python.exe"
|
||
if (Test-Path $exec) {
|
||
return $exec
|
||
}
|
||
throw "Unable to find the executable of Python $version in folder specified in the system registry ($base)"
|
||
}
|
||
|
||
function run_chirpw() {
|
||
$pyexec = get_python_executable("2.7")
|
||
echo "Running $pyexec chirpw"
|
||
& $pyexec "chirpw"
|
||
}
|
||
|
||
run_chirpw
|