summaryrefslogtreecommitdiff
path: root/cloudinit
diff options
context:
space:
mode:
Diffstat (limited to 'cloudinit')
-rwxr-xr-xcloudinit/reporting/handlers.py10
-rw-r--r--cloudinit/safeyaml.py2
-rw-r--r--cloudinit/sources/DataSourceNoCloud.py2
-rw-r--r--cloudinit/templater.py4
-rw-r--r--cloudinit/tests/test_subp.py8
5 files changed, 13 insertions, 13 deletions
diff --git a/cloudinit/reporting/handlers.py b/cloudinit/reporting/handlers.py
index 0a8c7af3..e32739ef 100755
--- a/cloudinit/reporting/handlers.py
+++ b/cloudinit/reporting/handlers.py
@@ -137,8 +137,8 @@ class HyperVKvpReportingHandler(ReportingHandler):
self._event_types = event_types
self.q = queue.Queue()
self.incarnation_no = self._get_incarnation_no()
- self.event_key_prefix = u"{0}|{1}".format(self.EVENT_PREFIX,
- self.incarnation_no)
+ self.event_key_prefix = "{0}|{1}".format(self.EVENT_PREFIX,
+ self.incarnation_no)
self.publish_thread = threading.Thread(
target=self._publish_event_routine
)
@@ -200,9 +200,9 @@ class HyperVKvpReportingHandler(ReportingHandler):
CLOUD_INIT|<incarnation number>|<event_type>|<event_name>|<uuid>
[|subevent_index]
"""
- return u"{0}|{1}|{2}|{3}".format(self.event_key_prefix,
- event.event_type, event.name,
- uuid.uuid4())
+ return "{0}|{1}|{2}|{3}".format(self.event_key_prefix,
+ event.event_type, event.name,
+ uuid.uuid4())
def _encode_kvp_item(self, key, value):
data = struct.pack(
diff --git a/cloudinit/safeyaml.py b/cloudinit/safeyaml.py
index d6f5f95b..b95df27d 100644
--- a/cloudinit/safeyaml.py
+++ b/cloudinit/safeyaml.py
@@ -15,7 +15,7 @@ class _CustomSafeLoader(yaml.SafeLoader):
_CustomSafeLoader.add_constructor(
- u'tag:yaml.org,2002:python/unicode',
+ 'tag:yaml.org,2002:python/unicode',
_CustomSafeLoader.construct_python_unicode)
diff --git a/cloudinit/sources/DataSourceNoCloud.py b/cloudinit/sources/DataSourceNoCloud.py
index a126aad3..2d9e86b4 100644
--- a/cloudinit/sources/DataSourceNoCloud.py
+++ b/cloudinit/sources/DataSourceNoCloud.py
@@ -247,7 +247,7 @@ def _quick_read_instance_id(dirs=None):
try:
data = util.pathprefix2dict(d, required=['meta-data'])
md = util.load_yaml(data['meta-data'])
- if iid_key in md:
+ if md and iid_key in md:
return md[iid_key]
except ValueError:
pass
diff --git a/cloudinit/templater.py b/cloudinit/templater.py
index a00ade20..009bed32 100644
--- a/cloudinit/templater.py
+++ b/cloudinit/templater.py
@@ -36,14 +36,14 @@ from cloudinit import util
LOG = logging.getLogger(__name__)
TYPE_MATCHER = re.compile(r"##\s*template:(.*)", re.I)
BASIC_MATCHER = re.compile(r'\$\{([A-Za-z0-9_.]+)\}|\$([A-Za-z0-9_.]+)')
-MISSING_JINJA_PREFIX = u'CI_MISSING_JINJA_VAR/'
+MISSING_JINJA_PREFIX = 'CI_MISSING_JINJA_VAR/'
class UndefinedJinjaVariable(JUndefined):
"""Class used to represent any undefined jinja template variable."""
def __str__(self):
- return u'%s%s' % (MISSING_JINJA_PREFIX, self._undefined_name)
+ return '%s%s' % (MISSING_JINJA_PREFIX, self._undefined_name)
def __sub__(self, other):
other = str(other).replace(MISSING_JINJA_PREFIX, '')
diff --git a/cloudinit/tests/test_subp.py b/cloudinit/tests/test_subp.py
index 911c1f3d..515d5d64 100644
--- a/cloudinit/tests/test_subp.py
+++ b/cloudinit/tests/test_subp.py
@@ -91,8 +91,8 @@ class TestSubp(CiTestCase):
tmp_file = self.tmp_path('test.out')
cmd = 'echo HI MOM >> {tmp_file}'.format(tmp_file=tmp_file)
(out, _err) = subp.subp(cmd.encode('utf-8'), shell=True)
- self.assertEqual(u'', out)
- self.assertEqual(u'', _err)
+ self.assertEqual('', out)
+ self.assertEqual('', _err)
self.assertEqual('HI MOM\n', util.load_file(tmp_file))
def test_subp_handles_strings(self):
@@ -100,8 +100,8 @@ class TestSubp(CiTestCase):
tmp_file = self.tmp_path('test.out')
cmd = 'echo HI MOM >> {tmp_file}'.format(tmp_file=tmp_file)
(out, _err) = subp.subp(cmd, shell=True)
- self.assertEqual(u'', out)
- self.assertEqual(u'', _err)
+ self.assertEqual('', out)
+ self.assertEqual('', _err)
self.assertEqual('HI MOM\n', util.load_file(tmp_file))
def test_subp_handles_utf8(self):