diff --git a/gui/Gui/Attackwindow.py b/gui/Gui/Attackwindow.py index fbbfbf6..f470170 100644 --- a/gui/Gui/Attackwindow.py +++ b/gui/Gui/Attackwindow.py @@ -30,6 +30,7 @@ import time """ Import scyther-gui components """ import Icon import Preference +import Error #--------------------------------------------------------------------------- if Preference.usePIL(): @@ -70,7 +71,11 @@ class AttackDisplay(wx.ScrolledWindow): self.original = wx.Image(filename,wx.BITMAP_TYPE_PNG) elif attack.filetype == "ps": # depends on PIL lib - self.original = Image.open(filename) + try: + self.original = Image.open(filename) + except: + Preference.doNotUsePIL() + raise Error.PILError else: print "Unknown file type %s." % (self.filetype) diff --git a/gui/Gui/Error.py b/gui/Gui/Error.py index 5b5f859..b7f0db6 100644 --- a/gui/Gui/Error.py +++ b/gui/Gui/Error.py @@ -31,10 +31,21 @@ import sys #--------------------------------------------------------------------------- -def ShowAndExit(text): +class PILError (Exception): + pass + +class NoAttackError(Exception): + pass + +#--------------------------------------------------------------------------- + +def ShowAndReturn(text): title = "Error" dlg = wx.MessageDialog(None, text, title, wx.ID_OK | wx.ICON_ERROR) result = dlg.ShowModal() dlg.Destroy() + +def ShowAndExit(text): + ShowAndReturn(text) sys.exit() diff --git a/gui/Gui/Preference.py b/gui/Gui/Preference.py index da0f909..daede86 100644 --- a/gui/Gui/Preference.py +++ b/gui/Gui/Preference.py @@ -55,7 +55,7 @@ from time import localtime,strftime """ Globals """ # Do we have the Python Imaging library? havePIL = True -havePIL = False # For now, override (bounding box bug on Feisty?) +#havePIL = False # For now, override (bounding box bug on Feisty?) try: import Image except ImportError: @@ -80,6 +80,14 @@ def usePIL(): return False +def doNotUsePIL(): + """ + Disable + """ + global havePIL + + havePIL = False + #--------------------------------------------------------------------------- class Preferences(dict): diff --git a/gui/Gui/Scytherthread.py b/gui/Gui/Scytherthread.py index b95af8f..0ba4d90 100644 --- a/gui/Gui/Scytherthread.py +++ b/gui/Gui/Scytherthread.py @@ -357,8 +357,12 @@ class ResultWindow(wx.Frame): def onViewButton(self,evt): btn = evt.GetEventObject() - w = Attackwindow.AttackWindow(btn.claim) - w.Show(True) + try: + w = Attackwindow.AttackWindow(btn.claim) + w.Show(True) + except Error.PILError: + Error.ShowAndReturn("Problem with PIL imaging library: disabled zooming. Please retry to verify the protocol again.") + self.onCloseWindow(None) def onCloseWindow(self,evt): """ TODO we should kill self.thread """