daemon.py: simplify exception handling

This commit is contained in:
The MMGen Project 2021-08-02 19:47:52 +00:00
commit f290642ff8
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2

View file

@ -72,8 +72,7 @@ class Daemon(MMGenObject):
try:
cp = run(cmd,check=False,stdout=PIPE,stderr=PIPE)
except Exception as e:
ymsg(f'Error starting executable: {type(e).__name__} [Errno {e.errno}]')
raise
raise MMGenCalledProcessError(f'Error starting executable: {type(e).__name__} [Errno {e.errno}]')
if self.debug:
print(cp)
return cp
@ -173,16 +172,7 @@ class Daemon(MMGenObject):
# leading to interesting consequences.
os.unlink(self.pidfile)
for i in range(20):
try:
ret = self.do_start(silent=silent)
except Exception as e:
ymsg(str(e))
else:
break
time.sleep(1)
else:
die(2,'Unable to start daemon')
ret = self.do_start(silent=silent)
if self.wait:
self.wait_for_state('ready')