~smoser/cloud-init/snappy-fix-config

« back to all changes in this revision

Viewing changes to cloudinit/CloudConfig/cc_final_message.py

  • Committer: Scott Moser
  • Date: 2012-01-17 19:41:29 UTC
  • Revision ID: smoser@ubuntu.com-20120117194129-nftss2ywh8hp9xpi
[PATCH] PEP8 coding style fixes.
From: Juerg Haefliger <juerg.haefliger@hp.com>

This pulls in the named patch for LP: #914739 with a few other changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
 
25
25
final_message = "cloud-init boot finished at $TIMESTAMP. Up $UPTIME seconds"
26
26
 
 
27
 
27
28
def handle(_name, cfg, _cloud, log, args):
28
29
    if len(args) != 0:
29
30
        msg_in = args[0]
38
39
        log.warn("unable to open /proc/uptime\n")
39
40
        uptime = "na"
40
41
 
41
 
 
42
42
    try:
43
43
        ts = time.strftime("%a, %d %b %Y %H:%M:%S %z", time.gmtime())
44
44
    except:
45
45
        ts = "na"
46
46
 
47
47
    try:
48
 
        subs = { 'UPTIME' : uptime, 'TIMESTAMP' : ts }
 
48
        subs = {'UPTIME': uptime, 'TIMESTAMP': ts}
49
49
        sys.stdout.write("%s\n" % util.render_string(msg_in, subs))
50
50
    except Exception as e:
51
51
        log.warn("failed to render string to stdout: %s" % e)