pyrolab/manager.py:642-671:
if delta.days > 0:
return f"Up {delta.days} days"
elif delta.seconds > 3600:
return f"Up {delta.seconds // 3600} hours"
elif delta.seconds > 120:
return f"Up {delta.seconds // 60} minutes"
elif delta.seconds > 60:
return f"Up 1 minute"
else:
return f"Up {delta.seconds} seconds"
This is the STATUS column of pyrolab ps. Issues:
- A daemon up for 6 days 23 hours reports
Up 6 days. timedelta.seconds is the sub-day remainder, so the hours are available and discarded.
delta.seconds == 60 falls through every branch to the final else and prints Up 60 seconds.
delta.days == 1 prints Up 1 days.
- Boundaries use
> rather than >= throughout, so each threshold is off by one unit.
Suggested fix: compute from delta.total_seconds() and emit the two most significant units (Up 6d 23h, Up 4h 12m, Up 45s), which is both correct and more informative in a status table. humanize.naturaldelta would also do, though it is another dependency for one function.
Found in a full-codebase audit at v0.4.0 (commit 1ce3146).
pyrolab/manager.py:642-671:This is the STATUS column of
pyrolab ps. Issues:Up 6 days.timedelta.secondsis the sub-day remainder, so the hours are available and discarded.delta.seconds == 60falls through every branch to the finalelseand printsUp 60 seconds.delta.days == 1printsUp 1 days.>rather than>=throughout, so each threshold is off by one unit.Suggested fix: compute from
delta.total_seconds()and emit the two most significant units (Up 6d 23h,Up 4h 12m,Up 45s), which is both correct and more informative in a status table.humanize.naturaldeltawould also do, though it is another dependency for one function.Found in a full-codebase audit at v0.4.0 (commit 1ce3146).