Pre-release charm-helpers sync
To begin release testing get each charm up to date with lp:charm-helpers Change-Id: Ib14ceb4ec61c7b1a31f9b46b4406cd560e4a8857
This commit is contained in:
parent
3c17fd5ba1
commit
8020a96700
@ -13,6 +13,7 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
from charmhelpers.core import host
|
from charmhelpers.core import host
|
||||||
from charmhelpers.core import hookenv
|
from charmhelpers.core import hookenv
|
||||||
@ -38,8 +39,9 @@ def render(source, target, context, owner='root', group='root',
|
|||||||
The rendered template will be written to the file as well as being returned
|
The rendered template will be written to the file as well as being returned
|
||||||
as a string.
|
as a string.
|
||||||
|
|
||||||
Note: Using this requires python-jinja2; if it is not installed, calling
|
Note: Using this requires python-jinja2 or python3-jinja2; if it is not
|
||||||
this will attempt to use charmhelpers.fetch.apt_install to install it.
|
installed, calling this will attempt to use charmhelpers.fetch.apt_install
|
||||||
|
to install it.
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
from jinja2 import FileSystemLoader, Environment, exceptions
|
from jinja2 import FileSystemLoader, Environment, exceptions
|
||||||
@ -51,7 +53,10 @@ def render(source, target, context, owner='root', group='root',
|
|||||||
'charmhelpers.fetch to install it',
|
'charmhelpers.fetch to install it',
|
||||||
level=hookenv.ERROR)
|
level=hookenv.ERROR)
|
||||||
raise
|
raise
|
||||||
apt_install('python-jinja2', fatal=True)
|
if sys.version_info.major == 2:
|
||||||
|
apt_install('python-jinja2', fatal=True)
|
||||||
|
else:
|
||||||
|
apt_install('python3-jinja2', fatal=True)
|
||||||
from jinja2 import FileSystemLoader, Environment, exceptions
|
from jinja2 import FileSystemLoader, Environment, exceptions
|
||||||
|
|
||||||
if template_loader:
|
if template_loader:
|
||||||
|
@ -178,14 +178,14 @@ def filter_installed_packages(packages):
|
|||||||
return _pkgs
|
return _pkgs
|
||||||
|
|
||||||
|
|
||||||
def apt_cache(in_memory=True):
|
def apt_cache(in_memory=True, progress=None):
|
||||||
"""Build and return an apt cache"""
|
"""Build and return an apt cache"""
|
||||||
from apt import apt_pkg
|
from apt import apt_pkg
|
||||||
apt_pkg.init()
|
apt_pkg.init()
|
||||||
if in_memory:
|
if in_memory:
|
||||||
apt_pkg.config.set("Dir::Cache::pkgcache", "")
|
apt_pkg.config.set("Dir::Cache::pkgcache", "")
|
||||||
apt_pkg.config.set("Dir::Cache::srcpkgcache", "")
|
apt_pkg.config.set("Dir::Cache::srcpkgcache", "")
|
||||||
return apt_pkg.Cache()
|
return apt_pkg.Cache(progress)
|
||||||
|
|
||||||
|
|
||||||
def apt_install(packages, options=None, fatal=False):
|
def apt_install(packages, options=None, fatal=False):
|
||||||
|
Loading…
Reference in New Issue
Block a user