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 6f615dcf9e
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) ret, out, err = sau.helpers.exec_cmd(cmd)
if ret != 0: if ret != 0:
log.warning("searching for owner of {} failed:".format(exe)) raise sau.errors.UnknownServiceError("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
pkg = out.strip() pkg = out.strip()
cmd = [ EQUERY_PATH, '-Cq', 'f', pkg ] cmd = [ EQUERY_PATH, '-Cq', 'f', pkg ]
@ -48,9 +43,9 @@ def identify_service_from_bin(exe):
if match: if match:
matches.add(match.group(1)) matches.add(match.group(1))
if len(matches) < 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: 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: else:
return matches.pop() return matches.pop()
return None return None