GithubHelp home page GithubHelp logo

lowellobservatory / ultimonitor Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 184 KB

A job/print monitor for the Ultimaker 3 Extended (or any printer supporting that style API), that takes snapshots and emails about them as well as manages statistics gathering

License: Mozilla Public License 2.0

Python 100.00%
ultimaker 3dprinter monitoring alerting python

ultimonitor's Introduction

Ultimonitor

A job/print monitor for the Ultimaker 3 Extended (or any printer supporting that style API), that takes snapshots and emails about them as well as manages statistics gathering

Dependencies

  • python3.x
  • requests
  • picamera
  • xmltodict
  • numpy
  • matplotlib
  • ligmos
  • ?

ultimonitor's People

Contributors

astrobokonon avatar

Stargazers

 avatar

Watchers

 avatar  avatar

ultimonitor's Issues

SMTP setup is fragile

Since I'm not running printzini in a container during debugging, and restricted the dirtymail net to the docker subnet and lowell subnet, I can't reliably figure out a way to reference the damn server in the configuration file. Super annoying.

Consider a database

I could do the temperature statistics way better and just have an async process in another container that just grabs the temperatures, all the time, and stores them in a time windowed database. It would then be a better match with the developments that have occured with Mr. Freeze, and not that much overhead considering everything can just still run on the Pi.

I'm almost tempted to say that it might be better to consider another database, but influx makes this so easy it's probably not worth that extra effort.

gcode scraping

When I detect a print, should I download and parse the gcode to pull out print-specific parameters and put them in the summary? It can be done, probably pretty easy, since Cura annotates the gcode.

Seems like /print_job/gcode or /print_job/container would do it, though I think they require API authentication so there are some under-the-hood workarounds to do too.

Figure out passwords

A continual thorn in my side. I just need to figure out how I want to do this, and then just do it.

A previous cobbled-together solution I came up with for DataServants has the passwords in another file that is then associated with the main config file. But I hate that. I really, really, really just need to figure out whether I want to put the credentials in environment variables that are pulled in for each container (ugly for Alfred with his many machines to check) or if I do encryption and just keep the keyfile secret/uncommitted.

The second seems sensible, but I'm no security expert.

Unhandled timestamp exception

While printing, I'm missing something occasionally. Not sure why this happened yet:

2020-08-17 12:04:23,103 INFO     flowState: printing
2020-08-17 12:04:23,104 INFO     /printer/state: printing
2020-08-17 12:04:23,104 INFO     /print_job/state: printing
2020-08-17 12:04:23,148 INFO     Previous Progress:
2020-08-17 12:04:23,149 INFO     93.85864167992543
2020-08-17 12:04:23,149 INFO     Current Progress:
2020-08-17 12:04:23,150 INFO     93.90188699004047
2020-08-17 12:04:23,150 INFO     Sleeping for 30 seconds...
2020-08-17 12:04:53,880 ERROR    Traceback (most recent call last):
2020-08-17 12:04:53,881 ERROR      File "Printzini.py", line 93, in <module>
2020-08-17 12:04:53,888 ERROR    main(conffile)
2020-08-17 12:04:53,889 ERROR      File "Printzini.py", line 86, in main
2020-08-17 12:04:53,891 ERROR    squashUltiCam=squashUltiCam)
2020-08-17 12:04:53,892 ERROR      File "/home/lig/Ultimonitor/ultimonitor/monitoring.py", line 207, in monitorUltimaker
2020-08-17 12:04:53,896 ERROR    stats = printer.statusCheck(printerip)
2020-08-17 12:04:53,897 ERROR      File "/home/lig/Ultimonitor/ultimonitor/printer.py", line 234, in statusCheck
2020-08-17 12:04:53,901 ERROR    ext1temps = headinfo['extruders'][0]['hotend']['temperature']
2020-08-17 12:04:53,901 ERROR    KeyError
2020-08-17 12:04:53,902 ERROR    :
2020-08-17 12:04:53,903 ERROR    'extruders'

At that point, Printzini restarted, so the emails were sent again. Not ideal.

Seemed to occur this morning, too:

2020-08-17 18:14:25,838 INFO     flowState: pre_print
2020-08-17 18:14:25,839 INFO     /printer/state: printing
2020-08-17 18:14:25,839 INFO     /print_job/state: pre_print
2020-08-17 18:14:25,875 INFO     Previous Progress:
2020-08-17 18:14:25,876 INFO     0.0
2020-08-17 18:14:25,876 INFO     Current Progress:
2020-08-17 18:14:25,876 INFO     0.0
2020-08-17 18:14:25,876 INFO     Sleeping for 30 seconds...
2020-08-17 18:14:57,217 INFO     flowState: wait_user_action
2020-08-17 18:14:57,228 INFO     /printer/state: printing
2020-08-17 18:14:57,228 INFO     /print_job/state: wait_user_action
2020-08-17 18:14:57,266 INFO     hue mismatch!
2020-08-17 18:14:57,266 INFO     Expected 0.0 but it's currently 129.10345
2020-08-17 18:14:57,267 INFO     Sending {"hue": 0.0, "saturation": 100.0, "brightness": 28.07843} to http://10.10.30.27/api/v1/printer/led
2020-08-17 18:14:57,340 INFO     New job found!
2020-08-17 18:14:57,350 ERROR    Traceback (most recent call last):
2020-08-17 18:14:57,351 ERROR      File "Printzini.py", line 93, in <module>
2020-08-17 18:14:57,360 ERROR    main(conffile)
2020-08-17 18:14:57,361 ERROR      File "Printzini.py", line 86, in main
2020-08-17 18:14:57,362 ERROR    squashUltiCam=squashUltiCam)
2020-08-17 18:14:57,362 ERROR      File "/home/lig/Ultimonitor/ultimonitor/monitoring.py", line 252, in monitorUltimaker
2020-08-17 18:14:57,365 ERROR    pJob, notices = checkJob(stats, pJob, notices)
2020-08-17 18:14:57,366 ERROR      File "/home/lig/Ultimonitor/ultimonitor/monitoring.py", line 156, in checkJob
2020-08-17 18:14:57,367 ERROR    "%Y-%m-%dT%H:%M:%S")
2020-08-17 18:14:57,367 ERROR      File "/usr/local/lib/python3.7/_strptime.py", line 577, in _strptime_datetime
2020-08-17 18:14:57,371 ERROR    tt, fraction, gmtoff_fraction = _strptime(data_string, format)
2020-08-17 18:14:57,372 ERROR      File "/usr/local/lib/python3.7/_strptime.py", line 359, in _strptime
2020-08-17 18:14:57,373 ERROR    (data_string, format))
2020-08-17 18:14:57,374 ERROR    ValueError
2020-08-17 18:14:57,374 ERROR    :
2020-08-17 18:14:57,375 ERROR    time data '' does not match format '%Y-%m-%dT%H:%M:%S'
2020-08-17 18:15:18,786 INFO     flowState: wait_user_action
2020-08-17 18:15:18,793 INFO     /printer/state: printing
2020-08-17 18:15:18,794 INFO     /print_job/state: wait_user_action
2020-08-17 18:15:18,848 INFO     New job found!
2020-08-17 18:15:18,873 ERROR    Traceback (most recent call last):
2020-08-17 18:15:18,874 ERROR      File "Printzini.py", line 93, in <module>
2020-08-17 18:15:18,876 ERROR    main(conffile)
2020-08-17 18:15:18,876 ERROR      File "Printzini.py", line 86, in main
2020-08-17 18:15:18,878 ERROR    squashUltiCam=squashUltiCam)
2020-08-17 18:15:18,879 ERROR      File "/home/lig/Ultimonitor/ultimonitor/monitoring.py", line 252, in monitorUltimaker
2020-08-17 18:15:18,883 ERROR    pJob, notices = checkJob(stats, pJob, notices)
2020-08-17 18:15:18,883 ERROR      File "/home/lig/Ultimonitor/ultimonitor/monitoring.py", line 156, in checkJob
2020-08-17 18:15:18,885 ERROR    "%Y-%m-%dT%H:%M:%S")
2020-08-17 18:15:18,886 ERROR      File "/usr/local/lib/python3.7/_strptime.py", line 577, in _strptime_datetime
2020-08-17 18:15:18,892 ERROR    tt, fraction, gmtoff_fraction = _strptime(data_string, format)
2020-08-17 18:15:18,893 ERROR      File "/usr/local/lib/python3.7/_strptime.py", line 359, in _strptime
2020-08-17 18:15:18,896 ERROR    (data_string, format))
2020-08-17 18:15:18,896 ERROR    ValueError
2020-08-17 18:15:18,897 ERROR    :
2020-08-17 18:15:18,898 ERROR    time data '' does not match format '%Y-%m-%dT%H:%M:%S'
2020-08-17 18:15:36,647 INFO     flowState: wait_user_action
2020-08-17 18:15:36,648 INFO     /printer/state: printing
2020-08-17 18:15:36,648 INFO     /print_job/state: wait_user_action
2020-08-17 18:15:36,696 INFO     New job found!
2020-08-17 18:15:36,719 ERROR    Traceback (most recent call last):
2020-08-17 18:15:36,720 ERROR      File "Printzini.py", line 93, in <module>
2020-08-17 18:15:36,721 ERROR    main(conffile)
2020-08-17 18:15:36,722 ERROR      File "Printzini.py", line 86, in main
2020-08-17 18:15:36,723 ERROR    squashUltiCam=squashUltiCam)
2020-08-17 18:15:36,724 ERROR      File "/home/lig/Ultimonitor/ultimonitor/monitoring.py", line 252, in monitorUltimaker
2020-08-17 18:15:36,727 ERROR    pJob, notices = checkJob(stats, pJob, notices)
2020-08-17 18:15:36,727 ERROR      File "/home/lig/Ultimonitor/ultimonitor/monitoring.py", line 156, in checkJob
2020-08-17 18:15:36,729 ERROR    "%Y-%m-%dT%H:%M:%S")
2020-08-17 18:15:36,730 ERROR      File "/usr/local/lib/python3.7/_strptime.py", line 577, in _strptime_datetime
2020-08-17 18:15:36,733 ERROR    tt, fraction, gmtoff_fraction = _strptime(data_string, format)
2020-08-17 18:15:36,734 ERROR      File "/usr/local/lib/python3.7/_strptime.py", line 359, in _strptime
2020-08-17 18:15:36,736 ERROR    (data_string, format))
2020-08-17 18:15:36,737 ERROR    ValueError
2020-08-17 18:15:36,737 ERROR    :
2020-08-17 18:15:36,737 ERROR    time data '' does not match format '%Y-%m-%dT%H:%M:%S'
2020-08-17 18:15:48,750 INFO     flowState: wait_user_action
2020-08-17 18:15:48,751 INFO     /printer/state: printing
2020-08-17 18:15:48,751 INFO     /print_job/state: wait_user_action
2020-08-17 18:15:48,787 INFO     New job found!
2020-08-17 18:15:48,799 ERROR    Traceback (most recent call last):
2020-08-17 18:15:48,799 ERROR      File "Printzini.py", line 93, in <module>
2020-08-17 18:15:48,800 ERROR    main(conffile)
2020-08-17 18:15:48,800 ERROR      File "Printzini.py", line 86, in main
2020-08-17 18:15:48,801 ERROR    squashUltiCam=squashUltiCam)
2020-08-17 18:15:48,801 ERROR      File "/home/lig/Ultimonitor/ultimonitor/monitoring.py", line 252, in monitorUltimaker
2020-08-17 18:15:48,803 ERROR    pJob, notices = checkJob(stats, pJob, notices)
2020-08-17 18:15:48,803 ERROR      File "/home/lig/Ultimonitor/ultimonitor/monitoring.py", line 156, in checkJob
2020-08-17 18:15:48,804 ERROR    "%Y-%m-%dT%H:%M:%S")
2020-08-17 18:15:48,804 ERROR      File "/usr/local/lib/python3.7/_strptime.py", line 577, in _strptime_datetime
2020-08-17 18:15:48,806 ERROR    tt, fraction, gmtoff_fraction = _strptime(data_string, format)
2020-08-17 18:15:48,807 ERROR      File "/usr/local/lib/python3.7/_strptime.py", line 359, in _strptime
2020-08-17 18:15:48,808 ERROR    (data_string, format))
2020-08-17 18:15:48,808 ERROR    ValueError
2020-08-17 18:15:48,809 ERROR    :
2020-08-17 18:15:48,809 ERROR    time data '' does not match format '%Y-%m-%dT%H:%M:%S'
2020-08-17 18:16:00,762 INFO     flowState: wait_user_action
2020-08-17 18:16:00,762 INFO     /printer/state: printing
2020-08-17 18:16:00,762 INFO     /print_job/state: wait_user_action
2020-08-17 18:16:00,807 INFO     New job found!
2020-08-17 18:16:00,830 ERROR    Traceback (most recent call last):
2020-08-17 18:16:00,831 ERROR      File "Printzini.py", line 93, in <module>
2020-08-17 18:16:00,832 ERROR    main(conffile)
2020-08-17 18:16:00,833 ERROR      File "Printzini.py", line 86, in main
2020-08-17 18:16:00,835 ERROR    squashUltiCam=squashUltiCam)
2020-08-17 18:16:00,835 ERROR      File "/home/lig/Ultimonitor/ultimonitor/monitoring.py", line 252, in monitorUltimaker
2020-08-17 18:16:00,838 ERROR    pJob, notices = checkJob(stats, pJob, notices)
2020-08-17 18:16:00,838 ERROR      File "/home/lig/Ultimonitor/ultimonitor/monitoring.py", line 156, in checkJob
2020-08-17 18:16:00,840 ERROR    "%Y-%m-%dT%H:%M:%S")
2020-08-17 18:16:00,841 ERROR      File "/usr/local/lib/python3.7/_strptime.py", line 577, in _strptime_datetime
2020-08-17 18:16:00,844 ERROR    tt, fraction, gmtoff_fraction = _strptime(data_string, format)
2020-08-17 18:16:00,845 ERROR      File "/usr/local/lib/python3.7/_strptime.py", line 359, in _strptime
2020-08-17 18:16:00,848 ERROR    (data_string, format))
2020-08-17 18:16:00,848 ERROR    ValueError
2020-08-17 18:16:00,849 ERROR    :
2020-08-17 18:16:00,850 ERROR    time data '' does not match format '%Y-%m-%dT%H:%M:%S'
2020-08-17 18:16:14,121 INFO     flowState: wait_user_action
2020-08-17 18:16:14,122 INFO     /printer/state: printing
2020-08-17 18:16:14,122 INFO     /print_job/state: wait_user_action
2020-08-17 18:16:14,161 INFO     New job found!
2020-08-17 18:16:14,173 ERROR    Traceback (most recent call last):
2020-08-17 18:16:14,173 ERROR      File "Printzini.py", line 93, in <module>
2020-08-17 18:16:14,174 ERROR    main(conffile)
2020-08-17 18:16:14,175 ERROR      File "Printzini.py", line 86, in main
2020-08-17 18:16:14,176 ERROR    squashUltiCam=squashUltiCam)
2020-08-17 18:16:14,176 ERROR      File "/home/lig/Ultimonitor/ultimonitor/monitoring.py", line 252, in monitorUltimaker
2020-08-17 18:16:14,177 ERROR    pJob, notices = checkJob(stats, pJob, notices)
2020-08-17 18:16:14,178 ERROR      File "/home/lig/Ultimonitor/ultimonitor/monitoring.py", line 156, in checkJob
2020-08-17 18:16:14,178 ERROR    "%Y-%m-%dT%H:%M:%S")
2020-08-17 18:16:14,179 ERROR      File "/usr/local/lib/python3.7/_strptime.py", line 577, in _strptime_datetime
2020-08-17 18:16:14,181 ERROR    tt, fraction, gmtoff_fraction = _strptime(data_string, format)
2020-08-17 18:16:14,181 ERROR      File "/usr/local/lib/python3.7/_strptime.py", line 359, in _strptime
2020-08-17 18:16:14,182 ERROR    (data_string, format))
2020-08-17 18:16:14,183 ERROR    ValueError
2020-08-17 18:16:14,183 ERROR    :
2020-08-17 18:16:14,183 ERROR    time data '' does not match format '%Y-%m-%dT%H:%M:%S'
2020-08-17 18:16:26,307 INFO     flowState: wait_user_action
2020-08-17 18:16:26,308 INFO     /printer/state: printing
2020-08-17 18:16:26,308 INFO     /print_job/state: wait_user_action
2020-08-17 18:16:26,345 INFO     New job found!
2020-08-17 18:16:26,357 ERROR    Traceback (most recent call last):
2020-08-17 18:16:26,358 ERROR      File "Printzini.py", line 93, in <module>
2020-08-17 18:16:26,359 ERROR    main(conffile)
2020-08-17 18:16:26,359 ERROR      File "Printzini.py", line 86, in main
2020-08-17 18:16:26,360 ERROR    squashUltiCam=squashUltiCam)
2020-08-17 18:16:26,360 ERROR      File "/home/lig/Ultimonitor/ultimonitor/monitoring.py", line 252, in monitorUltimaker
2020-08-17 18:16:26,361 ERROR    pJob, notices = checkJob(stats, pJob, notices)
2020-08-17 18:16:26,361 ERROR      File "/home/lig/Ultimonitor/ultimonitor/monitoring.py", line 156, in checkJob
2020-08-17 18:16:26,362 ERROR    "%Y-%m-%dT%H:%M:%S")
2020-08-17 18:16:26,363 ERROR      File "/usr/local/lib/python3.7/_strptime.py", line 577, in _strptime_datetime
2020-08-17 18:16:26,365 ERROR    tt, fraction, gmtoff_fraction = _strptime(data_string, format)
2020-08-17 18:16:26,365 ERROR      File "/usr/local/lib/python3.7/_strptime.py", line 359, in _strptime
2020-08-17 18:16:26,366 ERROR    (data_string, format))
2020-08-17 18:16:26,367 ERROR    ValueError
2020-08-17 18:16:26,367 ERROR    :
2020-08-17 18:16:26,367 ERROR    time data '' does not match format '%Y-%m-%dT%H:%M:%S'
2020-08-17 18:16:38,656 INFO     flowState: wait_user_action
2020-08-17 18:16:38,656 INFO     /printer/state: printing
2020-08-17 18:16:38,657 INFO     /print_job/state: wait_user_action
2020-08-17 18:16:38,693 INFO     New job found!
2020-08-17 18:16:38,705 ERROR    Traceback (most recent call last):
2020-08-17 18:16:38,705 ERROR      File "Printzini.py", line 93, in <module>
2020-08-17 18:16:38,706 ERROR    main(conffile)
2020-08-17 18:16:38,707 ERROR      File "Printzini.py", line 86, in main
2020-08-17 18:16:38,707 ERROR    squashUltiCam=squashUltiCam)
2020-08-17 18:16:38,708 ERROR      File "/home/lig/Ultimonitor/ultimonitor/monitoring.py", line 252, in monitorUltimaker
2020-08-17 18:16:38,709 ERROR    pJob, notices = checkJob(stats, pJob, notices)
2020-08-17 18:16:38,709 ERROR      File "/home/lig/Ultimonitor/ultimonitor/monitoring.py", line 156, in checkJob
2020-08-17 18:16:38,710 ERROR    "%Y-%m-%dT%H:%M:%S")
2020-08-17 18:16:38,710 ERROR      File "/usr/local/lib/python3.7/_strptime.py", line 577, in _strptime_datetime
2020-08-17 18:16:38,712 ERROR    tt, fraction, gmtoff_fraction = _strptime(data_string, format)
2020-08-17 18:16:38,713 ERROR      File "/usr/local/lib/python3.7/_strptime.py", line 359, in _strptime
2020-08-17 18:16:38,714 ERROR    (data_string, format))
2020-08-17 18:16:38,714 ERROR    ValueError
2020-08-17 18:16:38,715 ERROR    :
2020-08-17 18:16:38,715 ERROR    time data '' does not match format '%Y-%m-%dT%H:%M:%S'
2020-08-17 18:16:52,183 INFO     flowState: wait_user_action
2020-08-17 18:16:52,183 INFO     /printer/state: printing
2020-08-17 18:16:52,184 INFO     /print_job/state: wait_user_action
2020-08-17 18:16:52,222 INFO     New job found!
2020-08-17 18:16:52,234 ERROR    Traceback (most recent call last):
2020-08-17 18:16:52,235 ERROR      File "Printzini.py", line 93, in <module>
2020-08-17 18:16:52,236 ERROR    main(conffile)
2020-08-17 18:16:52,236 ERROR      File "Printzini.py", line 86, in main
2020-08-17 18:16:52,237 ERROR    squashUltiCam=squashUltiCam)
2020-08-17 18:16:52,237 ERROR      File "/home/lig/Ultimonitor/ultimonitor/monitoring.py", line 252, in monitorUltimaker
2020-08-17 18:16:52,238 ERROR    pJob, notices = checkJob(stats, pJob, notices)
2020-08-17 18:16:52,239 ERROR      File "/home/lig/Ultimonitor/ultimonitor/monitoring.py", line 156, in checkJob
2020-08-17 18:16:52,240 ERROR    "%Y-%m-%dT%H:%M:%S")
2020-08-17 18:16:52,240 ERROR      File "/usr/local/lib/python3.7/_strptime.py", line 577, in _strptime_datetime
2020-08-17 18:16:52,242 ERROR    tt, fraction, gmtoff_fraction = _strptime(data_string, format)
2020-08-17 18:16:52,242 ERROR      File "/usr/local/lib/python3.7/_strptime.py", line 359, in _strptime
2020-08-17 18:16:52,243 ERROR    (data_string, format))
2020-08-17 18:16:52,244 ERROR    ValueError
2020-08-17 18:16:52,244 ERROR    :
2020-08-17 18:16:52,244 ERROR    time data '' does not match format '%Y-%m-%dT%H:%M:%S'
2020-08-17 18:17:04,672 INFO     flowState: wait_user_action
2020-08-17 18:17:04,673 INFO     /printer/state: printing
2020-08-17 18:17:04,673 INFO     /print_job/state: wait_user_action
2020-08-17 18:17:04,743 INFO     New job found!
2020-08-17 18:17:04,766 ERROR    Traceback (most recent call last):
2020-08-17 18:17:04,767 ERROR      File "Printzini.py", line 93, in <module>
2020-08-17 18:17:04,769 ERROR    main(conffile)
2020-08-17 18:17:04,769 ERROR      File "Printzini.py", line 86, in main
2020-08-17 18:17:04,771 ERROR    squashUltiCam=squashUltiCam)
2020-08-17 18:17:04,771 ERROR      File "/home/lig/Ultimonitor/ultimonitor/monitoring.py", line 252, in monitorUltimaker
2020-08-17 18:17:04,773 ERROR    pJob, notices = checkJob(stats, pJob, notices)
2020-08-17 18:17:04,774 ERROR      File "/home/lig/Ultimonitor/ultimonitor/monitoring.py", line 156, in checkJob
2020-08-17 18:17:04,776 ERROR    "%Y-%m-%dT%H:%M:%S")
2020-08-17 18:17:04,777 ERROR      File "/usr/local/lib/python3.7/_strptime.py", line 577, in _strptime_datetime
2020-08-17 18:17:04,780 ERROR    tt, fraction, gmtoff_fraction = _strptime(data_string, format)
2020-08-17 18:17:04,781 ERROR      File "/usr/local/lib/python3.7/_strptime.py", line 359, in _strptime
2020-08-17 18:17:04,784 ERROR    (data_string, format))
2020-08-17 18:17:04,784 ERROR    ValueError
2020-08-17 18:17:04,785 ERROR    :
2020-08-17 18:17:04,785 ERROR    time data '' does not match format '%Y-%m-%dT%H:%M:%S'
2020-08-17 18:17:17,751 INFO     flowState: wait_user_action
2020-08-17 18:17:17,752 INFO     /printer/state: printing
2020-08-17 18:17:17,753 INFO     /print_job/state: wait_user_action
2020-08-17 18:17:18,284 INFO     New job found!
2020-08-17 18:17:18,307 ERROR    Traceback (most recent call last):
2020-08-17 18:17:18,308 ERROR      File "Printzini.py", line 93, in <module>
2020-08-17 18:17:18,310 ERROR    main(conffile)
2020-08-17 18:17:18,311 ERROR      File "Printzini.py", line 86, in main
2020-08-17 18:17:18,312 ERROR    squashUltiCam=squashUltiCam)
2020-08-17 18:17:18,313 ERROR      File "/home/lig/Ultimonitor/ultimonitor/monitoring.py", line 252, in monitorUltimaker
2020-08-17 18:17:18,315 ERROR    pJob, notices = checkJob(stats, pJob, notices)
2020-08-17 18:17:18,316 ERROR      File "/home/lig/Ultimonitor/ultimonitor/monitoring.py", line 156, in checkJob
2020-08-17 18:17:18,318 ERROR    "%Y-%m-%dT%H:%M:%S")
2020-08-17 18:17:18,318 ERROR      File "/usr/local/lib/python3.7/_strptime.py", line 577, in _strptime_datetime
2020-08-17 18:17:18,322 ERROR    tt, fraction, gmtoff_fraction = _strptime(data_string, format)
2020-08-17 18:17:18,323 ERROR      File "/usr/local/lib/python3.7/_strptime.py", line 359, in _strptime
2020-08-17 18:17:18,325 ERROR    (data_string, format))
2020-08-17 18:17:18,326 ERROR    ValueError
2020-08-17 18:17:18,327 ERROR    :
2020-08-17 18:17:18,327 ERROR    time data '' does not match format '%Y-%m-%dT%H:%M:%S'
2020-08-17 18:17:32,764 INFO     flowState: wait_user_action
2020-08-17 18:17:32,765 INFO     /printer/state: printing
2020-08-17 18:17:32,766 INFO     /print_job/state: wait_user_action
2020-08-17 18:17:32,811 INFO     New job found!
2020-08-17 18:17:32,834 ERROR    Traceback (most recent call last):
2020-08-17 18:17:32,835 ERROR      File "Printzini.py", line 93, in <module>
2020-08-17 18:17:32,837 ERROR    main(conffile)
2020-08-17 18:17:32,837 ERROR      File "Printzini.py", line 86, in main
2020-08-17 18:17:32,839 ERROR    squashUltiCam=squashUltiCam)
2020-08-17 18:17:32,839 ERROR      File "/home/lig/Ultimonitor/ultimonitor/monitoring.py", line 252, in monitorUltimaker
2020-08-17 18:17:32,842 ERROR    pJob, notices = checkJob(stats, pJob, notices)
2020-08-17 18:17:32,842 ERROR      File "/home/lig/Ultimonitor/ultimonitor/monitoring.py", line 156, in checkJob
2020-08-17 18:17:32,844 ERROR    "%Y-%m-%dT%H:%M:%S")
2020-08-17 18:17:32,845 ERROR      File "/usr/local/lib/python3.7/_strptime.py", line 577, in _strptime_datetime
2020-08-17 18:17:32,848 ERROR    tt, fraction, gmtoff_fraction = _strptime(data_string, format)
2020-08-17 18:17:32,849 ERROR      File "/usr/local/lib/python3.7/_strptime.py", line 359, in _strptime
2020-08-17 18:17:32,852 ERROR    (data_string, format))
2020-08-17 18:17:32,853 ERROR    ValueError
2020-08-17 18:17:32,853 ERROR    :
2020-08-17 18:17:32,854 ERROR    time data '' does not match format '%Y-%m-%dT%H:%M:%S'
2020-08-17 18:17:51,157 INFO     flowState: wait_user_action
2020-08-17 18:17:51,158 INFO     /printer/state: printing
2020-08-17 18:17:51,158 INFO     /print_job/state: wait_user_action
2020-08-17 18:17:51,202 INFO     New job found!
2020-08-17 18:17:51,214 ERROR    Traceback (most recent call last):
2020-08-17 18:17:51,214 ERROR      File "Printzini.py", line 93, in <module>
2020-08-17 18:17:51,215 ERROR    main(conffile)
2020-08-17 18:17:51,215 ERROR      File "Printzini.py", line 86, in main
2020-08-17 18:17:51,216 ERROR    squashUltiCam=squashUltiCam)
2020-08-17 18:17:51,217 ERROR      File "/home/lig/Ultimonitor/ultimonitor/monitoring.py", line 252, in monitorUltimaker
2020-08-17 18:17:51,218 ERROR    pJob, notices = checkJob(stats, pJob, notices)
2020-08-17 18:17:51,218 ERROR      File "/home/lig/Ultimonitor/ultimonitor/monitoring.py", line 156, in checkJob
2020-08-17 18:17:51,219 ERROR    "%Y-%m-%dT%H:%M:%S")
2020-08-17 18:17:51,219 ERROR      File "/usr/local/lib/python3.7/_strptime.py", line 577, in _strptime_datetime
2020-08-17 18:17:51,221 ERROR    tt, fraction, gmtoff_fraction = _strptime(data_string, format)
2020-08-17 18:17:51,222 ERROR      File "/usr/local/lib/python3.7/_strptime.py", line 359, in _strptime
2020-08-17 18:17:51,223 ERROR    (data_string, format))
2020-08-17 18:17:51,223 ERROR    ValueError
2020-08-17 18:17:51,224 ERROR    :
2020-08-17 18:17:51,224 ERROR    time data '' does not match format '%Y-%m-%dT%H:%M:%S'
2020-08-17 18:18:17,607 INFO     flowState: wait_user_action
2020-08-17 18:18:17,608 INFO     /printer/state: printing
2020-08-17 18:18:17,609 INFO     /print_job/state: wait_user_action
2020-08-17 18:18:17,670 INFO     New job found!
2020-08-17 18:18:17,693 ERROR    Traceback (most recent call last):
2020-08-17 18:18:17,694 ERROR      File "Printzini.py", line 93, in <module>
2020-08-17 18:18:17,696 ERROR    main(conffile)
2020-08-17 18:18:17,696 ERROR      File "Printzini.py", line 86, in main
2020-08-17 18:18:17,698 ERROR    squashUltiCam=squashUltiCam)
2020-08-17 18:18:17,698 ERROR      File "/home/lig/Ultimonitor/ultimonitor/monitoring.py", line 252, in monitorUltimaker
2020-08-17 18:18:17,701 ERROR    pJob, notices = checkJob(stats, pJob, notices)
2020-08-17 18:18:17,701 ERROR      File "/home/lig/Ultimonitor/ultimonitor/monitoring.py", line 156, in checkJob
2020-08-17 18:18:17,703 ERROR    "%Y-%m-%dT%H:%M:%S")
2020-08-17 18:18:17,704 ERROR      File "/usr/local/lib/python3.7/_strptime.py", line 577, in _strptime_datetime
2020-08-17 18:18:17,708 ERROR    tt, fraction, gmtoff_fraction = _strptime(data_string, format)
2020-08-17 18:18:17,708 ERROR      File "/usr/local/lib/python3.7/_strptime.py", line 359, in _strptime
2020-08-17 18:18:17,711 ERROR    (data_string, format))
2020-08-17 18:18:17,712 ERROR    ValueError
2020-08-17 18:18:17,712 ERROR    :
2020-08-17 18:18:17,713 ERROR    time data '' does not match format '%Y-%m-%dT%H:%M:%S'
2020-08-17 18:18:54,461 INFO     flowState: wait_user_action
2020-08-17 18:18:54,461 INFO     /printer/state: printing
2020-08-17 18:18:54,462 INFO     /print_job/state: wait_user_action
2020-08-17 18:18:54,498 INFO     New job found!
2020-08-17 18:18:54,509 ERROR    Traceback (most recent call last):
2020-08-17 18:18:54,510 ERROR      File "Printzini.py", line 93, in <module>
2020-08-17 18:18:54,511 ERROR    main(conffile)
2020-08-17 18:18:54,511 ERROR      File "Printzini.py", line 86, in main
2020-08-17 18:18:54,512 ERROR    squashUltiCam=squashUltiCam)
2020-08-17 18:18:54,512 ERROR      File "/home/lig/Ultimonitor/ultimonitor/monitoring.py", line 252, in monitorUltimaker
2020-08-17 18:18:54,513 ERROR    pJob, notices = checkJob(stats, pJob, notices)
2020-08-17 18:18:54,514 ERROR      File "/home/lig/Ultimonitor/ultimonitor/monitoring.py", line 156, in checkJob
2020-08-17 18:18:54,515 ERROR    "%Y-%m-%dT%H:%M:%S")
2020-08-17 18:18:54,515 ERROR      File "/usr/local/lib/python3.7/_strptime.py", line 577, in _strptime_datetime
2020-08-17 18:18:54,517 ERROR    tt, fraction, gmtoff_fraction = _strptime(data_string, format)
2020-08-17 18:18:54,517 ERROR      File "/usr/local/lib/python3.7/_strptime.py", line 359, in _strptime
2020-08-17 18:18:54,519 ERROR    (data_string, format))
2020-08-17 18:18:54,519 ERROR    ValueError
2020-08-17 18:18:54,519 ERROR    :
2020-08-17 18:18:54,520 ERROR    time data '' does not match format '%Y-%m-%dT%H:%M:%S'
2020-08-17 18:19:57,473 INFO     flowState: wait_user_action
2020-08-17 18:19:57,475 INFO     /printer/state: printing
2020-08-17 18:19:57,476 INFO     /print_job/state: wait_user_action
2020-08-17 18:19:57,513 INFO     New job found!
2020-08-17 18:19:57,525 ERROR    Traceback (most recent call last):
2020-08-17 18:19:57,525 ERROR      File "Printzini.py", line 93, in <module>
2020-08-17 18:19:57,526 ERROR    main(conffile)
2020-08-17 18:19:57,527 ERROR      File "Printzini.py", line 86, in main
2020-08-17 18:19:57,527 ERROR    squashUltiCam=squashUltiCam)
2020-08-17 18:19:57,528 ERROR      File "/home/lig/Ultimonitor/ultimonitor/monitoring.py", line 252, in monitorUltimaker
2020-08-17 18:19:57,529 ERROR    pJob, notices = checkJob(stats, pJob, notices)
2020-08-17 18:19:57,529 ERROR      File "/home/lig/Ultimonitor/ultimonitor/monitoring.py", line 156, in checkJob
2020-08-17 18:19:57,530 ERROR    "%Y-%m-%dT%H:%M:%S")
2020-08-17 18:19:57,530 ERROR      File "/usr/local/lib/python3.7/_strptime.py", line 577, in _strptime_datetime
2020-08-17 18:19:57,532 ERROR    tt, fraction, gmtoff_fraction = _strptime(data_string, format)
2020-08-17 18:19:57,533 ERROR      File "/usr/local/lib/python3.7/_strptime.py", line 359, in _strptime
2020-08-17 18:19:57,534 ERROR    (data_string, format))
2020-08-17 18:19:57,535 ERROR    ValueError
2020-08-17 18:19:57,535 ERROR    :
2020-08-17 18:19:57,535 ERROR    time data '' does not match format '%Y-%m-%dT%H:%M:%S'

