Skip to contentSkip to conversation

scripts/graph-build-time: clarify backend selection

PATCH New Luca Ceresoli 4 participants 6 messages Oct 12, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 scripts/graph-build-time: clarify backend selection

This instruction in the middle of 'import' lines looks very strange.

Also, it was not obvious to me what the 'Agg' backend is.

Both things are actually correct, but it took a while to find out why. So clarify with a comment to save someone else's time.

Cc Sascha Arthur <[email protected]>
Cc "Yann E. MORIN" <[email protected]>
Cc Thomas Petazzoni <[email protected]>
---
 support/scripts/graph-build-time | 5 +++++
 1 file changed, 5 insertions(+)
support/scripts/graph-build-time +5 -0
index 4bb90c2..b2817bd 100755
@@ -52,7 +52,12 @@
 import matplotlib as mpl
 import numpy
 
+# Use the Agg backend (which produces a PNG output, see
+# http://matplotlib.org/faq/usage_faq.html#what-is-a-backend),
+# otherwise an incorrect backend is used on soe host machines).
+# Note: matplotlib.use() must be called *before* matplotlib.pyplot.
 mpl.use('Agg')
+
 import matplotlib.pyplot as plt
 import matplotlib.font_manager as fm
 import csv
Signature · 1 line
1.9.1
#1 lore raw

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

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.

---
 support/scripts/graph-build-time | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
support/scripts/graph-build-time +8 -3
index b2817bd..fbb3d52 100755
@@ -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',
Signature · 1 line
1.9.1
#2 lore raw

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

Quoted 7 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Luca" == Luca Ceresoli <[email protected]> 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.

Committed, thanks.

Signature · 1 line
Bye, Peter Korsgaard
#3 lore raw

PATCH 1/2 scripts/graph-build-time: clarify backend selection

In reply to Luca Ceresoli

Luca, All,

On 2014-10-12 12:52 +0200, Luca Ceresoli spake thusly:

Quoted 4 lines

This instruction in the middle of 'import' lines looks very strange.

Also, it was not obvious to me what the 'Agg' backend is.

Quoted 8 lines

Both things are actually correct, but it took a while to find out why. So clarify with a comment to save someone else's time.

Cc Sascha Arthur <[email protected]>
Cc "Yann E. MORIN" <[email protected]>
Cc Thomas Petazzoni <[email protected]>

Except for a little typo:

Quoted 9 lines
---
 support/scripts/graph-build-time | 5 +++++
 1 file changed, 5 insertions(+)
support/scripts/graph-build-time +0 -0
index 4bb90c2..b2817bd 100755

support/scripts/graph-build-time line 57

Quoted 6 lines
support/scripts/graph-build-time +3 -0
@@ -52,7 +52,12 @@
 import matplotlib as mpl
 import numpy
 
+# Use the Agg backend (which produces a PNG output, see
+# http://matplotlib.org/faq/usage_faq.html#what-is-a-backend),
+# otherwise an incorrect backend is used on soe host machines).

s/soe/smoe/

Regards,
Yann E. MORIN.

Quoted 9 lines
support/scripts/graph-build-time +2 -0
+# Note: matplotlib.use() must be called *before* matplotlib.pyplot.
 mpl.use('Agg')
+
 import matplotlib.pyplot as plt
 import matplotlib.font_manager as fm
 import csv
Signature · 1 line
1.9.1
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#4 lore raw

PATCH 1/2 scripts/graph-build-time: clarify backend selection

"Yann E. MORIN" <[email protected]> schreef:

Quoted 32 lines

Luca, All,

On 2014-10-12 12:52 +0200, Luca Ceresoli spake thusly:

Quoted 4 lines

This instruction in the middle of 'import' lines looks very strange.

Also, it was not obvious to me what the 'Agg' backend is.

Quoted 8 lines

Both things are actually correct, but it took a while to find out why. So clarify with a comment to save someone else's time.

Cc Sascha Arthur <[email protected]>
Cc "Yann E. MORIN" <[email protected]>
Cc Thomas Petazzoni <[email protected]>

Except for a little typo:

Quoted 12 lines
---
 support/scripts/graph-build-time | 5 +++++
 1 file changed, 5 insertions(+)
support/scripts/graph-build-time +0 -0
index 4bb90c2..b2817bd 100755
@@ -52,7 +52,12 @@
 import matplotlib as mpl
 import numpy
 
Quoted 5 lines

support/scripts/graph-build-time line 57

Quoted 3 lines
support/scripts/graph-build-time +3 -0
+# Use the Agg backend (which produces a PNG output, see
+# http://matplotlib.org/faq/usage_faq.html#what-is-a-backend),
+# otherwise an incorrect backend is used on soe host machines).

s/soe/smoe/

Are you sure? ;-)

#5 lore raw

PATCH 1/2 scripts/graph-build-time: clarify backend selection

In reply to Luca Ceresoli
Quoted 5 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Luca" == Luca Ceresoli <[email protected]> writes:

This instruction in the middle of 'import' lines looks very strange. Also, it was not obvious to me what the 'Agg' backend is.

Quoted 8 lines

Both things are actually correct, but it took a while to find out why. So clarify with a comment to save someone else's time.

Cc Sascha Arthur <[email protected]>
Cc "Yann E. MORIN" <[email protected]>
Cc Thomas Petazzoni <[email protected]>

Committed with the typo fixed, thanks.

Signature · 1 line
Bye, Peter Korsgaard