Commit b6838c1ce1c07a7377ae704d15122fb7bbe16298
1 parent
0aebaad3
Exists in
master
Showing error message when trying to export surface inside a folder without write permission
Showing
1 changed file
with
16 additions
and
1 deletions
Show diff stats
invesalius/data/surface.py
... | ... | @@ -902,7 +902,22 @@ class SurfaceManager(): |
902 | 902 | wx.MessageBox(_("It was not possible to export the surface because the surface is empty"), _("Export surface error")) |
903 | 903 | return |
904 | 904 | |
905 | - shutil.move(temp_file, filename) | |
905 | + try: | |
906 | + shutil.move(temp_file, filename) | |
907 | + except PermissionError as err: | |
908 | + dirpath = os.path.split(filename)[0] | |
909 | + if wx.GetApp() is None: | |
910 | + print(_("It was not possible to export the surface because you don't have permission to write to {} folder: {}".format(dirpath, err))) | |
911 | + else: | |
912 | + dlg = dialogs.ErrorMessageBox( | |
913 | + None, | |
914 | + _("Export surface error"), | |
915 | + "It was not possible to export the surface because you don't have permission to write to {}:\n{}".format(dirpath, err) | |
916 | + ) | |
917 | + dlg.ShowModal() | |
918 | + dlg.Destroy() | |
919 | + os.remove(temp_file) | |
920 | + | |
906 | 921 | |
907 | 922 | def _export_surface(self, filename, filetype): |
908 | 923 | if filetype in (const.FILETYPE_STL, | ... | ... |