diff options
author | Scott Moser <smoser@ubuntu.com> | 2015-03-04 17:09:32 -0500 |
---|---|---|
committer | Scott Moser <smoser@ubuntu.com> | 2015-03-04 17:09:32 -0500 |
commit | 56a594cb47342b89629e0876bd63b4e724d5e1a2 (patch) | |
tree | 787e72e1bba979810aa998eeab6eade13fbd06a4 /cloudinit/util.py | |
parent | 068ee3d324350fd998e2a27e5be2991ea9bab52f (diff) | |
parent | 5eb2aab5d010e7b8d5e4146959e50f2a9f67d504 (diff) | |
download | vyos-cloud-init-56a594cb47342b89629e0876bd63b4e724d5e1a2.tar.gz vyos-cloud-init-56a594cb47342b89629e0876bd63b4e724d5e1a2.zip |
Add util.message_from_string to wrap email.message_from_string.
This is to work-around the fact that email.message_from_string uses
cStringIO in Python 2.6, which can't handle Unicode.
Diffstat (limited to 'cloudinit/util.py')
-rw-r--r-- | cloudinit/util.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/cloudinit/util.py b/cloudinit/util.py index b6065410..971c1c2d 100644 --- a/cloudinit/util.py +++ b/cloudinit/util.py @@ -23,6 +23,7 @@ import contextlib import copy as obj_copy import ctypes +import email import errno import glob import grp @@ -2187,3 +2188,9 @@ def read_dmi_data(key): LOG.warn("did not find either path %s or dmidecode command", DMI_SYS_PATH) return None + + +def message_from_string(string): + if sys.version_info[:2] < (2, 7): + return email.message_from_file(six.StringIO(string)) + return email.message_from_string(string) |