i3pystatus/ice-status: only show net info if we actually have information

This commit is contained in:
Franzi 2022-03-19 10:31:01 +01:00
parent b295fd359a
commit bd8c68235e
Signed by: kunsi
GPG Key ID: 12E3D2136B818350
1 changed files with 14 additions and 4 deletions

View File

@ -66,12 +66,22 @@ try:
else:
next_stop = 'Endstation, bitte Aussteigen'
print('<span color="#999999">{}km/h</span> > {} <span color="#999999">(Net: {} > [{}] {})</span>'.format(
net_current = ice_status['connectivity']['currentState']
net_future = ice_status['connectivity']['nextState']
if net_current not in (None, 'NO_INFO') or net_future not in (None, 'NO_INFO'):
net = ' <span color="#999999">(Net: {} > [{}] {})</span>'.format(
net_current,
format_time(ice_status['connectivity']['remainingTimeSeconds']),
net_future,
)
else:
net = ''
print('<span color="#999999">{}km/h</span> > {}{}'.format(
ice_status['speed'],
next_stop,
ice_status['connectivity']['currentState'],
format_time(ice_status['connectivity']['remainingTimeSeconds']),
ice_status['connectivity']['nextState'],
net,
))
except Exception as e:
print(repr(e))