diff --git a/irctest/controllers/unrealircd.py b/irctest/controllers/unrealircd.py index 53da8ba..8d7e643 100644 --- a/irctest/controllers/unrealircd.py +++ b/irctest/controllers/unrealircd.py @@ -223,44 +223,44 @@ class UnrealircdController(BaseServerController, DirectoryBasedController): password_field = 'password "{}";'.format(password) if password else "" - with _STARTSTOP_LOCK(): - (services_hostname, services_port) = self.get_hostname_and_port() - (unused_hostname, unused_port) = self.get_hostname_and_port() + (services_hostname, services_port) = self.get_hostname_and_port() + (unused_hostname, unused_port) = self.get_hostname_and_port() - self.gen_ssl() - if ssl: - (tls_hostname, tls_port) = (hostname, port) - (hostname, port) = (unused_hostname, unused_port) - else: - # Unreal refuses to start without TLS enabled - (tls_hostname, tls_port) = (unused_hostname, unused_port) + self.gen_ssl() + if ssl: + (tls_hostname, tls_port) = (hostname, port) + (hostname, port) = (unused_hostname, unused_port) + else: + # Unreal refuses to start without TLS enabled + (tls_hostname, tls_port) = (unused_hostname, unused_port) - assert self.directory + assert self.directory - with self.open_file("unrealircd.conf") as fd: - fd.write( - TEMPLATE_CONFIG.format( - hostname=hostname, - port=port, - services_hostname=services_hostname, - services_port=services_port, - tls_hostname=tls_hostname, - tls_port=tls_port, - password_field=password_field, - key_path=self.key_path, - pem_path=self.pem_path, - empty_file=self.directory / "empty.txt", - set_v6only=set_v6only, - extras=extras, - ) + with self.open_file("unrealircd.conf") as fd: + fd.write( + TEMPLATE_CONFIG.format( + hostname=hostname, + port=port, + services_hostname=services_hostname, + services_port=services_port, + tls_hostname=tls_hostname, + tls_port=tls_port, + password_field=password_field, + key_path=self.key_path, + pem_path=self.pem_path, + empty_file=self.directory / "empty.txt", + set_v6only=set_v6only, + extras=extras, ) + ) - if faketime and shutil.which("faketime"): - faketime_cmd = ["faketime", "-f", faketime] - self.faketime_enabled = True - else: - faketime_cmd = [] + if faketime and shutil.which("faketime"): + faketime_cmd = ["faketime", "-f", faketime] + self.faketime_enabled = True + else: + faketime_cmd = [] + with _STARTSTOP_LOCK(): self.proc = subprocess.Popen( [ *faketime_cmd,