except ImportError:
import simplejson as json
+from common.utils import unicode_to_str
+
def trigger_next(job_name, data):
print "====LOG:TRIGGER_NEXT:%s ========================================" %job_name.upper()
with open("%s.env" %job_name, 'w') as fh:
for key in data.keys():
print "%s='%s'" %(key, data[key])
print "====LOG:TRIGGER_NEXT:========================================end=="
+
def trigger_info(TRIGGER_INFO):
print "====LOG:TRIGGER_INFO:========================================"
- content_dict = json.loads(base64.b64decode(TRIGGER_INFO))
+ content_dict = unicode_to_str(json.loads(base64.b64decode(TRIGGER_INFO)))
print json.dumps(content_dict, indent = 4)
print "====LOG:TRIGGER_INFO:========================================end=="
return content_dict
return runner.outs('readlink %s' % path)
else:
return os.path.basename(path)
+
+def unicode_to_str(obj):
+ """convert unicode object to str"""
+
+ if isinstance(obj, list):
+ return [unicode_to_str(element) for element in obj]
+ elif isinstance(obj, dict):
+ return {unicode_to_str(key) : unicode_to_str(value) for key, value in obj.iteritems()}
+ elif isinstance(obj, unicode):
+ return obj.encode('utf-8')
+ else:
+ return obj