1
1
# Copyright 2014-2015 Canonical Limited.
3
# This file is part of charm-helpers.
5
# charm-helpers is free software: you can redistribute it and/or modify
6
# it under the terms of the GNU Lesser General Public License version 3 as
7
# published by the Free Software Foundation.
9
# charm-helpers is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
# GNU Lesser General Public License for more details.
14
# You should have received a copy of the GNU Lesser General Public License
15
# along with charm-helpers. If not, see <http://www.gnu.org/licenses/>.
3
# Licensed under the Apache License, Version 2.0 (the "License");
4
# you may not use this file except in compliance with the License.
5
# You may obtain a copy of the License at
7
# http://www.apache.org/licenses/LICENSE-2.0
9
# Unless required by applicable law or agreed to in writing, software
10
# distributed under the License is distributed on an "AS IS" BASIS,
11
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
# See the License for the specific language governing permissions and
13
# limitations under the License.
19
18
from charmhelpers.core import host
20
19
from charmhelpers.core import hookenv
40
39
The rendered template will be written to the file as well as being returned
43
Note: Using this requires python-jinja2; if it is not installed, calling
44
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
47
47
from jinja2 import FileSystemLoader, Environment, exceptions
53
53
'charmhelpers.fetch to install it',
54
54
level=hookenv.ERROR)
56
apt_install('python-jinja2', fatal=True)
56
if sys.version_info.major == 2:
57
apt_install('python-jinja2', fatal=True)
59
apt_install('python3-jinja2', fatal=True)
57
60
from jinja2 import FileSystemLoader, Environment, exceptions
59
62
if template_loader: