diff mbox

[2/2] scripts/graph-build-time: properly warn about missing modules

Message ID 1413111142-17643-2-git-send-email-luca@lucaceresoli.net
State Accepted
Commit 9722381c0da7203c725c8f589cd84b4c55f8c9a7
Headers show

Commit Message

Luca Ceresoli Oct. 12, 2014, 10:52 a.m. UTC
Currently the graph-build-time script prints a python exception if a
needed module cannot be imported. Catch the exception and tell the user
which packages are missing, as we do for other missing dependencies.

Signed-off-by: Luca Ceresoli <luca@lucaceresoli.net>
---
 support/scripts/graph-build-time | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

Comments

Peter Korsgaard Oct. 12, 2014, 3:23 p.m. UTC | #1
>>>>> "Luca" == Luca Ceresoli <luca@lucaceresoli.net> writes:

 > Currently the graph-build-time script prints a python exception if a
 > needed module cannot be imported. Catch the exception and tell the user
 > which packages are missing, as we do for other missing dependencies.

 > Signed-off-by: Luca Ceresoli <luca@lucaceresoli.net>

Committed, thanks.
diff mbox

Patch

diff --git a/support/scripts/graph-build-time b/support/scripts/graph-build-time
index b2817bd..fbb3d52 100755
--- a/support/scripts/graph-build-time
+++ b/support/scripts/graph-build-time
@@ -49,8 +49,14 @@ 
 #   * argparse (by default in Python 2.7, requires python-argparse if
 #     Python 2.6 is used)
 
-import matplotlib as mpl
-import numpy
+import sys
+
+try:
+    import matplotlib as mpl
+    import numpy
+except ImportError:
+    sys.stderr.write("You need python-matplotlib and python-numpy to generate build graphs\n")
+    exit(1)
 
 # Use the Agg backend (which produces a PNG output, see
 # http://matplotlib.org/faq/usage_faq.html#what-is-a-backend),
@@ -62,7 +68,6 @@  import matplotlib.pyplot as plt
 import matplotlib.font_manager as fm
 import csv
 import argparse
-import sys
 
 steps = [ 'extract', 'patch', 'configure', 'build',
           'install-target', 'install-staging', 'install-images',