certbot-ci: fix py2 crash in dns_server

This commit is contained in:
Alex Zorin
2020-11-17 14:58:29 -08:00
committed by Brad Warren
parent 7ba35b4407
commit e8139e80be
@@ -40,6 +40,8 @@ class DNSServer(object):
self.bind_root = tempfile.mkdtemp()
self.process = None
self.dns_xdist = {
'address': BIND_BIND_ADDRESS[0],
'port': BIND_BIND_ADDRESS[1]
@@ -60,11 +62,12 @@ class DNSServer(object):
def stop(self):
"""Stop the DNS server, and clean its resources"""
try:
self.process.terminate()
self.process.wait()
except BaseException as e:
print("BIND9 did not stop cleanly: {}".format(e), file=sys.stderr)
if self.process:
try:
self.process.terminate()
self.process.wait()
except BaseException as e:
print("BIND9 did not stop cleanly: {}".format(e), file=sys.stderr)
shutil.rmtree(self.bind_root, ignore_errors=True)
@@ -74,7 +77,8 @@ class DNSServer(object):
def _configure_bind(self):
"""Configure the BIND9 server based on the prebaked configuration"""
bind_conf_src = resource_filename('certbot_integration_tests', 'assets/bind-config')
shutil.copytree(bind_conf_src, self.bind_root, dirs_exist_ok=True)
for dir in ('conf', 'zones'):
shutil.copytree(os.path.join(bind_conf_src, dir), os.path.join(self.bind_root, dir))
def _start_bind(self):
"""Launch the BIND9 server as a Docker container"""