~adam-collard/charms/trusty/rabbitmq-server/fix-le-ignore-min-cluster

« back to all changes in this revision

Viewing changes to hooks/rabbitmq_server_relations.py

  • Committer: james.page at ubuntu
  • Date: 2015-04-22 14:15:20 UTC
  • mfrom: (95.1.1 rabbitmq-server)
  • Revision ID: james.page@ubuntu.com-20150422141520-wrkd4djob412cvxm
Ensure yaml library is usable

Newer Ubuntu versions don't have python-yaml installed by default.

Handle this automatically in the charm.

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
import subprocess
7
7
import glob
8
8
import socket
9
 
import yaml
 
9
 
 
10
try:
 
11
    import yaml  # flake8: noqa
 
12
except ImportError:
 
13
    if sys.version_info.major == 2:
 
14
        subprocess.check_call(['apt-get', 'install', '-y', 'python-yaml'])
 
15
    else:
 
16
        subprocess.check_call(['apt-get', 'install', '-y', 'python3-yaml'])
 
17
    import yaml  # flake8: noqa
10
18
 
11
19
import rabbit_utils as rabbit
12
20
from lib.utils import (