Skip to content

Commit 4f70ecb

Browse files
committed
Silently execute dependency monitoring tools (unless they fail)
Before, we'd dump the output to /dev/null. Unfortunately, when things go wrong the user gets no feedback. Now, we monitor the process, and if it fails dumps stdout and stderr. Also a minor fix to the Python dependency monitor: a regexp that can handle packages with '-' in the name.
1 parent 4ef2f85 commit 4f70ecb

File tree

4 files changed

+54
-15
lines changed

4 files changed

+54
-15
lines changed

Makefile

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,18 @@ bundle = ./public/build/bundle.js
77
webpack = ./node_modules/.bin/webpack
88

99

10-
dev_dependencies:
11-
@./tools/install_deps.py requirements.dev.txt
12-
1310
dependencies:
14-
@./tools/install_deps.py requirements.txt
15-
@./tools/check_js_deps.sh
11+
@./tools/silent_monitor.py ./tools/install_deps.py requirements.txt
12+
@./tools/silent_monitor.py ./tools/check_js_deps.sh
1613

1714
db_init:
18-
./tools/db_create.sh
15+
@./tools/silent_monitor.py ./tools/db_create.sh
1916

2017
db_drop:
21-
PYTHONPATH=. ./tools/db_drop.py
18+
@PYTHONPATH=. ./tools/silent_monitor.py ./tools/db_drop.py
2219

2320
db_test_data:
24-
PYTHONPATH=. python ./cesium_app/models.py
21+
@PYTHONPATH=. python ./cesium_app/models.py
2522

2623
$(bundle): webpack.config.js package.json
2724
$(webpack)
@@ -32,9 +29,9 @@ bundle-watch:
3229
$(webpack) -w
3330

3431
paths:
35-
mkdir -p log run tmp
36-
mkdir -p log/sv_child
37-
mkdir -p ~/.local/cesium/logs
32+
@mkdir -p log run tmp
33+
@mkdir -p log/sv_child
34+
@mkdir -p ~/.local/cesium/logs
3835

3936
log: paths
4037
./tools/watch_logs.py
@@ -68,5 +65,5 @@ docker-images:
6865

6966
# Call this target to see which Javascript dependencies are not up to date
7067
check-js-updates:
71-
@./tools/check_js_updates.sh
68+
./tools/check_js_updates.sh
7269

tools/check_js_deps.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,16 @@ set -e
55
CHECKER='./node_modules/.bin/check-dependencies'
66

77
if [[ ! -x ${CHECKER} ]]; then
8-
npm install check-dependencies > /dev/null 2>&1
8+
npm install check-dependencies
99
fi
1010

1111
# We suppress output for the next command because, annoyingly, it reports
1212
# that a dependency is unsatisfied even if the --install flag is specified,
1313
# and that package has been successfully installed
14-
${CHECKER} --install > /dev/null 2>&1
14+
${CHECKER} --install
1515

1616
# Print report, if any unsatisfied dependencies remain
1717
if ${CHECKER}; then
1818
echo "✓ All Javascript dependencies satisfied."
1919
fi
20+

tools/install_deps.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
if '-e' in dep:
2626
dep = dep.split('#egg=')[-1] # use the egg name
2727
else:
28-
dep = re.split('\W+', dep)[0] # discard version info
28+
dep = re.split('[^\w\-]+', dep)[0] # discard version info
2929

3030
try:
3131
__import__(pkg_import.get(dep, dep))

tools/silent_monitor.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/usr/bin/env python
2+
3+
import subprocess
4+
import sys
5+
import shlex
6+
7+
if len(sys.argv) < 2:
8+
print('Usage: silent_monitor.py <cmd to execute>')
9+
sys.exit()
10+
11+
cmd = ' '.join(sys.argv[1:])
12+
13+
tag = 'Silently executing: {}'.format(cmd)
14+
print('[·] {}'.format(tag), end='')
15+
sys.stdout.flush()
16+
17+
p = subprocess.Popen(shlex.split(cmd),
18+
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
19+
20+
err = p.wait()
21+
stdout, stderr = p.stderr.read().strip(), p.stdout.read().strip()
22+
23+
if err == 0:
24+
print('\r[✓] {}'.format(tag))
25+
else:
26+
print('\r[✗] {}'.format(tag))
27+
print('\n! Failure (exit code {}).'.format(err, cmd))
28+
29+
if stdout:
30+
print('--- stdout ---')
31+
print(stdout.decode('utf-8'))
32+
33+
if stderr:
34+
print('--- stderr ---')
35+
print(stderr.decode('utf-8'))
36+
37+
if stdout or stderr:
38+
print('--- end ---')
39+
40+
sys.exit(err)
41+

0 commit comments

Comments
 (0)