Correct an issue when using autodiscover in unitary test

This commit is contained in:
nicolargo 2022-10-31 08:58:16 +01:00
parent 2b8ae361d1
commit 1ed761c1aa
3 changed files with 5 additions and 1 deletions

View File

@ -186,6 +186,9 @@ class GlancesAutoDiscoverClient(object):
# Issue #528 (no network interface available)
pass
# Ensure zeroconf_bind_address is an IP address not an host
zeroconf_bind_address = socket.gethostbyname(zeroconf_bind_address)
# Check IP v4/v6
address_family = socket.getaddrinfo(zeroconf_bind_address, args.port)[0][0]

View File

@ -219,6 +219,7 @@ class GlancesServer(object):
if not self.args.disable_autodiscover:
# Note: The Zeroconf service name will be based on the hostname
# Correct issue: Zeroconf problem with zeroconf service name #889
logger.info('Autodiscover is enabled with service name {}'.format(socket.gethostname().split('.', 1)[0]))
self.autodiscover_client = GlancesAutoDiscoverClient(socket.gethostname().split('.', 1)[0], args)
else:
logger.info("Glances autodiscover announce is disabled")

View File

@ -48,7 +48,7 @@ class TestGlances(unittest.TestCase):
cmdline = "./venv/bin/python"
else:
cmdline = "python"
cmdline += " -m glances -B localhost -s --disable-autodiscover -p %s" % SERVER_PORT
cmdline += " -m glances -B localhost -s -p %s" % SERVER_PORT
print("Run the Glances Server on port %s" % SERVER_PORT)
args = shlex.split(cmdline)
pid = subprocess.Popen(args)