daemon.py: state_msg() fix

This commit is contained in:
The MMGen Project 2023-07-01 15:51:37 +00:00
commit 31ad7805ca
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2

View file

@ -168,10 +168,14 @@ class Daemon(Lockable):
return self.run_cmd(self.cli_cmd(*cmds),silent=silent)
def state_msg(self,extra_text=None):
try:
pid = self.pid
except:
pid = None
extra_text = 'not ' if self.state == 'stopped' else f'{extra_text} ' if extra_text else ''
return '{:{w}} {:10} {}'.format(
f'{self.desc} {extra_text}running',
'pid N/A' if self.pid is None or self.pids else f'pid {self.pid}',
'pid N/A' if pid is None or self.pids or self.state == 'stopped' else f'pid {pid}',
f'port {self.bind_port}',
w = 60 )