~cloud-init-dev/cloud-init/trunk

« back to all changes in this revision

Viewing changes to cloudinit/user_data.py

  • Committer: Barry Warsaw
  • Date: 2015-01-21 22:56:53 UTC
  • mto: This revision was merged to the branch mainline in revision 1054.
  • Revision ID: barry@python.org-20150121225653-331tcuhwd1szidkh
Largely merge lp:~harlowja/cloud-init/py2-3 albeit manually because it seemed
to be behind trunk.

`tox -e py27` passes full test suite.  Now to work on replacing mocker.

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
from email.mime.nonmultipart import MIMENonMultipart
30
30
from email.mime.text import MIMEText
31
31
 
 
32
import six
 
33
 
32
34
from cloudinit import handlers
33
35
from cloudinit import log as logging
34
36
from cloudinit import util
235
237
                resp = util.read_file_or_url(include_url,
236
238
                                             ssl_details=self.ssl_details)
237
239
                if include_once_on and resp.ok():
238
 
                    util.write_file(include_once_fn, str(resp), mode=0600)
 
240
                    util.write_file(include_once_fn, str(resp), mode=0o600)
239
241
                if resp.ok():
240
242
                    content = str(resp)
241
243
                else:
256
258
            #    filename and type not be present
257
259
            # or
258
260
            #  scalar(payload)
259
 
            if isinstance(ent, (str, basestring)):
 
261
            if isinstance(ent, six.string_types):
260
262
                ent = {'content': ent}
261
263
            if not isinstance(ent, (dict)):
262
264
                # TODO(harlowja) raise?
337
339
    data = util.decomp_gzip(raw_data)
338
340
    if "mime-version:" in data[0:4096].lower():
339
341
        msg = email.message_from_string(data)
340
 
        for (key, val) in headers.iteritems():
 
342
        for (key, val) in headers.items():
341
343
            _replace_header(msg, key, val)
342
344
    else:
343
345
        mtype = headers.get(CONTENT_TYPE, NOT_MULTIPART_TYPE)