Skip to content
setup-weboob.bat 4.37 KiB
Newer Older
Bezleputh's avatar
Bezleputh committed
@echo off
setlocal enableextensions enabledelayedexpansion

call settings.cmd

echo.
echo 0.Set proxy
set/P HTTP_PROXY=Enter HTTP_PROXY if needed :
set/P HTTPS_PROXY=Enter HTTPS_PROXY if needed :

echo.
echo 1.GNU/WGET Init

set WGET=wget-%ARCHITECTURE%.exe

echo.
echo 2.Check Python Installation

set KEY_NAME=HKLM\Software\Python\PythonCore\2.7\InstallPath
if %ARCHITECTURE% == x64 (
  set KEY_NAME=HKLM\SOFTWARE\Python\PythonCore\2.7\InstallPath
Bezleputh's avatar
Bezleputh committed
)

set IsPythonInstalled=0

REG QUERY !KEY_NAME! >NUL 2>NUL
if %ERRORLEVEL% EQU 0 (
  set IsPythonInstalled=1
) else (
  rem first key doesn't exist, test the second possible key
  set KEY_NAME=HKCU\Software\Python\PythonCore\2.7\InstallPath
  REG QUERY !KEY_NAME! >NUL 2>NUL
  if %ERRORLEVEL% EQU 0 (
    set IsPythonInstalled=1
  )
)

if %IsPythonInstalled% EQU 1 (
  rem check installed python version
  for /F "tokens=4" %%A IN ('REG QUERY !KEY_NAME!') do (
    set PythonPath=%%A
  )

  !PythonPath!python.exe --version 2>&1 | find /i "!PYTHON_VERSION!" > tmp.txt
Bezleputh's avatar
Bezleputh committed
  if %ERRORLEVEL% EQU 1 (
    set IsPythonInstalled=0
  ) else (
    FOR /F "eol=; tokens=2 delims=." %%i in (tmp.txt) do set minor_version=%%i
Bezleputh's avatar
Bezleputh committed
    if !minor_version! LSS !PYTHON_MINOR_VERSION! (
      set IsPythonInstalled=0
    )
  )
  del tmp.txt
)

if %IsPythonInstalled% EQU 0 (
  rem Python is not installed
  set PYTHON_MSI=python-!PYTHON_VERSION!.msi
  if %ARCHITECTURE% == x64 (
    set PYTHON_MSI=python-!PYTHON_VERSION!.amd64.msi
  )

  echo 2.1 Download !PYTHON_MSI!
  "%WGET%" -o python_donwload --no-check-certificate "https://www.python.org/ftp/python/!PYTHON_VERSION!/!PYTHON_MSI!"
Bezleputh's avatar
Bezleputh committed

  echo 2.2 Setup !PYTHON_MSI!
  !PYTHON_MSI!

  del !PYTHON_MSI!
  del python_donwload
)

echo Retrieve Python path
rem check first possible key
set KEY_NAME=HKLM\Software\Python\PythonCore\2.7\InstallPath
if %ARCHITECTURE% == x64 (
  set KEY_NAME=HKLM\SOFTWARE\Python\PythonCore\2.7\InstallPath
)

REG QUERY !KEY_NAME! >NUL 2>NUL
if %ERRORLEVEL% EQU 1 (
  rem first key doesn't exist, test the second possible key
  set KEY_NAME=HKCU\Software\Python\PythonCore\2.7\InstallPath
)

Bezleputh's avatar
Bezleputh committed
for /F "tokens=4" %%A IN ('REG QUERY !KEY_NAME!') do (
  set PythonPath=%%A
)

echo.
echo 3.Check EasyInstall
if exist "%PythonPath%Scripts\easy_install.exe" (
  goto :step4
) else (
  echo 3.1 Install pip
  %PythonPath%python.exe get-pip.py || goto :InstallFailed
:step4
echo.
echo 4.PyQt5 Installation
%PythonPath%Scripts\easy_install.exe python-qt5 || goto :InstallFailed

Bezleputh's avatar
Bezleputh committed
echo.
echo 5.Check Gpg4win Installation
Bezleputh's avatar
Bezleputh committed
set ShouldReboot=0
set KEY_NAME=HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\GPG4Win
REG QUERY %KEY_NAME% > nul 2>NUL || (
  echo 5.1 Download Gpg4win
Bezleputh's avatar
Bezleputh committed
  "%WGET%" -o gpg4win_download http://files.gpg4win.org/gpg4win-2.2.2.exe

Bezleputh's avatar
Bezleputh committed
  gpg4win-2.2.2.exe

  set ShouldReboot=1

  del gpg4win-2.2.2.exe
  del gpg4win_download
)

echo.
echo 6.Install WeBoob
%PythonPath%Scripts\easy_install.exe weboob==!WEBOOB_VERSION! || goto 
:InstallFailed
Bezleputh's avatar
Bezleputh committed

set StartupFolder=%AppData%\Microsoft\Windows\Start Menu\Programs
if exist "%StartupFolder%" Goto :FoundStartup
set StartupFolder=%UserProfile%\Start Menu\Programs
if exist "%StartupFolder%" Goto :FoundStartup
echo Cannot find Startup folder.
echo do not create launchers
goto :InstallSucceed

:FoundStartup
if exist "%StartupFolder%\Weboob" (
  goto :CreateLauncher
Bezleputh's avatar
Bezleputh committed
) else (
  md "%StartupFolder%\Weboob"
  goto :CreateLauncher
Bezleputh's avatar
Bezleputh committed
)

:CreateLauncher
for %%i in (%LIST_APPLIQUATIONS_QT%) do (
  echo Process %%i
  (
    echo @echo off
    echo start %PythonPath%pythonw.exe %PythonPath%Scripts\%%i
  ) > %%i.bat
  %PythonPath%python.exe convertPNG2ICO.py "%PythonPath%\Lib\site-packages\%WEBOOB%\share\icons\hicolor\64x64\apps\%%i.png" > nul
  if exist "%StartupFolder%\Weboob\%%i.exe" (
    del "%StartupFolder%\Weboob\%%i.exe"
  )
  "Bat_To_Exe_Converter_%ARCHITECTURE%.exe" -bat "%%i.bat" -save "%StartupFolder%\Weboob\%%i.exe" -icon "%PythonPath%\Lib\site-packages\%WEBOOB%\share\icons\hicolor\64x64\apps\%%i.ico" "%%i"
  del "%%i.bat"
  del "%PythonPath%\Lib\site-packages\%WEBOOB%\share\icons\hicolor\64x64\apps\%%i.ico"
Bezleputh's avatar
Bezleputh committed
)

goto :InstallSucceed

:InstallSucceed

echo.
echo INSTALLATION PROCESS SUCCEED
if %ShouldReboot% EQU 1 (
  echo.
  echo YOU SHOULD REBOOT BEFORE USING WEBOOB
)
goto :Quit

:InstallFailed
echo.
echo INSTALLATION PROCESS FAILED
goto :Quit

:Quit

del .wget-hsts
del get-pip.py
Bezleputh's avatar
Bezleputh committed
del convertPNG2ICO.py
del settings.cmd

pause