~dobey/dirspec/python3

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
:: Author: Manuel de la Pena <manuel@canonical.com>
::
:: Copyright 2010-2011 Canonical Ltd.
::
:: This program is free software: you can redistribute it and/or modify it
:: under the terms of the GNU Lesser 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 PYTHONEXECPATH=""
:: 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 ('REG QUERY HKLM\Software\Python\PythonCore\2.7\InstallPath /ve') DO @SET PYTHONEXECPATH=%%A
IF NOT %PYTHONEXECPATH% == "" 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 ('REG QUERY HKLM\Software\Python\PythonCore\2.6\InstallPath /ve') DO @SET PYTHONEXECPATH=%%A
IF NOT %PYTHONEXECPATH% == "" GOTO :PYTHONPRESENT
:: we do not have python (2.6 or 2.7), therefore we go to end
ECHO Please ensure you have python installed
GOTO :END

:: Using trial.py is different on Windows, so we need to set PYTHONPATH
SET PYTHONPATH=.

:PYTHONPRESENT
ECHO Python found, executing the tests...
:: execute the tests with a number of ignored linux only modules
"%PYTHONEXECPATH%\python.exe" "%PYTHONEXECPATH%\Scripts\trial.py" dirspec
"%PYTHONEXECPATH%\python.exe" "%PYTHONEXECPATH%\Scripts\pyflakes" dirspec
:: test for style if we can, if pep8 is not present, move to the end
IF EXIST "%PYTHONEXECPATH%Scripts\pep8.exe"
"%PYTHONEXECPATH%\Scripts\pep8.exe" --repeat dirspec
ELSE
ECHO Style checks were not done
:: Delete the temp folders
RMDIR /s /q _trial_temp
RMDIR /s /q .coverage
:END