SourceForge: deskframe/deskframe: changeset 5:51f02f4367ff
now deals with corrupt files
authorShai Ayal <shaiay@users.sourceforge.net>
Thu Sep 24 22:54:44 2009 +0300 (2 months ago)
changeset 551f02f4367ff
parent 40e2c84627502
child 660cd2361b2fd
now deals with corrupt files
main.py
     1.1 --- a/main.py	Thu Sep 24 22:04:55 2009 +0300
     1.2 +++ b/main.py	Thu Sep 24 22:54:44 2009 +0300
     1.3 @@ -203,8 +203,16 @@
     1.4              self.image_list.add_root(dd)
     1.5  
     1.6      def image(self,fname) :
     1.7 -        self.im = wx.Image(fname)
     1.8 -        self.EXIF = EXIF.process_file(file(fname))
     1.9 +        if wx.Image_CanRead(fname) :
    1.10 +            self.im = wx.Image(fname)
    1.11 +            try :
    1.12 +                self.EXIF = EXIF.process_file(file(fname))
    1.13 +            except :
    1.14 +                self.EXIF = {}
    1.15 +        else :
    1.16 +            ## very non elegant -- using someone elses exception class
    1.17 +            ## because we are lazy to define our own
    1.18 +            raise KeyError
    1.19  
    1.20      def ReadDirList(self) :
    1.21          try :
    1.22 @@ -216,7 +224,14 @@
    1.23          self.config.Write('dir_list',':'.join(dir_list))
    1.24  
    1.25      def OnTimer(self,event):
    1.26 -        self.image(self.image_list.get_file(self.image_idx))
    1.27 +        self.timer.Stop()
    1.28 +        try :
    1.29 +            self.image(self.image_list.get_file(self.image_idx))
    1.30 +            self.timer.Start(1000)
    1.31 +        except :
    1.32 +            ## bad image -- skip right to the next one
    1.33 +            self.timer.Start(10)
    1.34 +
    1.35          self.image_idx += 1
    1.36          self.Refresh()
    1.37          return