예제 #1
0
파일: site.py 프로젝트: intaxi/makesite
 def remove_template(self, template_name):
     assert template_name in self.templates, "Template not installed."
     print_header("Remove template: %s" % template_name)
     template = self._get_template_path(template_name)
     if not template.startswith(self.source_dir):
         for f in gen_template_files(template):
             call('sudo rm -f %s' % op.join(self.deploy_dir, f))
     self.templates = filter(lambda x: x != template_name, self.templates)
     self['template'] = ','.join(self.templates)
     self.write()
예제 #2
0
 def remove_template(self, template_name):
     assert template_name in self.templates, "Template not installed."
     print_header("Remove template: %s" % template_name)
     template = self._get_template_path(template_name)
     if not template.startswith(self.source_dir):
         for f in gen_template_files(template):
             call('sudo rm -f %s' % op.join(self.deploy_dir, f))
     self.templates = filter(lambda x: x != template_name, self.templates)
     self['template'] = ','.join(self.templates)
     self.write()
예제 #3
0
파일: site.py 프로젝트: intaxi/makesite
    def paste_template(self, template_name, template=None, deploy_dir=None):
        " Paste template. "

        LOGGER.info("Paste template: %s" % template_name)
        deploy_dir = deploy_dir or self.deploy_dir
        template = template or self._get_template_path(template_name)
        self.read([op.join(template, settings.CFGNAME)], extending=True)

        for fname in gen_template_files(template):
            curdir = op.join(deploy_dir, op.dirname(fname))
            if not op.exists(curdir):
                makedirs(curdir)

            source = op.join(template, fname)
            target = op.join(deploy_dir, fname)
            copy2(source, target)
            name, ext = op.splitext(fname)
            if ext == '.tmpl':
                t = Template.from_filename(target, namespace=self.as_dict())
                with open(op.join(deploy_dir, name), 'w') as f:
                    f.write(t.substitute())
                remove(target)

        return deploy_dir
예제 #4
0
    def paste_template(self, template_name, template=None, deploy_dir=None):
        " Paste template. "

        LOGGER.debug("Paste template: %s" % template_name)
        deploy_dir = deploy_dir or self.deploy_dir
        template = template or self._get_template_path(template_name)
        self.read([op.join(template, settings.CFGNAME)], extending=True)

        for fname in gen_template_files(template):
            curdir = op.join(deploy_dir, op.dirname(fname))
            if not op.exists(curdir):
                makedirs(curdir)

            source = op.join(template, fname)
            target = op.join(deploy_dir, fname)
            copy2(source, target)
            name, ext = op.splitext(fname)
            if ext == '.tmpl':
                t = Template.from_filename(target, namespace=self.as_dict())
                with open(op.join(deploy_dir, name), 'w') as f:
                    f.write(t.substitute())
                remove(target)

        return deploy_dir