diff options
author | Scott Moser <smoser@ubuntu.com> | 2015-02-25 19:40:33 -0500 |
---|---|---|
committer | Scott Moser <smoser@ubuntu.com> | 2015-02-25 19:40:33 -0500 |
commit | 8cd5d7b143f882d80d45b1c04bdde1949846d4f1 (patch) | |
tree | 066a65a504d1409f9caa5d1298e07caa337064e8 /tests/unittests/helpers.py | |
parent | e2fea567772f3d178072607aee617c3792185db0 (diff) | |
download | vyos-cloud-init-8cd5d7b143f882d80d45b1c04bdde1949846d4f1.tar.gz vyos-cloud-init-8cd5d7b143f882d80d45b1c04bdde1949846d4f1.zip |
move towards user-data being binary
UrlResponse: biggest change... make readurl return bytes, making user
know what to do with it.
util: add load_tfile_or_url for loading text file or url
as read_file_or_url now returns bytes
ec2_utils: all meta-data is text, remove non-obvious string translations
DigitalOcean: adjust for ec2_utils
DataSourceGCE, DataSourceMAAS: user-data is binary other fields are text.
openstack.py: read paths without decoding to text. This is ok as paths
other than user-data are json, and load_json will handle
load_file still returns text, and that is what most things use.
Diffstat (limited to 'tests/unittests/helpers.py')
-rw-r--r-- | tests/unittests/helpers.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/tests/unittests/helpers.py b/tests/unittests/helpers.py index 7516bd02..24e1e881 100644 --- a/tests/unittests/helpers.py +++ b/tests/unittests/helpers.py @@ -288,7 +288,10 @@ def populate_dir(path, files): os.makedirs(path) for (name, content) in files.items(): with open(os.path.join(path, name), "wb") as fp: - fp.write(content.encode('utf-8')) + if isinstance(content, six.binary_type): + fp.write(content) + else: + fp.write(content.encode('utf-8')) fp.close() |