예제 #1
0
파일: base.py 프로젝트: EnterStudios/indico
    def run(self, template_name, **kwargs):
        template_dir = os.path.join(Config.getInstance().getTPLDir(), 'latex')
        template = tpl_render(os.path.join(template_dir, template_name), kwargs)

        self._dir = tempfile.mkdtemp(prefix="indico-texgen-", dir=Config.getInstance().getTempDir())
        source_filename = os.path.join(self._dir, template_name + '.tex')
        target_filename = os.path.join(self._dir, template_name + '.pdf')
        log_filename = os.path.join(self._dir, 'output.log')
        log_file = open(log_filename, 'a+')

        with open(source_filename, 'w') as f:
            f.write(template)

        try:
            self.run_latex(source_filename, log_file)
            if self.has_toc:
                self.run_latex(source_filename, log_file)
        finally:
            log_file.close()

            if not os.path.exists(target_filename):
                # something went terribly wrong, no LaTeX file was produced
                raise LaTeXRuntimeException(source_filename, log_filename)

        return target_filename
예제 #2
0
파일: base.py 프로젝트: innovexa/IDC-Events
    def run(self, template_name, **kwargs):
        template_dir = os.path.join(get_root_path('indico'),
                                    'legacy/webinterface/tpls/latex')
        template = tpl_render(os.path.join(template_dir, template_name),
                              kwargs)

        self._dir = tempfile.mkdtemp(prefix="indico-texgen-",
                                     dir=config.TEMP_DIR)
        chmod_umask(self._dir, execute=True)
        source_filename = os.path.join(self._dir, template_name + '.tex')
        target_filename = os.path.join(self._dir, template_name + '.pdf')
        log_filename = os.path.join(self._dir, 'output.log')
        log_file = open(log_filename, 'a+')

        with open(source_filename, 'w') as f:
            f.write(template)

        try:
            self.run_latex(source_filename, log_file)
            if self.has_toc:
                self.run_latex(source_filename, log_file)
        finally:
            log_file.close()

            if not os.path.exists(target_filename):
                # something went terribly wrong, no LaTeX file was produced
                raise LaTeXRuntimeException(source_filename, log_filename)

        return target_filename
예제 #3
0
파일: base.py 프로젝트: bkolobara/indico
    def run(self, template_name, **kwargs):
        template_dir = os.path.join(get_root_path('indico'), 'legacy/webinterface/tpls/latex')
        template = tpl_render(os.path.join(template_dir, template_name), kwargs)

        self._dir = tempfile.mkdtemp(prefix="indico-texgen-", dir=config.TEMP_DIR)
        chmod_umask(self._dir, execute=True)
        source_filename = os.path.join(self._dir, template_name + '.tex')
        target_filename = os.path.join(self._dir, template_name + '.pdf')
        log_filename = os.path.join(self._dir, 'output.log')
        log_file = open(log_filename, 'a+')

        with open(source_filename, 'w') as f:
            f.write(template)

        try:
            self.run_latex(source_filename, log_file)
            if self.has_toc:
                self.run_latex(source_filename, log_file)
        finally:
            log_file.close()

            if not os.path.exists(target_filename):
                # something went terribly wrong, no LaTeX file was produced
                raise LaTeXRuntimeException(source_filename, log_filename)

        return target_filename