diff options
authorEdward Cragg <>2016-02-24 18:06:07 (GMT)
committerEdward Cragg <>2016-02-25 15:56:26 (GMT)
commitfb6dd955cbc7081f47dc43919075dc4eb3809172 (patch)
parent7e15ed7080c45f5283938e86af33fe4794b91b43 (diff)
Validate empty configure/build/test/install commands
If a command in a chunk is evaluated to None when a morphology is loaded, this would previously lead to the subprocess module throwing a 'Coercing to Unicode' error when morph attempts to run the command during the chunk build. This change throws a more helpful error if any commands are not valid strings when the chunk is validated, for example: ERROR: Field configure-commands[217] expected type <type 'str'>, got <type 'NoneType'> in morphology linux-jetson-tk1 Change-Id: I45220e7deab8c7cd9351507bc998f7ff12797442
1 files changed, 13 insertions, 0 deletions
diff --git a/morphlib/ b/morphlib/
index ff433d7..d7f0fe7 100644
--- a/morphlib/
+++ b/morphlib/
@@ -585,12 +585,25 @@ class MorphologyLoader(object):
morphology['products'], errors)
+ for key in MorphologyDumper.keyorder:
+ if key.endswith('-commands') and key in morphology:
+ cls._validate_commands(morphology['name'], key,
+ morphology[key], errors)
if len(errors) == 1:
raise errors[0]
elif errors:
raise MultipleValidationErrors(morphology['name'], errors)
+ def _validate_commands(cls, morphology_name, key, commands, errors):
+ for cmd_index, cmd in enumerate(commands):
+ if not isinstance(cmd, basestring):
+ e = InvalidTypeError('%s[%d]' % (key, cmd_index),
+ str, type(cmd), morphology_name)
+ errors.append(e)
+ @classmethod
def _validate_products(cls, morphology_name, products, errors):
'''Validate the products field is of the correct type.'''
if (not isinstance(products, collections.Iterable)