Add recursive strip_unicode function to utils.py

This is useful for untangling the revolting mess JSON rpc calls make

Signed-off-by: Martin Bligh <mbligh@google.com>



git-svn-id: http://test.kernel.org/svn/autotest/trunk@2443 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/client/common_lib/utils.py b/client/common_lib/utils.py
index 287222b..d89f6cc 100644
--- a/client/common_lib/utils.py
+++ b/client/common_lib/utils.py
@@ -513,6 +513,20 @@
     return out
 
 
+def strip_unicode(input):
+    if type(input) == list:
+        return [strip_unicode(i) for i in input]
+    elif type(input) == dict:
+        output = {}
+        for key in input.keys():
+            output[str(key)] = strip_unicode(input[key])
+        return output
+    elif type(input) == unicode:
+        return str(input)
+    else:
+        return input
+
+
 def get_cpu_percentage(function, *args, **dargs):
     """Returns a tuple containing the CPU% and return value from function call.