Stephan3 / dwc2-for-klipper

A translator between DWC2 and Klipper
GNU General Public License v3.0
160 stars 38 forks source link

Macro loading is broken on latest DWC releases #49

Closed altvnk closed 4 years ago

altvnk commented 4 years ago

After updating to DWC 2.0.6 i have noticed that macros are not being loaded anymore. Just checked recently released 2.0.7 and it's affected too.

Log message ``` Uncaught exception GET /rr_filelist?dir=0%3A%2Fmacros&first=0 (192.168.145.121) HTTPServerRequest(protocol='http', host='raspberrypi.local:4750', method='GET', uri='/rr_filelist?dir=0%3A%2Fmacros&first=0', version='HTTP/1.1', remote_ip='192.168.145.121') Traceback (most recent call last): File "/home/pi/klippy-env/local/lib/python2.7/site-packages/tornado/web.py", line 1592, in _execute result = yield result File "/home/pi/klippy-env/local/lib/python2.7/site-packages/tornado/gen.py", line 1133, in run value = future.result() File "/home/pi/klippy-env/local/lib/python2.7/site-packages/tornado/concurrent.py", line 261, in result raise_exc_info(self._exc_info) File "/home/pi/klippy-env/local/lib/python2.7/site-packages/tornado/gen.py", line 326, in wrapper yielded = next(result) File "/home/pi/klipper/klippy/extras/web_dwc2.py", line 218, in get self.repl_ = self.web_dwc2.rr_filelist(self) File "/home/pi/klipper/klippy/extras/web_dwc2.py", line 454, in rr_filelist "date": datetime.datetime.fromtimestamp(os.stat(el_path).st_mtime).strftime("%Y-%m-%dT%H:%M:%S") UnboundLocalError: local variable 'el_path' referenced before assignment DWC2:17503.64 - 192.168.145.121 - GET - /rr_filelist?dir=0%3A%2Fmacros&first=0 ```
shadrincev commented 4 years ago

Suddenly you have the same as me. I updated DWC to version 2.0.6 and I lost the possibility of manual extrusion, but I put the DuetWebControl-SBC version.zip, and now updated to 2.0.7 and put it DuetWebControl-SD.zip. Everything is back. It might help...

altvnk commented 4 years ago

Manual extrusion was broken for me too, resolved by clearing browser cache.

Stephan3 commented 4 years ago

https://github.com/Stephan3/dwc2-for-klipper/commit/997655aa4ef3e70b9ca1aba47a7560d42076028a

this is solved since 2?3? days

altvnk commented 4 years ago

Strange, I pulled master before submitting the issue. Thanks, I will double check.

altvnk commented 4 years ago

So, as I said I'm on latest master, on commit you have referenced

git log | head -n 1
commit 997655aa4ef3e70b9ca1aba47a7560d42076028a

Symlink is in place, klipper restarted and everything, but I still getting 500's. Any ideas what else could be wrong?

Wireheadbe commented 4 years ago

Same issue here edit: to be more specific, I have this in the macro's view

DWC2:02527.88 - 192.168.100.7 - GET - /rr_filelist?dir=0%3A%2Fmacros&first=0
Uncaught exception GET /rr_filelist?dir=0%3A%2Fmacros&first=0 (192.168.100.7)
HTTPServerRequest(protocol='http', host='octopi.wirehead.be:8080', method='GET', uri='/rr_filelist?dir=0%3A%2Fmacros&first=0', version='HTTP/1.1', remote_ip='192.168.100.7')
Traceback (most recent call last):
  File "/home/jeffrey/klippy-env/local/lib/python2.7/site-packages/tornado/web.py", line 1592, in _execute
    result = yield result
  File "/home/jeffrey/klippy-env/local/lib/python2.7/site-packages/tornado/gen.py", line 1133, in run
    value = future.result()
  File "/home/jeffrey/klippy-env/local/lib/python2.7/site-packages/tornado/concurrent.py", line 261, in result
    raise_exc_info(self._exc_info)
  File "/home/jeffrey/klippy-env/local/lib/python2.7/site-packages/tornado/gen.py", line 326, in wrapper
    yielded = next(result)
  File "/home/jeffrey/klipper/klippy/extras/web_dwc2.py", line 218, in get
    self.repl_ = self.web_dwc2.rr_filelist(self)
  File "/home/jeffrey/klipper/klippy/extras/web_dwc2.py", line 454, in rr_filelist
    "date": datetime.datetime.fromtimestamp(os.stat(el_path).st_mtime).strftime("%Y-%m-%dT%H:%M:%S")
UnboundLocalError: local variable 'el_path' referenced before assignment
Wireheadbe commented 4 years ago

Line 454 should be replaced:

"date": datetime.datetime.fromtimestamp(os.stat(el_path).st_mtime).strftime("%Y-%m-%dT%H:%M:%S")

"date": datetime.datetime.fromtimestamp(os.stat(self.klipper_config).st_mtime).strftime("%Y-%m-%dT%H:%M:%S")

Stephan3 commented 4 years ago

Yes so klipper macros get the date of the config file. that looks right to me, i fixed it.

Wireheadbe commented 4 years ago

Yep - seems like the most logical thing to do, thanks for committing :)

altvnk commented 4 years ago

That is definitely works as intended now. Many thanks!