1
0
mirror of https://github.com/altlinux/gpupdate.git synced 2025-03-21 10:50:35 +03:00

Catch exception on PolicyKit generation errors

This commit is contained in:
Игорь Чудов 2020-01-14 20:28:42 +04:00
parent f5d2c6c3bc
commit bdf96d8cac
Signed by untrusted user: nir
GPG Key ID: 0F3883600CAE7AAC

View File

@ -34,9 +34,14 @@ class polkit:
self.outfile = os.path.join(self.__policy_dir, '{}.rules'.format(self.template_name))
def generate(self):
template = self.__template_environment.get_template(self.infilename)
text = template.render(**self.args)
with open(self.outfile, 'w') as f:
f.write(text)
logging.debug(slogm('Generated file {} with arguments {}'.format(self.outfile, self.args)))
try:
template = self.__template_environment.get_template(self.infilename)
text = template.render(**self.args)
with open(self.outfile, 'w') as f:
f.write(text)
logging.debug(slogm('Generated file {} with arguments {}'.format(self.outfile, self.args)))
except Exception as exc:
logging.error(slogm('Unable to generate file {} from {}'.format(self.outfile, self.infilename)))