How to use the mako.exceptions.text_error_template function in Mako

To help you get started, we’ve selected a few Mako examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mesa3d / mesa / src / intel / vulkan / anv_entrypoints_gen.py View on Github external
physical_device_entrypoints=physical_device_entrypoints,
                                      device_entrypoints=device_entrypoints,
                                      LAYERS=LAYERS,
                                      instance_strmap=instance_strmap,
                                      physical_device_strmap=physical_device_strmap,
                                      device_strmap=device_strmap,
                                      filename=os.path.basename(__file__)))
    except Exception:
        # In the event there's an error, this imports some helpers from mako
        # to print a useful stack trace and prints it, then exits with
        # status 1, if python is run with debug; otherwise it just raises
        # the exception
        if __debug__:
            import sys
            from mako import exceptions
            sys.stderr.write(exceptions.text_error_template().render() + '\n')
            sys.exit(1)
        raise
github appcelerator / titanium_mobile / drillbit / coverage / coverage.py View on Github external
def renderTemplate(self, tmpl, outPath, **kwargs):
		try:
			content = tmpl.render(**kwargs)
			open(outPath, "w").write(content)
		except:
			print exceptions.text_error_template().render()
			sys.exit(1)
github pymedusa / Medusa / ext / mako / cmd.py View on Github external
def _exit():
    sys.stderr.write(exceptions.text_error_template().render())
    sys.exit(1)
github geoadmin / mf-geoadmin3 / scripts / cmd.py View on Github external
def _exit():
    sys.stderr.write(exceptions.text_error_template().render())
    sys.exit(1)
github fedora-infra / bodhi / bodhi / server / services / errors.py View on Github external
directories=[directory],
            output_encoding='utf-8',
            input_encoding='utf-8',
        )
        template = lookup.get_template('errors.html')
        errors = request.errors

        try:
            body = template.render(
                errors=errors,
                status=errors.status,
                request=request,
                summary=status2summary(errors.status),
            )
        except Exception:
            log.error(mako.exceptions.text_error_template().render())
            raise

        # This thing inherits from both Exception *and* Response, so.. take the
        # Response path in the diamond inheritance chain and ignore the
        # exception side.
        # That turns this thing into a "real boy" like pinnochio.
        pyramid.response.Response.__init__(self, body)

        self.status = errors.status
        self.content_type = 'text/html'
github dayorbyte / dispatchd / scripts / amqp_gen.py View on Github external
def render(name, **kwargs):
  path = os.path.join(os.path.abspath(os.path.dirname(__file__)))
  lookup = TemplateLookup(directories=[path])
  try:
    template = lookup.get_template(name + '.mako')
    return template.render(**kwargs)
  except:
    print(exceptions.text_error_template().render())
    raise
github weldr / lorax / src / pylorax / creator.py View on Github external
kernels = [kernel for kernel in findkernels(images_dir, kdir="")
               if hasattr(kernel, "initrd")]
    if not kernels:
        return

    kernel = kernels[0]

    add_args_str = " ".join(add_args)


    try:
        result = Template(filename=template).render(kernel=kernel.path,
                          initrd=kernel.initrd.path, liveimg=live_image_name,
                          addargs=add_args_str)
    except Exception:
        log.error(text_error_template().render())
        raise

    with open (joinpaths(images_dir, "PXE_CONFIG"), "w") as f:
        f.write(result)
github Linutronix / elbe / elbepack / commands / xsdtoasciidoc.py View on Github external
def template(fname, d):
    try:
        return Template(filename=fname).render(**d)
    except:
        print exceptions.text_error_template().render()
        raise
github mesa3d / mesa / bin / gen_release_notes.py View on Github external
final = pathlib.Path(__file__).parent.parent / 'docs' / 'relnotes' / f'{next_version}.html'
    with final.open('wt') as f:
        try:
            f.write(TEMPLATE.render(
                bugfix=is_point_release,
                bugs=bugs,
                changes=walk_shortlog(shortlog),
                features=get_features(is_point_release),
                gl_version=CURRENT_GL_VERSION,
                next_version=next_version,
                today=datetime.date.today(),
                version=previous_version,
                vk_version=CURRENT_VK_VERSION,
            ))
        except:
            print(exceptions.text_error_template().render())