deploy: use str.format instead of string.Template

fixes #3928
This commit is contained in:
Benjamin Dauvergne 2013-11-04 10:07:00 +01:00
parent 6d9b70dc84
commit 4b21e65ea6
1 changed files with 5 additions and 9 deletions

View File

@ -1,4 +1,3 @@
import string
import cPickle
import os
import zipfile
@ -153,7 +152,7 @@ class DeployInstance(object):
idff_metadata_template = file(
os.path.join(self.skel_dir, 'idff-metadata-template')).read()
file(os.path.join(self.collectivity_install_dir, 'metadata.xml'), 'w').write(
string.Template(idff_metadata_template).substitute({'url': url_stripped}))
idff_metadata_template.format(url=url_stripped))
if os.path.exists(os.path.join(self.skel_dir, 'saml2-metadata-template')):
# there's a SAMLv2 metadata template, so we do the SAMLv2 stuff
@ -167,7 +166,7 @@ class DeployInstance(object):
saml2_metadata_template = file(
os.path.join(self.skel_dir, 'saml2-metadata-template')).read()
file(os.path.join(self.collectivity_install_dir, 'saml2-metadata.xml'), 'w').write(
string.Template(saml2_metadata_template).substitute({'url': url_stripped}))
saml2_metadata_template.format(url=url_stripped))
if has_idff or has_saml2:
idp_metadata = ET.parse(file(os.path.join(self.skel_dir, 'idp-metadata.xml')))
@ -207,11 +206,8 @@ class DeployInstance(object):
return
options_template = file(options_template_path).read()
file(os.path.join(self.collectivity_install_dir, 'site-options.cfg'), 'w').write(
string.Template(options_template).substitute({
'domain': self.domain,
'options': self.site_options_cfg
})
)
options_template.format(domain=self.domain,
options=self.site_options_cfg))
def make_apache_vhost(self):
@ -223,7 +219,7 @@ class DeployInstance(object):
if not os.path.exists(apache_dir):
os.mkdir(apache_dir)
file(os.path.join(apache_dir, '%s.conf' % self.domain), 'w').write(
string.Template(apache_vhost_template).substitute({'domain': self.domain}))
apache_vhost_template.format(domain=self.domain))
def reload_apache(self):