Properly print non-strings with the TxtOutputter

After adding support for using different outputters for salt-call -g,
I noticed it would blow up with ran with --text-out as pythonpath
and cpu_flags aren't strings. Now just print the equiv of repr()
on non-strings and all will be well.
This commit is contained in:
Jeff Schroeder 2011-12-01 21:26:27 -08:00
parent 7a899b9236
commit aad52f503b

View File

@ -136,8 +136,12 @@ class TxtOutputter(Outputter):
if hasattr(data, "keys"):
for key in data.keys():
value = data[key]
for line in value.split('\n'):
print "{0}: {1}".format(key, line)
# Don't blow up on non-strings
try:
for line in value.split('\n'):
print "{0}: {1}".format(key, line)
except AttributeError:
print "key: %s" % value
else:
# For non-dictionary data, just use print
RawOutputter()(data)