~openstack-charmers/charms/trusty/neutron-api/next

« back to all changes in this revision

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

  • Committer: David Ames
  • Date: 2016-07-15 17:08:42 UTC
  • Revision ID: david.ames@canonical.com-20160715170842-nrcfoafoowbp6a3n
Pre-release charm-helpers sync

To begin release testing get each charm up to date with lp:charm-helpers

Change-Id: I928c4ee107272419e4c7e8ea17b4a73c5254b3c8

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: