~stub/charms/trusty/nrpe/chsync

« back to all changes in this revision

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

  • Committer: Stuart Bishop
  • Date: 2016-07-15 06:02:57 UTC
  • Revision ID: stuart.bishop@canonical.com-20160715060257-rp95phvt376qwreh
Resync charm-helpers

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
# limitations under the License.
14
14
 
15
15
import os
 
16
import sys
16
17
 
17
18
from charmhelpers.core import host
18
19
from charmhelpers.core import hookenv
38
39
    The rendered template will be written to the file as well as being returned
39
40
    as a string.
40
41
 
41
 
    Note: Using this requires python-jinja2; if it is not installed, calling
42
 
    this will attempt to use charmhelpers.fetch.apt_install to install it.
 
42
    Note: Using this requires python-jinja2 or python3-jinja2; if it is not
 
43
    installed, calling this will attempt to use charmhelpers.fetch.apt_install
 
44
    to install it.
43
45
    """
44
46
    try:
45
47
        from jinja2 import FileSystemLoader, Environment, exceptions
51
53
                        'charmhelpers.fetch to install it',
52
54
                        level=hookenv.ERROR)
53
55
            raise
54
 
        apt_install('python-jinja2', fatal=True)
 
56
        if sys.version_info.major == 2:
 
57
            apt_install('python-jinja2', fatal=True)
 
58
        else:
 
59
            apt_install('python3-jinja2', fatal=True)
55
60
        from jinja2 import FileSystemLoader, Environment, exceptions
56
61
 
57
62
    if template_loader: