Commit 8a8e82c9 by Csók Tamás

client: created a choosable agressive Python search NSIS solution

parent 1eae6d5e
...@@ -34,7 +34,27 @@ IF NOT "%4"=="" ( ...@@ -34,7 +34,27 @@ IF NOT "%4"=="" (
SET my_site=!site:"=! SET my_site=!site:"=!
SET "website= -t ^"!my_site!^"" SET "website= -t ^"!my_site!^""
SET "32PythonOn64=False" rem Set Python version if we know it
IF NOT "%5"=="" (
SET "version=%5"
) else (
SET "version="
)
rem Set Python bit count (32 or 64) if we know it
IF NOT "%6"=="" (
SET "architecture=%6"
) else (
SET "architecture="
)
rem Set Python location if we know it
IF NOT "%7"=="" (
SET "python_location=%7"
SET install_path=!python_location:"=!
) else (
SET "install_path="
)
:BatchCheckElevated :BatchCheckElevated
:------------------------------------- :-------------------------------------
...@@ -53,7 +73,8 @@ if '%errorlevel%' NEQ '0' ( ...@@ -53,7 +73,8 @@ if '%errorlevel%' NEQ '0' (
:UACPrompt :UACPrompt
echo Set UAC = CreateObject^("Shell.Application"^) > ^"%temp%\getadmin.vbs^" echo Set UAC = CreateObject^("Shell.Application"^) > ^"%temp%\getadmin.vbs^"
set vbs_site=!site:"=""! set vbs_site=!site:"=""!
echo UAC.ShellExecute "cmd.exe", "/c %~s0 !output_on_screen! !install_nx! !vbs_site!", "", "runas", 1 >> "%temp%\getadmin.vbs" set vbs_installpath=!python_location:"=""!
echo UAC.ShellExecute "cmd.exe", "/c %~s0 !install_location! !output_on_screen! !install_nx! !vbs_site! !version! !architecture! !vbs_installpath!", "", "runas", 1 >> "%temp%\getadmin.vbs"
^"%temp%\getadmin.vbs^" ^"%temp%\getadmin.vbs^"
del "%temp%\getadmin.vbs" del "%temp%\getadmin.vbs"
...@@ -75,8 +96,16 @@ IF NOT "!output_on_screen!"=="False" ( ...@@ -75,8 +96,16 @@ IF NOT "!output_on_screen!"=="False" (
) )
@echo Starting CIRCLE Client install script @echo Starting CIRCLE Client install script
@echo. @echo.
call :SUB_ARCHITECTURE architecture IF NOT "!install_path!"=="" (
IF NOT "!output_on_screen!"=="False" (
@echo Python location got from input parameter.>CON
)
@echo Python location got from input parameter.
GOTO HASPYTHON
)
if "!architecture!"=="" (
call :SUB_ARCHITECTURE architecture
)
:PYTHON_CHECK_MODULE :PYTHON_CHECK_MODULE
rem Decide whether python 2.x is installed or not rem Decide whether python 2.x is installed or not
SET "python_registry=" SET "python_registry="
...@@ -88,7 +117,7 @@ SET index=8 ...@@ -88,7 +117,7 @@ SET index=8
if "!architecture!"=="64" ( if "!architecture!"=="64" (
if "%python_registry%"=="" ( if "%python_registry%"=="" (
SET "python_registry=Wow6432Node\" SET "python_registry=Wow6432Node\"
SET "32PythonOn64=True" SET "architecture=32"
GOTO PYTHON_CHECK GOTO PYTHON_CHECK
) else ( ) else (
GOTO NOPYTHON GOTO NOPYTHON
...@@ -98,7 +127,7 @@ SET index=8 ...@@ -98,7 +127,7 @@ SET index=8
) )
) )
SET version=2.%index% SET version=2.%index%
SET @query="hklm\SOFTWARE\%python_registry%Python\PythonCore\%version%" SET @query="hklm\SOFTWARE\%python_registry%Python\PythonCore\!version!"
reg>nul query %@query% 2>nul reg>nul query %@query% 2>nul
IF ERRORLEVEL 1 GOTO loop IF ERRORLEVEL 1 GOTO loop
IF ERRORLEVEL 0 GOTO HASPYTHON IF ERRORLEVEL 0 GOTO HASPYTHON
...@@ -116,7 +145,7 @@ IF NOT "!output_on_screen!"=="False" ( ...@@ -116,7 +145,7 @@ IF NOT "!output_on_screen!"=="False" (
@echo 64 bit system detected, commencing the install>CON @echo 64 bit system detected, commencing the install>CON
) )
@echo 64 bit system detected, commencing the install @echo 64 bit system detected, commencing the install
start "Phyton Installer" /WAIT ^"%running_directory%x64^\python-2.7.7.amd64.msi^" start "Phyton Installer" /WAIT ^"%running_directory%x64^\python-2.7.10.amd64.msi^"
GOTO NOWHASPYTHON GOTO NOWHASPYTHON
) )
if "!architecture!"=="32" ( if "!architecture!"=="32" (
...@@ -124,7 +153,7 @@ IF NOT "!output_on_screen!"=="False" ( ...@@ -124,7 +153,7 @@ IF NOT "!output_on_screen!"=="False" (
@echo 32 bit system detected, commencing the install>CON @echo 32 bit system detected, commencing the install>CON
) )
@echo 32 bit system detected, commencing the install @echo 32 bit system detected, commencing the install
start "Phyton Installer" /WAIT ^"%running_directory%x86^\python-2.7.7.msi^" start "Phyton Installer" /WAIT ^"%running_directory%x86^\python-2.7.10.msi^"
GOTO NOWHASPYTHON GOTO NOWHASPYTHON
) )
GOTO ERR GOTO ERR
...@@ -171,20 +200,21 @@ IF NOT "!output_on_screen!"=="False" ( ...@@ -171,20 +200,21 @@ IF NOT "!output_on_screen!"=="False" (
rem We have Python but let's check if it's in the PATH rem We have Python but let's check if it's in the PATH
:HASPYTHON :HASPYTHON
IF NOT "!output_on_screen!"=="False" ( IF NOT "!output_on_screen!"=="False" (
@echo %version% Python is found, checking PATH variable>CON @echo !version! Python is found, checking PATH variable>CON
) )
@echo %version% Python is found, checking PATH variable @echo !version! Python is found, checking PATH variable
rem Check Python install path rem Check Python install path
set install_path= IF "!install_path!"=="" (
for /f "tokens=2,*" %%a in ('reg query "hklm\SOFTWARE\%python_registry%Python\PythonCore\%version%\InstallPath"') do ( for /f "tokens=2,*" %%a in ('reg query "hklm\SOFTWARE\%python_registry%Python\PythonCore\!version!\InstallPath"') do (
set install_path=%%b set install_path=%%b
)
) )
rem Check whether python.exe is in the install path (python uninstall doesn't delete registry entrys) rem Check whether python.exe is in the install path (python uninstall doesn't delete registry entrys)
if NOT EXIST "%install_path%python.exe" ( if NOT EXIST "!install_path!python.exe" (
IF NOT "!output_on_screen!"=="False" ( IF NOT "!output_on_screen!"=="False" (
@echo %version% Python was installed but it is NOT now. Restarting the search for python^^!>CON @echo !version! Python was installed but it is NOT now. Restarting the search for python^^!>CON
) )
@echo %version% Python was installed but it is NOT now. Restarting the search for python^^! @echo !version! Python was installed but it is NOT now. Restarting the search for python^^!
goto loop goto loop
) else ( ) else (
set test=%install_path:~0,-1% set test=%install_path:~0,-1%
...@@ -247,7 +277,7 @@ IF NOT "!output_on_screen!"=="False" ( ...@@ -247,7 +277,7 @@ IF NOT "!output_on_screen!"=="False" (
rem Try to install the PIP packages via PIP rem Try to install the PIP packages via PIP
:PIP_PACKAGE_INSTALL :PIP_PACKAGE_INSTALL
if "!pip_program!"=="pywin32" ( if "!pip_program!"=="pywin32" (
call python %running_directory%pywin_installer.py call python ^"%running_directory%pywin_installer.py^" ^-m !architecture!
) else ( ) else (
call python -m pip install -r !pip_program! call python -m pip install -r !pip_program!
) )
......
...@@ -11,6 +11,11 @@ import subprocess ...@@ -11,6 +11,11 @@ import subprocess
import windowsclasses import windowsclasses
import argparse import argparse
if windowsclasses.DecideArchitecture.Is64Windows():
default_mode = '64'
else:
default_mode = '32'
def parse_arguments(): def parse_arguments():
""" """
...@@ -21,10 +26,9 @@ def parse_arguments(): ...@@ -21,10 +26,9 @@ def parse_arguments():
""" """
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
parser.add_argument( parser.add_argument(
"change_architect", type=str, "-m", "--mode",
help=("Whether the 32 bit Python version" help="Python running mode (32bit or 64bit)", type=str,
"is installed on a 64bit system"), required=True, choices=['32', '64'], default=default_mode)
nargs='?', default=False)
args = parser.parse_args() args = parser.parse_args()
return args return args
...@@ -37,6 +41,10 @@ def main(): ...@@ -37,6 +41,10 @@ def main():
Install Pywin32 to the computer Install Pywin32 to the computer
""" """
args = parse_arguments() args = parse_arguments()
if args.mode != default_mode:
change_architect = True
else:
change_architect = False
if sys.hexversion < 0x02060000: if sys.hexversion < 0x02060000:
print "Not a 2.6+ version Python is running, commencing update" print "Not a 2.6+ version Python is running, commencing update"
subprocess.Popen( subprocess.Popen(
...@@ -47,7 +55,7 @@ def main(): ...@@ -47,7 +55,7 @@ def main():
pywin32_version = str(219) pywin32_version = str(219)
if sys.hexversion < 0x02070000: if sys.hexversion < 0x02070000:
if (windowsclasses.DecideArchitecture.Is64Windows() if (windowsclasses.DecideArchitecture.Is64Windows()
and not args.change_architect): and not change_architect):
subprocess.Popen( subprocess.Popen(
"%s\\x64\\pywin32-%s.win-amd64-py2.6.exe" % ( "%s\\x64\\pywin32-%s.win-amd64-py2.6.exe" % (
os.path.dirname(os.path.realpath(__file__)), os.path.dirname(os.path.realpath(__file__)),
...@@ -59,7 +67,7 @@ def main(): ...@@ -59,7 +67,7 @@ def main():
pywin32_version)).wait() pywin32_version)).wait()
elif sys.hexversion < 0x02080000: elif sys.hexversion < 0x02080000:
if (windowsclasses.DecideArchitecture.Is64Windows() if (windowsclasses.DecideArchitecture.Is64Windows()
and not args.change_architect): and not change_architect):
subprocess.Popen( subprocess.Popen(
"%s\\x64\\pywin32-%s.win-amd64-py2.7.exe" % ( "%s\\x64\\pywin32-%s.win-amd64-py2.7.exe" % (
os.path.dirname(os.path.realpath(__file__)), os.path.dirname(os.path.realpath(__file__)),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment