The-Compiler/journalwatch

fails with "ValueError: could not convert string to float:"

rkoe opened this issue · 2 comments

rkoe commented

Bug description

Since a recent Linux-System-update, journalwatch does not work anymore; instead it fails with:

$ journalwatch print
Traceback (most recent call last):
  File "/nix/store/4my8gfpc9nl8pq1q9rf6kwa7h0n307xv-python3.9-journalwatch-1.1.0/bin/.journalwatch-wrapped", line 9, in <module>
    sys.exit(main())
  File "/nix/store/4my8gfpc9nl8pq1q9rf6kwa7h0n307xv-python3.9-journalwatch-1.1.0/lib/python3.9/site-packages/journalwatch.py", line 505, in main
    run()
  File "/nix/store/4my8gfpc9nl8pq1q9rf6kwa7h0n307xv-python3.9-journalwatch-1.1.0/lib/python3.9/site-packages/journalwatch.py", line 488, in run
    since = parse_since()
  File "/nix/store/4my8gfpc9nl8pq1q9rf6kwa7h0n307xv-python3.9-journalwatch-1.1.0/lib/python3.9/site-packages/journalwatch.py", line 451, in parse_since
    since = datetime.fromtimestamp(float(f.read()))
ValueError: could not convert string to float: ''

System information

  • OS: Linux, NixOS 21.11
rkoe commented

Looks like this is caused by something crashing ~/.local/share/journalwatch/time
Solution: Run journalwatch --since all print once; this will restore the file, so following calls work again.

Glad you got it sorted out! No idea how it happened though - apparently, the file was empty in your case, but all journalwatch does is:

def write_time_file():
"""Write the execution time to a file."""
with open(TIME_FILE, 'w') as f:
f.write(str(time.time()))

I added a better error message for that case to 363725a now.