-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path_Check_Dependencies.bat
237 lines (219 loc) · 5.81 KB
/
_Check_Dependencies.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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
::=============================================================::
:: DEVELOPED 2015, REVISED 2015, Jeff Rimko. ::
::=============================================================::
::=============================================================::
:: SECTION: Environment Setup ::
::=============================================================::
@set TITLE=%~n0 "%~dp0"
@cd /d %~dp0 && echo off && title %TITLE%
::=============================================================::
:: SECTION: Main Body ::
::=============================================================::
call:ChkDep^
"Python"^
"Python language interpreter."^
"www.python.org"^
"2.7/3.x"^
python -V
call:ChkDep^
"Docopt"^
"Python library CLI argument handling."^
"https://pypi.python.org/pypi/docopt"^
"latest"^
python -c "import docopt"
call:ChkDep^
"PyYaml"^
"Python library for YAML."^
"https://pypi.python.org/pypi/pyyaml"^
"latest"^
python -c "import yaml"
call:ChkDep^
"Verace"^
"Python library for version checking."^
"https://pypi.python.org/pypi/verace"^
"latest"^
python -c "import verace"
call:ChkDep^
"Qprompt"^
"Python library for CLI."^
"https://pypi.python.org/pypi/qprompt"^
"latest"^
python -c "import qprompt"
call:ChkDep^
"Binaryornot"^
"Python library for checking filetypes."^
"https://pypi.python.org/pypi/binaryornot"^
"latest"^
python -c "import binaryornot"
call:ChkDep^
"Jinja2"^
"Python template library."^
"https://pypi.python.org/pypi/jinja2"^
"latest"^
python -c "import jinja2"
call:ChkDep^
"Jinja2schema"^
"Python template checking library."^
"https://pypi.python.org/pypi/jinja2schema"^
"latest"^
python -c "import jinja2schema"
call:ChkDep^
"Jinja2_time"^
"Jinja2 extension for time."^
"https://pypi.python.org/pypi/jinja2_time"^
"latest"^
python -c "import jinja2_time"
call:ChkDep^
"Requests"^
"Python library for HTTP."^
"https://pypi.python.org/pypi/requests"^
"latest"^
python -c "import requests"
call:ChkDep^
"Auxly"^
"Python helper library."^
"https://pypi.python.org/pypi/auxly"^
"latest"^
python -c "import auxly"
pause
exit /b 0
::=============================================================::
:: SECTION: Function Definitions ::
::=============================================================::
::-------------------------------------------------------------::
:: Checks if a dependency is available.
::
:: **Params**:
:: - 1 - Name of dependency.
:: - 2 - Description of dependency.
:: - 3 - Reference website or where to obtain info.
:: - 4 - Recommended version.
:: - 5+ - Non-blocking command to check if installed; usually version display
:: or help.
::
:: **Attention**:
:: Do not use quotes around the non-blocking command.
:: Quotes may be included in the remaining params if they are needed for the
:: non-blocking call.
::
:: **Preconditions**:
:: The global variable DEP_OK should be set to 1 before the first call to this
:: function.
::
:: **Postconditions**:
:: The global variable DEP_OK will be set to 0 if a dependency check fails.
:: This variable is not set back to 1 by this function, it may be explicitly
:: set outside the function
::
:: **Example**:
:: call::ChkDep^
:: "Utility"^
:: "Does something."^
:: "www.website.com"^
:: "1.2.3"^
:: utility -h
:: call::ChkDep^
:: "Utility"^
:: "Does something."^
:: "www.website.com"^
:: "1.2.3"^
:: utility -c "non-blocking cmd"
::-------------------------------------------------------------::
:ChkDep
echo Checking dependency %~1...
shift
echo %~1
shift
echo Reference: %~1
shift
echo Recommended version: %~1
shift
echo --------
set CMD=%1
shift
:chkdep_shift_next
if [%1] neq [] (
set CMD=%CMD% %1
shift
goto:chkdep_shift_next
)
%CMD% > NUL 2>&1
if %ERRORLEVEL% neq 0 (
echo NOT FOUND!
set DEP_OK=0
goto:eof
)
echo OK.
goto:eof
::-------------------------------------------------------------::
:: Checks if a dependency is available and is the required version.
::
:: **Params**:
:: - 1 - Name of dependency.
:: - 2 - Description of dependency.
:: - 3 - Reference website or where to obtain info.
:: - 4 - Required version.
:: - 5+ - Non-blocking command to check if installed; usually version display
:: or help.
::
:: **Attention**:
:: Do not use quotes around the non-blocking command.
:: Quotes may be included in the remaining params if they are needed for the
:: non-blocking call.
::
:: **Preconditions**:
:: The global variable DEP_OK should be set to 1 before the first call to this
:: function.
::
:: **Postconditions**:
:: The global variable DEP_OK will be set to 0 if a dependency check fails.
:: This variable is not set back to 1 by this function, it may be explicitly
:: set outside the function
::
:: **Example**:
:: call::ChkDepVer^
:: "Utility"^
:: "Does something."^
:: "www.website.com"^
:: "1.2.3"^
:: utility -h
:: call::ChkDepVer^
:: "Utility"^
:: "Does something."^
:: "www.website.com"^
:: "1.2.3"^
:: utility -c "non-blocking cmd"
::-------------------------------------------------------------::
:ChkDepVer
echo Checking dependency for %~1...
shift
echo %~1
shift
echo Reference: %~1
shift
set DEP_VER=%~1
echo Required version: %DEP_VER%
shift
echo --------
set CMD=%1
shift
:chkdepver_shift_next
if [%1] neq [] (
set CMD=%CMD% %1
shift
goto:chkdepver_shift_next
)
%CMD% > NUL 2>&1
if %ERRORLEVEL% neq 0 (
echo NOT FOUND!
set DEP_OK=0
goto:eof
)
%CMD% 2>&1 | find "%DEP_VER%" >NUL
if %ERRORLEVEL% neq 0 (
echo NOT FOUND!
set DEP_OK=0
goto:eof
)
echo OK.
goto:eof