~adam-collard/charms/trusty/swift-proxy/lib-in-python-package

« back to all changes in this revision

Viewing changes to hooks/charmhelpers/core/hookenv.py

  • Committer: Liam Young
  • Date: 2015-04-16 10:26:51 UTC
  • Revision ID: liam.young@canonical.com-20150416102651-0krkkgyz310fa1uv
[gnuoy,trivial] Pre-release charmhelper sync

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
# Authors:
21
21
#  Charm Helpers Developers <juju@lists.ubuntu.com>
22
22
 
 
23
from __future__ import print_function
23
24
import os
24
25
import json
25
26
import yaml
26
27
import subprocess
27
28
import sys
 
29
import errno
28
30
from subprocess import CalledProcessError
29
31
 
30
32
import six
87
89
    if not isinstance(message, six.string_types):
88
90
        message = repr(message)
89
91
    command += [message]
90
 
    subprocess.call(command)
 
92
    # Missing juju-log should not cause failures in unit tests
 
93
    # Send log output to stderr
 
94
    try:
 
95
        subprocess.call(command)
 
96
    except OSError as e:
 
97
        if e.errno == errno.ENOENT:
 
98
            if level:
 
99
                message = "{}: {}".format(level, message)
 
100
            message = "juju-log: {}".format(message)
 
101
            print(message, file=sys.stderr)
 
102
        else:
 
103
            raise
91
104
 
92
105
 
93
106
class Serializable(UserDict):