proper error message on gentoo when service could not be identified.

This commit is contained in:
Fredrik Eriksson 2023-03-12 08:03:35 +01:00
parent 688af9ac62
commit 0ea7804427
Signed by: feffe
GPG Key ID: CD5A131FADFA3968

View File

@ -24,12 +24,7 @@ def identify_service_from_bin(exe):
ret, out, err = sau.helpers.exec_cmd(cmd)
if ret != 0:
log.warning("searching for owner of {} failed:".format(exe))
for line in out.splitlines():
log.warning("stdout: {}".format(line))
for line in err.splitlines():
log.warning("stderr: {}".format(line))
return None
raise sau.errors.UnknownServiceError("searching for owner of {} failed:".format(exe))
pkg = out.strip()
cmd = [ EQUERY_PATH, '-Cq', 'f', pkg ]
@ -48,9 +43,9 @@ def identify_service_from_bin(exe):
if match:
matches.add(match.group(1))
if len(matches) < 1:
log.warning('Could not find any init script in package {}'.format(pkg))
raise sau.errors.UnknownServiceError('Could not find any init script in package {}'.format(pkg))
elif len(matches) > 1:
log.warning('Found multiple init script in package {}'.format(pkg))
raise sau.errors.UnknownServiceError('Found multiple init script in package {}'.format(pkg))
else:
return matches.pop()
return None