JTechPhotonics/J-Tech-Photonics-Laser-Tool

Error when gcode header and footer paths not supplied [patch]

themanyone opened this issue · 1 comments

The errors are on line 66 and 71.

with open(self.options.header_path, 'r') as header_file:

Traceback (most recent call last):
File "/home/k/.config/inkscape/extensions/laser.py", line 278, in
effect.run()
File "/usr/share/inkscape/extensions/inkex/base.py", line 140, in run
self.save_raw(self.effect())
File "/home/k/.config/inkscape/extensions/laser.py", line 66, in effect
with open(self.options.header_path, 'r') as header_file:
IsADirectoryError: [Errno 21] Is a directory: '/home/k/.config/inkscape/extensions'

The fix in laser.py: Check that files exist

@@ -62,12 +62,12 @@ class GcodeExtension(EffectExtension):
                 n += 1
 
         header = None
-        if self.options.header_path:
+        if os.path.isfile(self.options.header_path):
             with open(self.options.header_path, 'r') as header_file:
                 header = header_file.read().splitlines()
 
         footer = None
-        if self.options.footer_path:
+        if os.path.isfile(self.options.footer_path):
             with open(self.options.footer_path, 'r') as footer_file:
                 footer = footer_file.read().splitlines()

The workaround. The user needs to create files and put the names in under the Advanced tab.

Is this still an issue with v2.3?