I think this one is because when the printer errored out (and entered wait_user_action) the same data isn't returned. I don't hit that failure mode often, but I should trap for it at least it seems?

Account for network interruptions

Printer was rebooted this morning, which caused an unhandled exception in this monitoring code because queries via apitools.queryChecker failed (and were handled) and returned empty dicts, which caused KeyError later when other bits tried to access the juicy information in them.

Strange failure querying hotends while in progress

Not sure if this is just a "busy" sort of signal from the ultimaker API or something, but I am seeing more failures along these lines:

2023-06-13 18:31:02,406 INFO     Current Progress:
2023-06-13 18:31:02,406 INFO     67.66444792096257
2023-06-13 18:31:02,407 INFO     Sleeping for 30 seconds...
2023-06-13 18:31:32,954 ERROR    Traceback (most recent call last):
2023-06-13 18:31:32,954 ERROR      File "Printzini.py", line 93, in <module>
2023-06-13 18:31:32,967 ERROR    main(conffile)
2023-06-13 18:31:32,967 ERROR      File "Printzini.py", line 86, in main
2023-06-13 18:31:32,968 ERROR    squashUltiCam=squashUltiCam)
2023-06-13 18:31:32,968 ERROR      File "/home/lig/Ultimonitor/ultimonitor/monitoring.py", line 207, in monitorUltimaker
2023-06-13 18:31:32,971 ERROR    stats = printer.statusCheck(printerip)
2023-06-13 18:31:32,972 ERROR      File "/home/lig/Ultimonitor/ultimonitor/printer.py", line 234, in statusCheck
2023-06-13 18:31:32,974 ERROR    ext1temps = headinfo['extruders'][0]['hotend']['temperature']
2023-06-13 18:31:32,976 ERROR    KeyError
2023-06-13 18:31:32,977 ERROR    :
2023-06-13 18:31:32,977 ERROR    'extruders'
2023-06-13 18:31:56,861 INFO     flowState: printing
2023-06-13 18:31:56,863 INFO     /printer/state: printing
2023-06-13 18:31:56,864 INFO     /print_job/state: printing
2023-06-13 18:31:56,899 INFO     New job found!

Looking at the lines in question

bedtemp = api.queryChecker(printerip, "printer/bed/temperature")
if bedtemp != {}:
ext1temps = headinfo['extruders'][0]['hotend']['temperature']
ext2temps = headinfo['extruders'][1]['hotend']['temperature']
else:
ext1temps = ""

I can just wrap them in a try...except block and see what comes out after that. Has happened once a day for the last 2-3 days now.

Saved state

Save the state of the print currently being monitored to a json file on disk (or something) to allow persistence of info between code restarts. Only way to avoid duplicate notices.

Could make the file a sort of snapshot of progress/parameters, too, which might be nice. Needs a little more thought.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.