Exemple #1
0
 def run(self):
     if self.menuitem.callback is not None:
         self.threadstate = threadstate.OOFThreadState()
         threadmanager.threadManager.newWorker(self)
         try:
             self.initialize()
             try:
                 self.menuitem.precall()
                 self.menuitem.callback(self, *self.args, **self.kwargs)
                 # remove_excepthook is called here only if no
                 # exception occured.  If an exception occured,
                 # remove_excepthook can't be called until after
                 # the exception is handled.
                 excepthook.remove_excepthook(self.excepthook)
             except SystemExit:
                 raise
             # TODO 3.1: After conversion to SWIG 2.x, OOF
             # exceptions will probably be subclasses of Exception.
             except (Exception, ooferror.ErrErrorPtr), exception:
                 self.menuitem.postcall(False)
                 if propagate_exceptions or not self.toplevel:
                     self.exception_data = sys.exc_info()
                     sys.exc_clear()
                 else:
                     reporter.error(exception)
                     sys.excepthook(*sys.exc_info())
             else:  # no exception
                 self.menuitem.postcall(True)
Exemple #2
0
 def run(self):
     if self.error is None:
         self.lines = self.fileobj.readlines()
         nlines = len(self.lines)
         nblocks = len(self.blocks)
         self.blocks.append(nlines + 1)  # avoid special case for last block
         self.excepthook = excepthook.assign_excepthook(
             _ScriptExceptHook(self))
         # We can't use a try/finally here to restore an old excepthook
         # after we're done reading the file.  If an exception is
         # raised, the "finally" clause would run before the
         # excepthook.
         for blockno in range(nblocks):
             # line numbers start at 1, not 0
             blockstart = self.blocks[blockno] - 1
             blockend = self.blocks[blockno + 1] - 1
             source = ''.join(self.lines[blockstart:blockend])
             more = self.runsource(
                 source, encodeLocation(self.filename, blockstart))
             if more:
                 raise ooferror.ErrPyProgrammingError(
                     "Error reading script!")
             self.progress(blockend + 1, nlines)
             if self.stop() or self.error:
                 break
         excepthook.remove_excepthook(self.excepthook)
     self.done()
Exemple #3
0
 def start(self):
     if self.menuitem.callback is not None:
         try:
             self.initialize()
             try:
                 mainthread.runBlock(self.menuitem.precall)
                 mainthread.runBlock(self.menuitem.callback,
                                     (self, ) + self.args, self.kwargs)
                 # remove_excepthook is called here only if no
                 # exception occured.  If an exception occured,
                 # remove_excepthook can't be called until after
                 # the exception is handled.
                 excepthook.remove_excepthook(self.excepthook)
             except SystemExit:
                 raise
             # TODO 3.1: After conversion to SWIG 2.x, OOF
             # exceptions will probably be subclasses of Exception.
             except (Exception, ooferror.ErrErrorPtr), exception:
                 mainthread.runBlock(self.menuitem.postcall, (False, ))
                 if propagate_exceptions or not self.toplevel:
                     excepthook.remove_excepthook(self.excepthook)
                     raise
                 else:
                     reporter.error(exception)
                     sys.excepthook(*sys.exc_info())
             else:  # no exception
                 mainthread.runBlock(self.menuitem.postcall, (True, ))
Exemple #4
0
 def run(self):
     if self.menuitem.callback is not None:
         self.threadstate = threadstate.ThreadState()
         threadmanager.threadManager.newWorker(self)
         try:
             self.initialize()
             try:
                 self.menuitem.precall()
                 self.menuitem.callback(self, *self.args, **self.kwargs)
                 # remove_excepthook is called here only if no
                 # exception occured.  If an exception occured,
                 # remove_excepthook can't be called until after
                 # the exception is handled.
                 excepthook.remove_excepthook(self.excepthook)
             except SystemExit:
                 raise
             # TODO SWIG1.3: After conversion to SWIG 1.3, OOF
             # exceptions will probably be subclasses of Exception.
             except (Exception, ooferror.ErrErrorPtr), exception:
                 self.menuitem.postcall(False)
                 if propagate_exceptions or not self.toplevel:
                     self.exception_data = sys.exc_info()
                     sys.exc_clear()
                 else:
                     reporter.error(exception)
                     sys.excepthook(*sys.exc_info())
             else:           # no exception
                 self.menuitem.postcall(True)
