From 2514eb9717ab6f8161d1fb403ca2bfff9e1169ea Mon Sep 17 00:00:00 2001 From: Tiago Gomes Date: Fri, 16 Aug 2013 08:32:41 +0000 Subject: Utility function to convert all values in a dictionary to strings This will be useful in the next commit, where we want to construct an environment to run a command from a dictionary. The cliapp runcmd method expects that the values in this dictionary are strings, so we need to convert them before. --- morphlib/util.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'morphlib/util.py') diff --git a/morphlib/util.py b/morphlib/util.py index 7526c93c..22288cac 100644 --- a/morphlib/util.py +++ b/morphlib/util.py @@ -361,7 +361,6 @@ def parse_environment_pairs(env, pairs): return dict(env.items() + extra_env.items()) - def get_host_architecture(): # pragma: no cover '''Get the canonical Morph name for the host's architecture.''' @@ -381,3 +380,8 @@ def get_host_architecture(): # pragma: no cover raise morphlib.Error('Unknown host architecture %s' % machine) return table[machine] + + +def sanitize_environment(env): + for k in env: + env[k] = str(env[k]) -- cgit v1.2.1