~corey.bryant/charms/trusty/heat/pip

« back to all changes in this revision

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

  • Committer: Liam Young
  • Date: 2015-09-03 09:45:18 UTC
  • Revision ID: liam.young@canonical.com-20150903094518-7htb8glbfm69zl6s
[gnuoy,trivial] Charmhelper sync (+1'd by mojo)

Show diffs side-by-side

added added

removed removed

Lines of Context:
767
767
 
768
768
 
769
769
def status_get():
770
 
    """Retrieve the previously set juju workload state
771
 
 
772
 
    If the status-set command is not found then assume this is juju < 1.23 and
773
 
    return 'unknown'
 
770
    """Retrieve the previously set juju workload state and message
 
771
 
 
772
    If the status-get command is not found then assume this is juju < 1.23 and
 
773
    return 'unknown', ""
 
774
 
774
775
    """
775
 
    cmd = ['status-get']
 
776
    cmd = ['status-get', "--format=json", "--include-data"]
776
777
    try:
777
 
        raw_status = subprocess.check_output(cmd, universal_newlines=True)
778
 
        status = raw_status.rstrip()
779
 
        return status
 
778
        raw_status = subprocess.check_output(cmd)
780
779
    except OSError as e:
781
780
        if e.errno == errno.ENOENT:
782
 
            return 'unknown'
 
781
            return ('unknown', "")
783
782
        else:
784
783
            raise
 
784
    else:
 
785
        status = json.loads(raw_status.decode("UTF-8"))
 
786
        return (status["status"], status["message"])
785
787
 
786
788
 
787
789
def translate_exc(from_exc, to_exc):