~mvo/ubuntu-sso-client/strawman-lp711413

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
:: Copyright 2010-12 Canonical Ltd.
::
:: This program is free software: you can redistribute it and/or modify it
:: under the terms of the GNU General Public License version 3, as published
:: by the Free Software Foundation.
::
:: This program is distributed in the hope that it will be useful, but
:: WITHOUT ANY WARRANTY; without even the implied warranties of
:: MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
:: PURPOSE.  See the GNU General Public License for more details.
::
:: You should have received a copy of the GNU General Public License along
:: with this program.  If not, see <http://www.gnu.org/licenses/>.

@ECHO off

:: We could have Python 2.6 or 2.7 on Windows. In order to check availability,
:: we should first check for 2.7, and run the tests, otherwise fall back to 2.6.
SET REGQUERY27="REG QUERY HKLM\Software\Python\PythonCore\2.7\InstallPath /ve"
SET REGQUERY2732="REG QUERY HKLM\Software\Wow6432Node\Python\PythonCore\2.7\InstallPath /ve"
SET REGQUERY26="REG QUERY HKLM\Software\Python\PythonCore\2.6\InstallPath /ve"
SET REGQUERY2632="REG QUERY HKLM\Software\Wow6432Node\Python\PythonCore\2.6\InstallPath /ve"
SET PYTHONEXEPATH=""

:: This is very annoying; FOR /F will work differently depending on the output
:: of reg which is not consistent between OS versions (XP, 7). We must choose
:: the tokens according to OS version.
::
SET PYTHONPATHTOKENS=3
VER | FIND "XP" > nul
IF %ERRORLEVEL% == 0 (
    SET PYTHONPATHTOKENS=4)

ECHO Checking if python 2.7 is in the system

:: Look for python 2.7
FOR /F "tokens=%PYTHONPATHTOKENS%" %%A IN ('%REGQUERY27%') DO @SET PYTHONEXEPATH=%%A

IF NOT %PYTHONEXEPATH% == "" (
    GOTO :PYTHONPRESENT)

ECHO Checking if python 2.6 is in the system
:: we do not have python 2.7 in the system, try to find 2.6
FOR /F "tokens=%PYTHONPATHTOKENS%" %%A IN ('%REGQUERY26%') DO @SET PYTHONEXEPATH=%%A

IF NOT %PYTHONEXEPATH% == "" (
    GOTO :PYTHONPRESENT)

:: we do not have python (2.6 or 2.7) this could hapen in the case  that the
:: user installed the 32version in a 64 machine, let check if the software was installed in the wow key

:: Look for python 2.7 in WoW64
ECHO Checking if python 2.7 32 is in the system
FOR /F "tokens=%PYTHONPATHTOKENS%" %%A IN ('%REGQUERY2732%') DO @SET PYTHONEXEPATH=%%A

IF NOT %PYTHONEXEPATH% == "" (
    GOTO :PYTHONPRESENT)

ECHO Checking if python 2.6 32 is in the system
:: we do not have python 2.7 in the system, try to find 2.6
FOR /F "tokens=%PYTHONPATHTOKENS%" %%A IN ('%REGQUERY2632%') DO @SET PYTHONEXEPATH=%%A
IF NOT %PYTHONEXEPATH% == "" (
    GOTO :PYTHONPRESENT)

ECHO Please ensure you have python installed
GOTO :END


:PYTHONPRESENT

:: throw the first parameter away if is /skip-lint,
:: the way we do this is to ensure that /skip-lint
:: is the first parameter and copy all the rest in a loop
:: the main reason for that is that %* is not affected
:: by SHIFT, that is, it allways have all passed parameters

SET PARAMS=%*
SET SKIPLINT=0
IF "%1" == "/skip-lint" (
    SET SKIPLINT=1
    GOTO :CLEANPARAMS
)ELSE (
    GOTO :CONTINUEBATCH)

:CLEANPARAMS
SHIFT
SET PARAMS=%1
:GETREST
SHIFT
if [%1]==[] (
    GOTO CONTINUEBATCH)
SET PARAMS=%PARAMS% %1
GOTO GETREST
:CONTINUEBATCH

ECHO Python found, building auto-generated modules...
:: call setup.py build so that the qt uic is called
::START "Build code" /D%CD% /WAIT "%PYTHONEXEPATH%\python.exe" setup.py build
"%PYTHONEXEPATH%\python.exe" setup.py build
ECHO Running tests
:: execute the tests with a number of ignored linux only modules
"%PYTHONEXEPATH%\python.exe" "%PYTHONEXEPATH%\Scripts\u1trial" -i "test_linux.py, test_txsecrets.py" -p "ubuntu_sso\gtk" --reactor=qt4 --gui %PARAMS% ubuntu_sso 
:: Clean the build from the setupt.py
ECHO Cleaning the generated code
"%PYTHONEXEPATH%\python.exe" setup.py clean

IF %SKIPLINT% == 1 (
    ECHO Skipping style checks
    GOTO :CLEAN)

ECHO Performing style checks...
SET IGNORE_LINT="ubuntu_sso\gtk,ubuntu_sso\networkstate\linux.py,ubuntu_sso\main\linux.py,ubuntu_sso\main\tests\test_linux.py,ubuntu_sso\utils\txsecrets.py,ubuntu_sso\utils\tests\test_txsecrets.py,ubuntu_sso\tests\bin,bin\ubuntu-sso-login"
"%PYTHONEXEPATH%\python.exe" "%PYTHONEXEPATH%\Scripts\u1lint" -i "%IGNORE_LINT%" ubuntu_sso
:: test for style if we can, if pep8 is not present, move to the end
"%PYTHONEXEPATH%\Scripts\pep8.exe" --repeat .
:CLEAN
:: Delete the temp folders
RMDIR /q /s _trial_temp
DEL /q .coverage
:END