Commit 318fac09 by Csók Tamás

Windows installation scripts

parent 470fa621
...@@ -5,16 +5,30 @@ setLocal EnableDelayedExpansion ...@@ -5,16 +5,30 @@ setLocal EnableDelayedExpansion
@echo. @echo.
rem Get the running directory for later ease of use rem Get the running directory for later ease of use
SET running_directory=%~dp0 SET running_directory=%~dp0
rem Set where this file will install the rest of the files
SET "install_location=%ProgramFiles%\CIRCLE"
call :SUB_ARCHITECTURE architecture call :SUB_ARCHITECTURE architecture
rem Decide whether python 2.x is installed or not rem Decide whether python 2.x is installed or not
SET "python_registry="
:PHYTON_CHECK :PHYTON_CHECK
SET index=-1 SET index=-1
:loop :loop
SET /a index+=1 SET /a index+=1
IF %index% GTR 7 GOTO NOPYTHON IF %index% GTR 7 (
if "!architecture!"=="64" (
if "%python_registry%"=="" (
SET "python_registry=Wow6432Node\"
GOTO PHYTON_CHECK
) else (
GOTO NOPYTHON
)
) else (
GOTO NOPYTHON
)
)
SET version=2.%index% SET version=2.%index%
SET @query="hklm\SOFTWARE\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
...@@ -70,7 +84,7 @@ rem No 2.x Python is installed ...@@ -70,7 +84,7 @@ rem No 2.x Python is installed
@echo %version% Phyton is found, checking PATH variable @echo %version% Phyton is found, checking PATH variable
rem Check Phyton install path rem Check Phyton install path
set install_path= set install_path=
for /f "tokens=2,*" %%a in ('reg query "hklm\SOFTWARE\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
) )
set test=%install_path:~0,-1% set test=%install_path:~0,-1%
...@@ -93,31 +107,39 @@ rem No 2.x Python is installed ...@@ -93,31 +107,39 @@ rem No 2.x Python is installed
@echo PIP is found @echo PIP is found
@echo Checking whether the latest PIP is installed @echo Checking whether the latest PIP is installed
call python -m pip install --upgrade pip call python -m pip install --upgrade pip
GOTO SELENIUM_CHECK SET "pip_program=selenium"
GOTO PIP_PACKAGE_CHECK
rem Check if Selenium is installed rem Check if the PIP package is installed or not
:SELENIUM_CHECK :PIP_PACKAGE_CHECK
@echo. @echo.
@echo Check whether selenium is installed @echo Check whether !pip_program! is installed
for /f "tokens=1,2 delims===" %%a in ('call python -m pip freeze') do ( for /f "tokens=1,2 delims===" %%a in ('call python -m pip freeze') do (
if "%%a"=="selenium" ( if "%%a"=="!pip_program!" (
@echo %%b Selenium is found @echo %%b !pip_program! is found
GOTO SELENIUM_UPDATE GOTO PIP_PACKAGE_UPDATE
) )
) )
@echo No Selenium version is found, commencing install @echo No !pip_program! version is found, commencing install
GOTO SELENIUM_INSTALL GOTO PIP_PACKAGE_INSTALL
rem Try to install Selenium via PIP rem Try to install the PIP package via PIP
:SELENIUM_INSTALL :PIP_PACKAGE_INSTALL
@echo Installing Selenium @echo Installing !pip_program!
call python -m pip install selenium call python -m pip install !pip_program!
goto CHECK_BROWSER goto CHECK_PACKAGE_LIST
rem Try to update Selenium rem Try to update Selenium
:SELENIUM_UPDATE :PIP_PACKAGE_UPDATE
@echo Trying to update Selenium @echo Trying to update !pip_program!
call python -m pip install --upgrade selenium call python -m pip install --upgrade !pip_program!
goto CHECK_PACKAGE_LIST
:CHECK_PACKAGE_LIST
if "!pip_program!"=="selenium" (
set "pip_program=winshell"
goto PIP_PACKAGE_CHECK
)
goto CHECK_BROWSER goto CHECK_BROWSER
...@@ -266,10 +288,27 @@ if "!browserToUse!"=="None" ( ...@@ -266,10 +288,27 @@ if "!browserToUse!"=="None" (
) )
GOTO ERR GOTO ERR
rem Installation complete rem Finish up the install
:FIN :FIN
rem Create folder if needed and set it to PATH
@echo Checking wheter ^'%install_location%^\^' exists already
call %running_directory%inPath install_location && (@echo !install_location! is already in PATH) || (call %running_directory%addPath install_location & setx PATH "%PATH%;!install_location!" /m & @echo !install_location! set to PATH)
if not exist "%install_location%\" (
mkdir "%install_location%"
)
rem Copy the files to the folder
@echo Copying files to ^'%install_location%^'
xcopy>nul "%running_directory%cloud.py" "%install_location%\" /y
xcopy>nul "%running_directory%cloud_connect_from_windows.py" "%install_location%\" /y
xcopy>nul "%running_directory%cloud.ico" "%install_location%\" /y
@echo Done
@echo. @echo.
@echo Starting the phyton installation script
call python %running_directory%win_install.py ^-d !browserToUse! ^-l "%install_location%\\"
@echo Done
@echo Installation complete @echo Installation complete
@echo Press any key to close this installer
pause
GOTO END GOTO END
rem Subroutine to decide which Selenium driver to use rem Subroutine to decide which Selenium driver to use
......
#!/usr/bin/python
# -*- coding: utf-8 -*-
##
# Windows installer helper for CIRCLE client application
##
import os, sys, argparse
import pythoncom
from win32com.shell import shell, shellcon
##
# Argument parser, argparse modulon alapszik
# @return args
#
def pars_arguments():
parser = argparse.ArgumentParser();
parser.add_argument("-d", "--driver", help="Select webdriver. Aside from Firefox, you have to install first the proper driver.", \
type=str, choices=['firefox', 'chrome', 'iexplore', 'opera'], default="firefox")
parser.add_argument("-l", "--location", help="Location of the client files in the system", default=os.getenv('ProgramFiles')+"\\CIRCLE\\")
args = parser.parse_args();
return args
##
# Main program
# read the parameters
# create a proper icon with the proper driver
def main():
try:
args = pars_arguments()
shortcut = pythoncom.CoCreateInstance (
shell.CLSID_ShellLink,
None,
pythoncom.CLSCTX_INPROC_SERVER,
shell.IID_IShellLink
)
shortcut.SetPath (args.location+"cloud.py")
if args.driver == "chrome":
shortcut.SetArguments("-d chrome")
elif args.driver == "iexplore":
shortcut.SetArguments("-d ie")
elif args.driver == "opera":
shortcut.SetArguments("-d opera")
shortcut.SetDescription ("Tool to use CIRCLE Cloud")
shortcut.SetIconLocation (args.location+"cloud.ico", 0)
desktop_path = shell.SHGetFolderPath (0, shellcon.CSIDL_DESKTOP, 0, 0)
persist_file = shortcut.QueryInterface (pythoncom.IID_IPersistFile)
persist_file.Save (os.path.join (desktop_path, "Cloud GUI.lnk"), 0)
except:
pass
if __name__ == "__main__":
main()
\ No newline at end of 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