Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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
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)
def _exit():
sys.stderr.write(exceptions.text_error_template().render())
sys.exit(1)
def _exit():
sys.stderr.write(exceptions.text_error_template().render())
sys.exit(1)
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'
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
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)
def template(fname, d):
try:
return Template(filename=fname).render(**d)
except:
print exceptions.text_error_template().render()
raise
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())