summaryrefslogtreecommitdiff
path: root/cloudinit/handlers/__init__.py
diff options
context:
space:
mode:
authorJoshua Harlow <harlowja@yahoo-inc.com>2012-11-06 14:27:56 -0800
committerJoshua Harlow <harlowja@yahoo-inc.com>2012-11-06 14:27:56 -0800
commit9850895442afe55079cecf4fd96fe8430ed960ea (patch)
tree8bf2753b18b9728bd1a6013515ff3d0b333b2ee1 /cloudinit/handlers/__init__.py
parent7ec0ef04b975eb5b4c40f7ae746d706585c73a02 (diff)
downloadvyos-cloud-init-9850895442afe55079cecf4fd96fe8430ed960ea.tar.gz
vyos-cloud-init-9850895442afe55079cecf4fd96fe8430ed960ea.zip
Do the append after escape.
Diffstat (limited to 'cloudinit/handlers/__init__.py')
-rw-r--r--cloudinit/handlers/__init__.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/cloudinit/handlers/__init__.py b/cloudinit/handlers/__init__.py
index d847f331..8d6dcd4d 100644
--- a/cloudinit/handlers/__init__.py
+++ b/cloudinit/handlers/__init__.py
@@ -162,14 +162,14 @@ def _extract_first_or_bytes(blob, size):
def _escape_string(text):
try:
- text = "'%s...'" % (text.encode("string-escape"))
+ return text.encode("string-escape")
except TypeError:
try:
# Unicode doesn't support string-escape...
- text = "'%s...'" % (text.encode('unicode-escape'))
+ return text.encode('unicode-escape')
except TypeError:
# Give up...
- text = "'%s...'" % (text)
+ pass
return text
@@ -184,7 +184,7 @@ def walker_callback(pdata, ctype, filename, payload):
elif payload:
# Extract the first line or 24 bytes for displaying in the log
start = _extract_first_or_bytes(payload, 24)
- details = _escape_string(start)
+ details = "'%s...'" % (_escape_string(start))
if ctype == NOT_MULTIPART_TYPE:
LOG.warning("Unhandled non-multipart (%s) userdata: %s",
ctype, details)