Exemple #5
0
 def start(self):
     if self.menuitem.callback is not None:
         try:
             self.initialize()
             try:
                 mainthread.runBlock(self.menuitem.precall)
                 mainthread.runBlock(self.menuitem.callback,
                                     (self,)+self.args,
                                     self.kwargs)
                 # remove_excepthook is called here only if no
                 # exception occured.  If an exception occured,
                 # remove_excepthook can't be called until after
                 # the exception is handled.
                 excepthook.remove_excepthook(self.excepthook)
             except SystemExit:
                 raise
             # TODO SWIG1.3: After conversion to SWIG 1.3, OOF
             # exceptions will probably be subclasses of Exception.
             except (Exception, ooferror.ErrErrorPtr), exception:
                 mainthread.runBlock(self.menuitem.postcall, (False,))
                 if propagate_exceptions or not self.toplevel:
                     excepthook.remove_excepthook(self.excepthook)
                     raise
                 else:
                     reporter.error(exception)
                     sys.excepthook(*sys.exc_info())
             else:           # no exception
                 mainthread.runBlock(self.menuitem.postcall, (True,))
Exemple #6
0
 def run(self):
     miniThreadManager.add(self)
     try:
         try:
             self.threadstate = threadstate.ThreadState()
             #                 debug.fmsg("assigning excepthook, function=", self.function)
             hook = excepthook.assign_excepthook(excepthook.OOFexceptHook())
             self.function(*self.args, **self.kwargs)
             excepthook.remove_excepthook(hook)
         except StopThread:
             excepthook.remove_excepthook(hook)
             return
         # TODO SWIG1.3: After conversion to SWIG 1.3, OOF
         # exceptions will probably be subclasses of Exception.
         except (Exception, ooferror.ErrErrorPtr), exception:
             from ooflib.common.IO import reporter
             reporter.error(exception)
             sys.excepthook(*sys.exc_info())
     finally:
         miniThreadManager.remove(self)
         self.threadstate = None
Exemple #7
0
    def run(self):
        miniThreadManager.add(self)
        try:
            try:
                self.threadstate = threadstate.ThreadState()
#                 debug.fmsg("assigning excepthook, function=", self.function)
                hook = excepthook.assign_excepthook(excepthook.OOFexceptHook())
                self.function(*self.args, **self.kwargs)
                excepthook.remove_excepthook(hook)
            except StopThread:
                excepthook.remove_excepthook(hook)
                return
            # TODO SWIG1.3: After conversion to SWIG 1.3, OOF
            # exceptions will probably be subclasses of Exception.
            except (Exception, ooferror.ErrErrorPtr), exception:
                from ooflib.common.IO import reporter
                reporter.error(exception)
                sys.excepthook(*sys.exc_info())
        finally:
            miniThreadManager.remove(self)
            self.threadstate = None
Exemple #8
0
 def run(self):
     miniThreadManager.add(self)
     try:
         try:
             self.threadstate = threadstate.OOFThreadState()
             hook = excepthook.assign_excepthook(excepthook.OOFexceptHook())
             # debug.fmsg("Starting thread %s: %s" %
             #            (self.id(), self.function))
             self.function(*self.args, **self.kwargs)
             # debug.fmsg("Finished thread", self.id())
             excepthook.remove_excepthook(hook)
         except StopThread:
             excepthook.remove_excepthook(hook)
             return
         # TODO 3.1: After conversion to SWIG 2.x, if that ever
         # happens, OOF exceptions will probably be subclasses of
         # Exception.
         except (Exception, ooferror.ErrErrorPtr), exception:
             from ooflib.common.IO import reporter
             reporter.error(exception)
             sys.excepthook(*sys.exc_info())
     finally:
         miniThreadManager.remove(self)
         self.threadstate = None
Exemple #9
0
 def run(self):
     if self.error is None:
         self.lines = self.fileobj.readlines()
         nlines = len(self.lines)
         nblocks = len(self.blocks)
         self.blocks.append(nlines + 1)  # avoid special case for last block
         self.excepthook = excepthook.assign_excepthook(_ScriptExceptHook(self))
         # We can't use a try/finally here to restore an old excepthook
         # after we're done reading the file.  If an exception is
         # raised, the "finally" clause would run before the
         # excepthook.
         for blockno in range(nblocks):
             # line numbers start at 1, not 0
             blockstart = self.blocks[blockno] - 1
             blockend = self.blocks[blockno + 1] - 1
             source = "".join(self.lines[blockstart:blockend])
             more = self.runsource(source, encodeLocation(self.filename, blockstart))
             if more:
                 raise ooferror.ErrPyProgrammingError("Error reading script!")
             self.progress(blockend + 1, nlines)
             if self.stop() or self.error:
                 break
         excepthook.remove_excepthook(self.excepthook)
     self.done()
Exemple #10
0
 def __call__(self, e_type, e_value, tback):
     self.scriptloader.error = (e_type, e_value, fixTraceBack(tback))
     self.scriptloader.errhandler(*self.scriptloader.error)
     oldhook = excepthook.remove_excepthook(self)
Exemple #11
0
 def __call__(self, e_type, e_value, tback):
     self.scriptloader.error = (e_type, e_value, fixTraceBack(tback))
     self.scriptloader.errhandler(*self.scriptloader.error)
     oldhook = excepthook.remove_excepthook(self)