mirror of
https://github.com/xcat2/confluent.git
synced 2024-11-25 11:01:09 +00:00
Change nodesensors format of float
Floats are either unnecessarily long in normal output, or too unconstrained in CSV output. Normalize to as many digits as 'makes sense' up to 5 digits. 5 miight seem a bit much, but one common metric is kWh, which may need that precision over short intervals.
This commit is contained in:
parent
77ba0acee6
commit
2379f6f90f
@ -135,7 +135,7 @@ def sensorpass(showout=True, appendtime=False):
|
||||
if sensedata['value'] is None:
|
||||
showval = ''
|
||||
elif isinstance(sensedata['value'], float):
|
||||
showval = u' {0:.5f} '.format(sensedata['value'])
|
||||
showval = u' {0:.5g} '.format(sensedata['value'])
|
||||
else:
|
||||
showval = u' {0} '.format(sensedata['value'])
|
||||
if sensedata['units'] not in (None, u''):
|
||||
@ -191,6 +191,8 @@ def format_csv(csvwriter, orderedsensors, resdata, showtime=True):
|
||||
datum = ','.join([datum, healthstates])
|
||||
else:
|
||||
datum = healthstates
|
||||
if isinstance(datum, float):
|
||||
datum = '{:.5g}'.format(datum)
|
||||
rowdata.append(datum)
|
||||
except KeyError:
|
||||
rowdata.append('N/A')
|
||||
|
Loading…
Reference in New Issue
Block a user