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 | ||
---|---|---|
1 |
@PowerShell -Command Invoke-Expression $([String]::Join([char] 10, (Get-Content '%~f0') -notmatch '^^@PowerShell.*EOF$')) & pause & goto :EOF |
|
2 |
|
|
3 |
function is_win64() { |
|
4 |
return [IntPtr]::size -eq 8 |
|
5 |
} |
|
6 |
|
|
7 |
function get_32bit_software_node() { |
|
8 |
if (is_win64) { |
|
9 |
return "HKLM:\SOFTWARE\Wow6432Node\" |
|
10 |
} |
|
11 |
|
|
12 |
return "HKLM:\SOFTWARE\" |
|
13 |
} |
|
14 |
|
|
15 |
function get_python_path([string]$version) { |
|
16 |
$softNode = get_32bit_software_node |
|
17 |
$basePath = "???" |
|
18 |
|
|
19 |
try { |
|
20 |
$regKey = Get-Item -erroraction stop -path "$softNode\Python\PythonCore\$version\InstallPath" |
|
21 |
$installKey = Get-ItemProperty -path $regKey.PsPath |
|
22 |
$basePath = $installKey.'(default)' |
|
23 |
} catch { |
|
24 |
throw "Unable to detect an installation of Python $version (32-bit)" |
|
25 |
} |
|
26 |
|
|
27 |
if (!(Test-Path $basePath)) { |
|
28 |
throw "Windows' registry specified a non-existant folder for Python $version ($basePath)" |
|
29 |
} |
|
30 |
|
|
31 |
return $basePath |
|
32 |
} |
|
33 |
|
|
34 |
function get_python_executable([string]$version) { |
|
35 |
$base = get_python_path($version) |
|
36 |
$exec = "$base\python.exe" |
|
37 |
if (Test-Path $exec) { |
|
38 |
return $exec |
|
39 |
} |
|
40 |
throw "Unable to find the executable of Python $version in folder specified in the system registry ($base)" |
|
41 |
} |
|
42 |
|
|
43 |
function run_chirpw() { |
|
44 |
$pyexec = get_python_executable("2.7") |
|
45 |
echo "Running $pyexec chirpw" |
|
46 |
& $pyexec "chirpw" |
|
47 |
} |
|
48 |
|
|
49 |
run_chirpw |