From 977c4cf42e795e35cf4ac31b5f000736c674502e Mon Sep 17 00:00:00 2001 From: Andrew Jorgensen Date: Wed, 5 Mar 2014 14:56:13 -0800 Subject: main: Don't use templater to format the welcome message Some versions of Cheetah returned everything as unicode by default (not utf-8 or ascii) and some varieties of syslog would choke on unicode. Jinja2 is probably fine, but Python's format() is perfectly adequate for a short message like the welcome message. Reviewed-by: Tom Kirchner Reviewed-by: Ben Cressey --- cloudinit/cmd/main.py | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'cloudinit/cmd/main.py') diff --git a/cloudinit/cmd/main.py b/cloudinit/cmd/main.py index 26cc2654..ce3c10dd 100644 --- a/cloudinit/cmd/main.py +++ b/cloudinit/cmd/main.py @@ -3,10 +3,12 @@ # Copyright (C) 2012 Canonical Ltd. # Copyright (C) 2012 Hewlett-Packard Development Company, L.P. # Copyright (C) 2012 Yahoo! Inc. +# Copyright (C) 2017 Amazon.com, Inc. or its affiliates # # Author: Scott Moser # Author: Juerg Haefliger # Author: Joshua Harlow +# Author: Andrew Jorgensen # # This file is part of cloud-init. See LICENSE file for license information. @@ -25,7 +27,6 @@ from cloudinit import netinfo from cloudinit import signal_handler from cloudinit import sources from cloudinit import stages -from cloudinit import templater from cloudinit import url_helper from cloudinit import util from cloudinit import version @@ -42,9 +43,9 @@ from cloudinit import atomic_helper from cloudinit.dhclient_hook import LogDhclient -# Pretty little cheetah formatted welcome message template -WELCOME_MSG_TPL = ("Cloud-init v. ${version} running '${action}' at " - "${timestamp}. Up ${uptime} seconds.") +# Welcome message template +WELCOME_MSG_TPL = ("Cloud-init v. {version} running '{action}' at " + "{timestamp}. Up {uptime} seconds.") # Module section template MOD_SECTION_TPL = "cloud_%s_modules" @@ -88,13 +89,11 @@ def welcome(action, msg=None): def welcome_format(action): - tpl_params = { - 'version': version.version_string(), - 'uptime': util.uptime(), - 'timestamp': util.time_rfc2822(), - 'action': action, - } - return templater.render_string(WELCOME_MSG_TPL, tpl_params) + return WELCOME_MSG_TPL.format( + version=version.version_string(), + uptime=util.uptime(), + timestamp=util.time_rfc2822(), + action=action) def extract_fns(args): -- cgit v1.2.3