From 73f7e432277a3c4999e1668fda1eb5516cbf7b00 Mon Sep 17 00:00:00 2001 From: jbernardis Date: Sat, 7 Feb 2015 23:38:12 -0500 Subject: [PATCH] Configtool: enforce correct configuration file names. Previously one could save a board or printer configuration with a name which wouldn't allow to load it again. --- configtool/boardpanel.py | 8 ++++++++ configtool/printerpanel.py | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/configtool/boardpanel.py b/configtool/boardpanel.py index 26a1148..67971cf 100644 --- a/configtool/boardpanel.py +++ b/configtool/boardpanel.py @@ -422,6 +422,14 @@ class BoardPanel(wx.Panel): dlg.Destroy() return False + if not os.path.basename(path).startswith("board."): + dlg = wx.MessageDialog(self, "Illegal file name: %s.\n" + "File name must begin with \"board.\"" % path, + "Illegal file name", wx.OK + wx.ICON_ERROR) + dlg.ShowModal() + dlg.Destroy() + return False + ext = os.path.splitext(os.path.basename(path))[1] self.dir = os.path.dirname(path) diff --git a/configtool/printerpanel.py b/configtool/printerpanel.py index 423308c..0c6e4db 100644 --- a/configtool/printerpanel.py +++ b/configtool/printerpanel.py @@ -301,6 +301,14 @@ class PrinterPanel(wx.Panel): dlg.Destroy() return False + if not os.path.basename(path).startswith("printer."): + dlg = wx.MessageDialog(self, "Illegal file name: %s.\n" + "File name must begin with \"printer.\"" % path, + "Illegal file name", wx.OK + wx.ICON_ERROR) + dlg.ShowModal() + dlg.Destroy() + return False + ext = os.path.splitext(os.path.basename(path))[1] self.dir = os.path.dirname(path)