This repository has been archived by the owner on Nov 3, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathrun.bat
126 lines (104 loc) · 3.76 KB
/
run.bat
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
121
122
123
124
125
126
@echo off
set find=c:\windows\system32\find.exe
set rndfile=%temp%\%random%.txt
set venv_dir=certsuite_venv
set has_choco=
set has_python=
set has_pip=
set has_virtualenv=
set has_adb=
set has_powershell=
rem main
call:check_powershell has_powershell
if not "%has_powershell%" == "1" echo Please install powershell manually and run again. & goto:eof
call:check_choco has_choco
if not "%has_choco%" == "1" call:install_choco has_choco
if not "%has_choco%" == "1" echo Install chocolatey failed. Find solutions on http://chocolatey.org and run again & goto:eof
call:check_pip has_pip
if not "%has_pip%" == "1" call:install_pip has_pip
if not "%has_pip%" == "1" echo Install easy_install failed. Find solutions on https://chocolatey.org/packages/easy.install and run again & goto:eof
call:check_virtualenv has_virtualenv
if not "%has_virtualenv%" == "1" call:install_virtualenv has_virtualenv
if not "%has_virtualenv%" == "1" echo Install virtualenv failed. Find solutions on https://virtualenv.pypa.io/en/latest/ and run again & goto:eof
call:check_adb has_adb
if not "%has_adb%" == "1" call:install_adb has_adb
if not "%has_adb%" == "1" echo Install adb failed. Find solutions on https://developer.android.com/tools/help/adb.html and run again & goto:eof
if not exist %venv_dir%\nul virtualenv --no-site-packages %venv_dir%
if not exist %venv_dir%\nul echo error creating virtualenv %venv_dir%, resovle this issue and run again & goto:eof
call %venv_dir%\Scripts\activate.bat
python setup.py install
echo "Done, running the suite"
runcertsuite %*
deactivate
set find=
set rndfile=
set has_choco=
set has_python=
set has_pip=
set has_virtualenv=
set has_adb=
set has_powershell=
set venv_dir=
rem end of main
goto:eof
rem temparory code
if "%has_powershell%" == "1" echo has powershell
if "%has_choco%" == "1" echo has choco
if "%has_python%" == "1" echo has python
if "%has_pip%" == "1" echo has pip
if "%has_adb%" == "1" echo has adb
if "%has_virtualenv%" == "1" echo has virtualenv
if not "%has_choco%" == "1" call:install_choco has_choco
if "%has_choco%" == "1" echo has choco
goto:eof
rem local function defines
:install_choco - passing a variable by reference
echo installing chocolatey
rem @powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))" && SET PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin
call:check_choco %~1
goto:eof
:install_python - passing a variable by reference
echo installing python
cinst python2
call:check_python %~1
goto:eof
:install_pip - passing a variable by reference
echo installing pip
cinst easy.install
call:check_pip %~1
goto:eof
:install_virtualenv - passing a variable by reference
echo installing virtualenv
pip install virtualenv
call:check_virtualenv %~1
goto:eof
:check_choco - passing a variable by reference
set "%~1=0"
choco > %rndfile% 2>&1
for /F %%i in ('type %rndfile% ^| %find% "Chocolatey"') do set "%~1=1"
goto:eof
:check_python - passing a variable by reference
set "%~1=0"
python --version > %rndfile% 2>&1
for /F %%i in ('type %rndfile% ^| %find% "Python"') do set "%~1=1"
goto:eof
:check_pip - passing a variable by reference
set "%~1=0"
pip list > %rndfile% 2>&1
for /F %%i in ('type %rndfile% ^| %find% "pip"') do set "%~1=1"
goto:eof
:check_virtualenv - passing a variable by reference
set "%~1=0"
virtualenv > %rndfile% 2>&1
for /F %%i in ('type %rndfile% ^| %find% "You must provide a DEST_DIR"') do set "%~1=1"
goto:eof
:check_adb - passing a variable by reference
set "%~1=0"
adb devices > %rndfile% 2>&1
for /F %%i in ('type %rndfile% ^| %find% "attached"') do set "%~1=1"
goto:eof
:check_powershell - passing a variable by reference
set "%~1=0"
powershell -h > %rndfile% 2>&1
for /F %%i in ('type %rndfile% ^| %find% "Windows PowerShell"') do set "%~1=1" & goto:eof
goto:eof