Commit adf8dbae2bd889dda0d3f0aeb41f32325fe310a2
1 parent
448294d7
Exists in
master
and in
6 other branches
ENH: Treated when file doesn't exist anymore fix #57
Showing
2 changed files
with
23 additions
and
12 deletions
Show diff stats
invesalius/control.py
... | ... | @@ -181,18 +181,18 @@ class Controller(): |
181 | 181 | def OnOpenRecentProject(self, pubsub_evt): |
182 | 182 | filepath = pubsub_evt.data |
183 | 183 | |
184 | - session = ses.Session() | |
185 | - st = session.project_status | |
186 | - if (st == const.PROJ_NEW) or (st == const.PROJ_CHANGE): | |
187 | - filename = session.project_path[1] | |
188 | - answer = dialog.SaveChangesDialog2(filename) | |
189 | - if answer: | |
190 | - self.ShowDialogSaveProject() | |
191 | - print "1" | |
192 | - self.CloseProject() | |
193 | - print "2" | |
194 | - self.OpenProject(filepath) | |
195 | - print "3" | |
184 | + if os.path.exists(filepath): | |
185 | + session = ses.Session() | |
186 | + st = session.project_status | |
187 | + if (st == const.PROJ_NEW) or (st == const.PROJ_CHANGE): | |
188 | + filename = session.project_path[1] | |
189 | + answer = dialog.SaveChangesDialog2(filename) | |
190 | + if answer: | |
191 | + self.ShowDialogSaveProject() | |
192 | + self.CloseProject() | |
193 | + self.OpenProject(filepath) | |
194 | + else: | |
195 | + dialog.InexistentPath(filepath) | |
196 | 196 | |
197 | 197 | |
198 | 198 | ... | ... |
invesalius/gui/dialogs.py
... | ... | @@ -302,6 +302,17 @@ def ImportInvalidFiles(): |
302 | 302 | dlg.ShowModal() |
303 | 303 | dlg.Destroy() |
304 | 304 | |
305 | +def InexistentPath(path): | |
306 | + msg = _("%s does not exist.")%(path) | |
307 | + if sys.platform == 'darwin': | |
308 | + dlg = wx.MessageDialog(None, "", msg, | |
309 | + wx.ICON_INFORMATION | wx.OK) | |
310 | + else: | |
311 | + dlg = wx.MessageDialog(None, msg, "InVesalius 3", | |
312 | + wx.ICON_INFORMATION | wx.OK) | |
313 | + dlg.ShowModal() | |
314 | + dlg.Destroy() | |
315 | + | |
305 | 316 | def SaveChangesDialog(filename): |
306 | 317 | current_dir = os.path.abspath(".") |
307 | 318 | msg = _("The project %s has been modified.\nSave changes?")%filename | ... | ... |