- added Exception handing for the case when the user is trying to save & overwrite a file already opened in another file
This commit is contained in:
parent
7a6c0541be
commit
6f526acb4d
|
@ -4669,10 +4669,13 @@ class App(QtCore.QObject):
|
||||||
with open(filename, 'w') as f:
|
with open(filename, 'w') as f:
|
||||||
for line in my_gcode:
|
for line in my_gcode:
|
||||||
f.write(line)
|
f.write(line)
|
||||||
|
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
self.inform.emit(_("[WARNING] No such file or directory"))
|
self.inform.emit(_("[WARNING] No such file or directory"))
|
||||||
return
|
return
|
||||||
|
except PermissionError:
|
||||||
|
self.inform.emit(_("[WARNING] Permission denied, saving not possible.\n"
|
||||||
|
"Most likely another app is holding the file open and not accessible."))
|
||||||
|
return
|
||||||
|
|
||||||
# Just for adding it to the recent files list.
|
# Just for adding it to the recent files list.
|
||||||
if self.defaults["global_open_style"] is False:
|
if self.defaults["global_open_style"] is False:
|
||||||
|
@ -7109,8 +7112,14 @@ class App(QtCore.QObject):
|
||||||
# Parse the xml through a xml parser just to add line feeds
|
# Parse the xml through a xml parser just to add line feeds
|
||||||
# and to make it look more pretty for the output
|
# and to make it look more pretty for the output
|
||||||
svgcode = parse_xml_string(svg_elem)
|
svgcode = parse_xml_string(svg_elem)
|
||||||
|
try:
|
||||||
with open(filename, 'w') as fp:
|
with open(filename, 'w') as fp:
|
||||||
fp.write(svgcode.toprettyxml())
|
fp.write(svgcode.toprettyxml())
|
||||||
|
except PermissionError:
|
||||||
|
self.inform.emit(_("[WARNING] Permission denied, saving not possible.\n"
|
||||||
|
"Most likely another app is holding the file open and not accessible."))
|
||||||
|
return 'fail'
|
||||||
|
|
||||||
if self.defaults["global_open_style"] is False:
|
if self.defaults["global_open_style"] is False:
|
||||||
self.file_opened.emit("SVG", filename)
|
self.file_opened.emit("SVG", filename)
|
||||||
self.file_saved.emit("SVG", filename)
|
self.file_saved.emit("SVG", filename)
|
||||||
|
@ -7213,8 +7222,13 @@ class App(QtCore.QObject):
|
||||||
# Parse the xml through a xml parser just to add line feeds
|
# Parse the xml through a xml parser just to add line feeds
|
||||||
# and to make it look more pretty for the output
|
# and to make it look more pretty for the output
|
||||||
doc = parse_xml_string(svg_elem)
|
doc = parse_xml_string(svg_elem)
|
||||||
|
try:
|
||||||
with open(filename, 'w') as fp:
|
with open(filename, 'w') as fp:
|
||||||
fp.write(doc.toprettyxml())
|
fp.write(doc.toprettyxml())
|
||||||
|
except PermissionError:
|
||||||
|
self.inform.emit(_("[WARNING] Permission denied, saving not possible.\n"
|
||||||
|
"Most likely another app is holding the file open and not accessible."))
|
||||||
|
return 'fail'
|
||||||
|
|
||||||
self.progress.emit(100)
|
self.progress.emit(100)
|
||||||
if self.defaults["global_open_style"] is False:
|
if self.defaults["global_open_style"] is False:
|
||||||
|
@ -7329,8 +7343,14 @@ class App(QtCore.QObject):
|
||||||
# Parse the xml through a xml parser just to add line feeds
|
# Parse the xml through a xml parser just to add line feeds
|
||||||
# and to make it look more pretty for the output
|
# and to make it look more pretty for the output
|
||||||
doc = parse_xml_string(svg_elem)
|
doc = parse_xml_string(svg_elem)
|
||||||
|
try:
|
||||||
with open(filename, 'w') as fp:
|
with open(filename, 'w') as fp:
|
||||||
fp.write(doc.toprettyxml())
|
fp.write(doc.toprettyxml())
|
||||||
|
except PermissionError:
|
||||||
|
self.inform.emit(_("[WARNING] Permission denied, saving not possible.\n"
|
||||||
|
"Most likely another app is holding the file open and not accessible."))
|
||||||
|
return 'fail'
|
||||||
|
|
||||||
self.progress.emit(100)
|
self.progress.emit(100)
|
||||||
if self.defaults["global_open_style"] is False:
|
if self.defaults["global_open_style"] is False:
|
||||||
self.file_opened.emit("SVG", filename)
|
self.file_opened.emit("SVG", filename)
|
||||||
|
@ -7371,6 +7391,7 @@ class App(QtCore.QObject):
|
||||||
file_string = StringIO(obj.source_file)
|
file_string = StringIO(obj.source_file)
|
||||||
time_string = "{:%A, %d %B %Y at %H:%M}".format(datetime.now())
|
time_string = "{:%A, %d %B %Y at %H:%M}".format(datetime.now())
|
||||||
|
|
||||||
|
try:
|
||||||
with open(filename, 'w') as file:
|
with open(filename, 'w') as file:
|
||||||
file.writelines('G04*\n')
|
file.writelines('G04*\n')
|
||||||
file.writelines('G04 %s (RE)GENERATED BY FLATCAM v%s - www.flatcam.org - Version Date: %s*\n' %
|
file.writelines('G04 %s (RE)GENERATED BY FLATCAM v%s - www.flatcam.org - Version Date: %s*\n' %
|
||||||
|
@ -7380,6 +7401,10 @@ class App(QtCore.QObject):
|
||||||
|
|
||||||
for line in file_string:
|
for line in file_string:
|
||||||
file.writelines(line)
|
file.writelines(line)
|
||||||
|
except PermissionError:
|
||||||
|
self.inform.emit(_("[WARNING] Permission denied, saving not possible.\n"
|
||||||
|
"Most likely another app is holding the file open and not accessible."))
|
||||||
|
return 'fail'
|
||||||
|
|
||||||
def export_excellon(self, obj_name, filename, use_thread=True):
|
def export_excellon(self, obj_name, filename, use_thread=True):
|
||||||
"""
|
"""
|
||||||
|
@ -7481,8 +7506,14 @@ class App(QtCore.QObject):
|
||||||
exported_excellon += excellon_code
|
exported_excellon += excellon_code
|
||||||
exported_excellon += footer
|
exported_excellon += footer
|
||||||
|
|
||||||
|
try:
|
||||||
with open(filename, 'w') as fp:
|
with open(filename, 'w') as fp:
|
||||||
fp.write(exported_excellon)
|
fp.write(exported_excellon)
|
||||||
|
except PermissionError:
|
||||||
|
self.inform.emit(_("[WARNING] Permission denied, saving not possible.\n"
|
||||||
|
"Most likely another app is holding the file open and not accessible."))
|
||||||
|
return 'fail'
|
||||||
|
|
||||||
if self.defaults["global_open_style"] is False:
|
if self.defaults["global_open_style"] is False:
|
||||||
self.file_opened.emit("Excellon", filename)
|
self.file_opened.emit("Excellon", filename)
|
||||||
self.file_saved.emit("Excellon", filename)
|
self.file_saved.emit("Excellon", filename)
|
||||||
|
@ -7598,8 +7629,14 @@ class App(QtCore.QObject):
|
||||||
exported_gerber += gerber_code
|
exported_gerber += gerber_code
|
||||||
exported_gerber += footer
|
exported_gerber += footer
|
||||||
|
|
||||||
|
try:
|
||||||
with open(filename, 'w') as fp:
|
with open(filename, 'w') as fp:
|
||||||
fp.write(exported_gerber)
|
fp.write(exported_gerber)
|
||||||
|
except PermissionError:
|
||||||
|
self.inform.emit(_("[WARNING] Permission denied, saving not possible.\n"
|
||||||
|
"Most likely another app is holding the file open and not accessible."))
|
||||||
|
return 'fail'
|
||||||
|
|
||||||
if self.defaults["global_open_style"] is False:
|
if self.defaults["global_open_style"] is False:
|
||||||
self.file_opened.emit("Gerber", filename)
|
self.file_opened.emit("Gerber", filename)
|
||||||
self.file_saved.emit("Gerber", filename)
|
self.file_saved.emit("Gerber", filename)
|
||||||
|
|
|
@ -5887,12 +5887,15 @@ class FlatCAMCNCjob(FlatCAMObj, CNCjob):
|
||||||
with open(filename, 'w') as f:
|
with open(filename, 'w') as f:
|
||||||
for line in lines:
|
for line in lines:
|
||||||
f.write(line)
|
f.write(line)
|
||||||
|
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
self.app.inform.emit(_(
|
self.app.inform.emit(_(
|
||||||
"[WARNING_NOTCL] No such file or directory"
|
"[WARNING_NOTCL] No such file or directory"
|
||||||
))
|
))
|
||||||
return
|
return
|
||||||
|
except PermissionError:
|
||||||
|
self.app.inform.emit(_("[WARNING] Permission denied, saving not possible.\n"
|
||||||
|
"Most likely another app is holding the file open and not accessible."))
|
||||||
|
return 'fail'
|
||||||
elif to_file is False:
|
elif to_file is False:
|
||||||
# Just for adding it to the recent files list.
|
# Just for adding it to the recent files list.
|
||||||
if self.app.defaults["global_open_style"] is False:
|
if self.app.defaults["global_open_style"] is False:
|
||||||
|
|
|
@ -9,6 +9,10 @@ CAD program, and create G-Code for Isolation routing.
|
||||||
|
|
||||||
=================================================
|
=================================================
|
||||||
|
|
||||||
|
9.09.2018
|
||||||
|
|
||||||
|
- added Exception handing for the case when the user is trying to save & overwrite a file already opened in another file
|
||||||
|
|
||||||
7.09.2019
|
7.09.2019
|
||||||
|
|
||||||
- replaced setFixedWidth calls with setMinimumWidth
|
- replaced setFixedWidth calls with setMinimumWidth
|
||||||
|
@ -26,7 +30,7 @@ CAD program, and create G-Code for Isolation routing.
|
||||||
5.08.2019
|
5.08.2019
|
||||||
|
|
||||||
- made sure that if using an negative Gerber isolation diameter, the resulting Geometry object will use a tool with positive diameter
|
- made sure that if using an negative Gerber isolation diameter, the resulting Geometry object will use a tool with positive diameter
|
||||||
- fixed bug that when isolating a Gerber file made out of a single polygon, an Recurrsion Exception was issued together with inability to create tbe isolation
|
- fixed bug that when isolating a Gerber file made out of a single polygon, an RecursionException was issued together with inability to create tbe isolation
|
||||||
- when applying a new language if there are any changes in the current project, the app will offer to save the project before the reboot
|
- when applying a new language if there are any changes in the current project, the app will offer to save the project before the reboot
|
||||||
|
|
||||||
3.08.2019
|
3.08.2019
|
||||||
|
|
|
@ -825,10 +825,10 @@ class ToolPaint(FlatCAMTool, Gerber):
|
||||||
tooldia = float('%.4f' % float(self.tools_table.item(0, 1).text()))
|
tooldia = float('%.4f' % float(self.tools_table.item(0, 1).text()))
|
||||||
|
|
||||||
# To be called after clicking on the plot.
|
# To be called after clicking on the plot.
|
||||||
def doit(event):
|
def on_mouse_press(event):
|
||||||
# do paint single only for left mouse clicks
|
# do paint single only for left mouse clicks
|
||||||
if event.button == 1:
|
if event.button == 1:
|
||||||
self.app.inform.emit(_("Painting polygon..."))
|
self.app.inform.emit(_("Painting selected area..."))
|
||||||
self.app.plotcanvas.vis_disconnect('mouse_press', doit)
|
self.app.plotcanvas.vis_disconnect('mouse_press', doit)
|
||||||
|
|
||||||
pos = self.app.plotcanvas.vispy_canvas.translate_coords(event.pos)
|
pos = self.app.plotcanvas.vispy_canvas.translate_coords(event.pos)
|
||||||
|
@ -841,10 +841,24 @@ class ToolPaint(FlatCAMTool, Gerber):
|
||||||
overlap=overlap,
|
overlap=overlap,
|
||||||
connect=connect,
|
connect=connect,
|
||||||
contour=contour)
|
contour=contour)
|
||||||
|
|
||||||
|
# to be called after second click on plot
|
||||||
|
def on_mouse_click_release(event):
|
||||||
self.app.plotcanvas.vis_connect('mouse_press', self.app.on_mouse_click_over_plot)
|
self.app.plotcanvas.vis_connect('mouse_press', self.app.on_mouse_click_over_plot)
|
||||||
|
self.app.plotcanvas.vis_connect('mouse_move', self.app.on_mouse_move_over_plot)
|
||||||
|
self.app.plotcanvas.vis_connect('mouse_release', self.app.on_mouse_click_release_over_plot)
|
||||||
|
|
||||||
|
# called on mouse move
|
||||||
|
def on_mouse_move(event):
|
||||||
|
pass
|
||||||
|
|
||||||
self.app.plotcanvas.vis_disconnect('mouse_press', self.app.on_mouse_click_over_plot)
|
self.app.plotcanvas.vis_disconnect('mouse_press', self.app.on_mouse_click_over_plot)
|
||||||
self.app.plotcanvas.vis_connect('mouse_press', doit)
|
self.app.plotcanvas.vis_disconnect('mouse_move', self.app.on_mouse_move_over_plot)
|
||||||
|
self.app.plotcanvas.vis_disconnect('mouse_release', self.app.on_mouse_click_release_over_plot)
|
||||||
|
|
||||||
|
self.app.plotcanvas.vis_connect('mouse_press', on_mouse_press)
|
||||||
|
self.app.plotcanvas.vis_connect('mouse_move', on_mouse_move)
|
||||||
|
self.app.plotcanvas.vis_connect('mouse_release', on_mouse_click_release)
|
||||||
|
|
||||||
def paint_poly(self, obj, inside_pt, tooldia, overlap, outname=None, connect=True, contour=True):
|
def paint_poly(self, obj, inside_pt, tooldia, overlap, outname=None, connect=True, contour=True):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -1396,6 +1396,10 @@ class SolderPaste(FlatCAMTool):
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
self.app.inform.emit(_("[WARNING_NOTCL] No such file or directory"))
|
self.app.inform.emit(_("[WARNING_NOTCL] No such file or directory"))
|
||||||
return
|
return
|
||||||
|
except PermissionError:
|
||||||
|
self.app.inform.emit(_("[WARNING] Permission denied, saving not possible.\n"
|
||||||
|
"Most likely another app is holding the file open and not accessible."))
|
||||||
|
return 'fail'
|
||||||
|
|
||||||
if self.app.defaults["global_open_style"] is False:
|
if self.app.defaults["global_open_style"] is False:
|
||||||
self.app.file_opened.emit("gcode", filename)
|
self.app.file_opened.emit("gcode", filename)
|
||||||
|
|
Loading…
Reference in New Issue