Skip to content

Commit 0573fe3

Browse files
yosifkittianon
authored andcommitted
Catch errors in windows on python installer failure
1 parent a1254c8 commit 0573fe3

File tree

7 files changed

+70
-21
lines changed

7 files changed

+70
-21
lines changed

3.10-rc/windows/windowsservercore-1809/Dockerfile

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ RUN $url = ('https://www.python.org/ftp/python/{0}/python-{1}-amd64.exe' -f $env
2020
Invoke-WebRequest -Uri $url -OutFile 'python.exe'; \
2121
\
2222
Write-Host 'Installing ...'; \
23-
# https://docs.python.org/3.5/using/windows.html#installing-without-ui
24-
Start-Process python.exe -Wait \
23+
# https://docs.python.org/3/using/windows.html#installing-without-ui
24+
$exitCode = (Start-Process python.exe -Wait -NoNewWindow -PassThru \
2525
-ArgumentList @( \
2626
'/quiet', \
2727
'InstallAllUsers=1', \
@@ -31,7 +31,13 @@ RUN $url = ('https://www.python.org/ftp/python/{0}/python-{1}-amd64.exe' -f $env
3131
'Include_doc=0', \
3232
'Include_pip=0', \
3333
'Include_test=0' \
34-
); \
34+
) \
35+
).ExitCode; \
36+
if ($exitCode -ne 0) { \
37+
Write-Host ('Running python installer failed with exit code: {0}' -f $exitCode); \
38+
Get-ChildItem $env:TEMP | Sort-Object -Descending -Property LastWriteTime | Select-Object -First 1 | Get-Content; \
39+
exit $exitCode; \
40+
} \
3541
\
3642
# the installer updated PATH, so we should refresh our local value
3743
$env:PATH = [Environment]::GetEnvironmentVariable('PATH', [EnvironmentVariableTarget]::Machine); \
@@ -41,6 +47,7 @@ RUN $url = ('https://www.python.org/ftp/python/{0}/python-{1}-amd64.exe' -f $env
4147
\
4248
Write-Host 'Removing ...'; \
4349
Remove-Item python.exe -Force; \
50+
Remove-Item $env:TEMP/Python*.log -Force; \
4451
\
4552
Write-Host 'Complete.'
4653

3.10-rc/windows/windowsservercore-ltsc2016/Dockerfile

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ RUN $url = ('https://www.python.org/ftp/python/{0}/python-{1}-amd64.exe' -f $env
2020
Invoke-WebRequest -Uri $url -OutFile 'python.exe'; \
2121
\
2222
Write-Host 'Installing ...'; \
23-
# https://docs.python.org/3.5/using/windows.html#installing-without-ui
24-
Start-Process python.exe -Wait \
23+
# https://docs.python.org/3/using/windows.html#installing-without-ui
24+
$exitCode = (Start-Process python.exe -Wait -NoNewWindow -PassThru \
2525
-ArgumentList @( \
2626
'/quiet', \
2727
'InstallAllUsers=1', \
@@ -31,7 +31,13 @@ RUN $url = ('https://www.python.org/ftp/python/{0}/python-{1}-amd64.exe' -f $env
3131
'Include_doc=0', \
3232
'Include_pip=0', \
3333
'Include_test=0' \
34-
); \
34+
) \
35+
).ExitCode; \
36+
if ($exitCode -ne 0) { \
37+
Write-Host ('Running python installer failed with exit code: {0}' -f $exitCode); \
38+
Get-ChildItem $env:TEMP | Sort-Object -Descending -Property LastWriteTime | Select-Object -First 1 | Get-Content; \
39+
exit $exitCode; \
40+
} \
3541
\
3642
# the installer updated PATH, so we should refresh our local value
3743
$env:PATH = [Environment]::GetEnvironmentVariable('PATH', [EnvironmentVariableTarget]::Machine); \
@@ -41,6 +47,7 @@ RUN $url = ('https://www.python.org/ftp/python/{0}/python-{1}-amd64.exe' -f $env
4147
\
4248
Write-Host 'Removing ...'; \
4349
Remove-Item python.exe -Force; \
50+
Remove-Item $env:TEMP/Python*.log -Force; \
4451
\
4552
Write-Host 'Complete.'
4653

3.8/windows/windowsservercore-1809/Dockerfile

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ RUN $url = ('https://www.python.org/ftp/python/{0}/python-{1}-amd64.exe' -f $env
2020
Invoke-WebRequest -Uri $url -OutFile 'python.exe'; \
2121
\
2222
Write-Host 'Installing ...'; \
23-
# https://docs.python.org/3.5/using/windows.html#installing-without-ui
24-
Start-Process python.exe -Wait \
23+
# https://docs.python.org/3/using/windows.html#installing-without-ui
24+
$exitCode = (Start-Process python.exe -Wait -NoNewWindow -PassThru \
2525
-ArgumentList @( \
2626
'/quiet', \
2727
'InstallAllUsers=1', \
@@ -31,7 +31,13 @@ RUN $url = ('https://www.python.org/ftp/python/{0}/python-{1}-amd64.exe' -f $env
3131
'Include_doc=0', \
3232
'Include_pip=0', \
3333
'Include_test=0' \
34-
); \
34+
) \
35+
).ExitCode; \
36+
if ($exitCode -ne 0) { \
37+
Write-Host ('Running python installer failed with exit code: {0}' -f $exitCode); \
38+
Get-ChildItem $env:TEMP | Sort-Object -Descending -Property LastWriteTime | Select-Object -First 1 | Get-Content; \
39+
exit $exitCode; \
40+
} \
3541
\
3642
# the installer updated PATH, so we should refresh our local value
3743
$env:PATH = [Environment]::GetEnvironmentVariable('PATH', [EnvironmentVariableTarget]::Machine); \
@@ -41,6 +47,7 @@ RUN $url = ('https://www.python.org/ftp/python/{0}/python-{1}-amd64.exe' -f $env
4147
\
4248
Write-Host 'Removing ...'; \
4349
Remove-Item python.exe -Force; \
50+
Remove-Item $env:TEMP/Python*.log -Force; \
4451
\
4552
Write-Host 'Complete.'
4653

3.8/windows/windowsservercore-ltsc2016/Dockerfile

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ RUN $url = ('https://www.python.org/ftp/python/{0}/python-{1}-amd64.exe' -f $env
2020
Invoke-WebRequest -Uri $url -OutFile 'python.exe'; \
2121
\
2222
Write-Host 'Installing ...'; \
23-
# https://docs.python.org/3.5/using/windows.html#installing-without-ui
24-
Start-Process python.exe -Wait \
23+
# https://docs.python.org/3/using/windows.html#installing-without-ui
24+
$exitCode = (Start-Process python.exe -Wait -NoNewWindow -PassThru \
2525
-ArgumentList @( \
2626
'/quiet', \
2727
'InstallAllUsers=1', \
@@ -31,7 +31,13 @@ RUN $url = ('https://www.python.org/ftp/python/{0}/python-{1}-amd64.exe' -f $env
3131
'Include_doc=0', \
3232
'Include_pip=0', \
3333
'Include_test=0' \
34-
); \
34+
) \
35+
).ExitCode; \
36+
if ($exitCode -ne 0) { \
37+
Write-Host ('Running python installer failed with exit code: {0}' -f $exitCode); \
38+
Get-ChildItem $env:TEMP | Sort-Object -Descending -Property LastWriteTime | Select-Object -First 1 | Get-Content; \
39+
exit $exitCode; \
40+
} \
3541
\
3642
# the installer updated PATH, so we should refresh our local value
3743
$env:PATH = [Environment]::GetEnvironmentVariable('PATH', [EnvironmentVariableTarget]::Machine); \
@@ -41,6 +47,7 @@ RUN $url = ('https://www.python.org/ftp/python/{0}/python-{1}-amd64.exe' -f $env
4147
\
4248
Write-Host 'Removing ...'; \
4349
Remove-Item python.exe -Force; \
50+
Remove-Item $env:TEMP/Python*.log -Force; \
4451
\
4552
Write-Host 'Complete.'
4653

3.9/windows/windowsservercore-1809/Dockerfile

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ RUN $url = ('https://www.python.org/ftp/python/{0}/python-{1}-amd64.exe' -f $env
2020
Invoke-WebRequest -Uri $url -OutFile 'python.exe'; \
2121
\
2222
Write-Host 'Installing ...'; \
23-
# https://docs.python.org/3.5/using/windows.html#installing-without-ui
24-
Start-Process python.exe -Wait \
23+
# https://docs.python.org/3/using/windows.html#installing-without-ui
24+
$exitCode = (Start-Process python.exe -Wait -NoNewWindow -PassThru \
2525
-ArgumentList @( \
2626
'/quiet', \
2727
'InstallAllUsers=1', \
@@ -31,7 +31,13 @@ RUN $url = ('https://www.python.org/ftp/python/{0}/python-{1}-amd64.exe' -f $env
3131
'Include_doc=0', \
3232
'Include_pip=0', \
3333
'Include_test=0' \
34-
); \
34+
) \
35+
).ExitCode; \
36+
if ($exitCode -ne 0) { \
37+
Write-Host ('Running python installer failed with exit code: {0}' -f $exitCode); \
38+
Get-ChildItem $env:TEMP | Sort-Object -Descending -Property LastWriteTime | Select-Object -First 1 | Get-Content; \
39+
exit $exitCode; \
40+
} \
3541
\
3642
# the installer updated PATH, so we should refresh our local value
3743
$env:PATH = [Environment]::GetEnvironmentVariable('PATH', [EnvironmentVariableTarget]::Machine); \
@@ -41,6 +47,7 @@ RUN $url = ('https://www.python.org/ftp/python/{0}/python-{1}-amd64.exe' -f $env
4147
\
4248
Write-Host 'Removing ...'; \
4349
Remove-Item python.exe -Force; \
50+
Remove-Item $env:TEMP/Python*.log -Force; \
4451
\
4552
Write-Host 'Complete.'
4653

3.9/windows/windowsservercore-ltsc2016/Dockerfile

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ RUN $url = ('https://www.python.org/ftp/python/{0}/python-{1}-amd64.exe' -f $env
2020
Invoke-WebRequest -Uri $url -OutFile 'python.exe'; \
2121
\
2222
Write-Host 'Installing ...'; \
23-
# https://docs.python.org/3.5/using/windows.html#installing-without-ui
24-
Start-Process python.exe -Wait \
23+
# https://docs.python.org/3/using/windows.html#installing-without-ui
24+
$exitCode = (Start-Process python.exe -Wait -NoNewWindow -PassThru \
2525
-ArgumentList @( \
2626
'/quiet', \
2727
'InstallAllUsers=1', \
@@ -31,7 +31,13 @@ RUN $url = ('https://www.python.org/ftp/python/{0}/python-{1}-amd64.exe' -f $env
3131
'Include_doc=0', \
3232
'Include_pip=0', \
3333
'Include_test=0' \
34-
); \
34+
) \
35+
).ExitCode; \
36+
if ($exitCode -ne 0) { \
37+
Write-Host ('Running python installer failed with exit code: {0}' -f $exitCode); \
38+
Get-ChildItem $env:TEMP | Sort-Object -Descending -Property LastWriteTime | Select-Object -First 1 | Get-Content; \
39+
exit $exitCode; \
40+
} \
3541
\
3642
# the installer updated PATH, so we should refresh our local value
3743
$env:PATH = [Environment]::GetEnvironmentVariable('PATH', [EnvironmentVariableTarget]::Machine); \
@@ -41,6 +47,7 @@ RUN $url = ('https://www.python.org/ftp/python/{0}/python-{1}-amd64.exe' -f $env
4147
\
4248
Write-Host 'Removing ...'; \
4349
Remove-Item python.exe -Force; \
50+
Remove-Item $env:TEMP/Python*.log -Force; \
4451
\
4552
Write-Host 'Complete.'
4653

Dockerfile-windowsservercore.template

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ RUN $url = ('https://www.python.org/ftp/python/{0}/python-{1}-amd64.exe' -f $env
1414
Invoke-WebRequest -Uri $url -OutFile 'python.exe'; \
1515
\
1616
Write-Host 'Installing ...'; \
17-
# https://docs.python.org/3.5/using/windows.html#installing-without-ui
18-
Start-Process python.exe -Wait \
17+
# https://docs.python.org/3/using/windows.html#installing-without-ui
18+
$exitCode = (Start-Process python.exe -Wait -NoNewWindow -PassThru \
1919
-ArgumentList @( \
2020
'/quiet', \
2121
'InstallAllUsers=1', \
@@ -25,7 +25,13 @@ RUN $url = ('https://www.python.org/ftp/python/{0}/python-{1}-amd64.exe' -f $env
2525
'Include_doc=0', \
2626
'Include_pip=0', \
2727
'Include_test=0' \
28-
); \
28+
) \
29+
).ExitCode; \
30+
if ($exitCode -ne 0) { \
31+
Write-Host ('Running python installer failed with exit code: {0}' -f $exitCode); \
32+
Get-ChildItem $env:TEMP | Sort-Object -Descending -Property LastWriteTime | Select-Object -First 1 | Get-Content; \
33+
exit $exitCode; \
34+
} \
2935
\
3036
# the installer updated PATH, so we should refresh our local value
3137
$env:PATH = [Environment]::GetEnvironmentVariable('PATH', [EnvironmentVariableTarget]::Machine); \
@@ -35,6 +41,7 @@ RUN $url = ('https://www.python.org/ftp/python/{0}/python-{1}-amd64.exe' -f $env
3541
\
3642
Write-Host 'Removing ...'; \
3743
Remove-Item python.exe -Force; \
44+
Remove-Item $env:TEMP/Python*.log -Force; \
3845
\
3946
Write-Host 'Complete.'
4047

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy