Esempio n. 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)
Esempio n. 2
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)
Esempio n. 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, ))
Esempio n. 4
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,))
Esempio n. 5
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
Esempio n. 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
Esempio n. 7
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
Esempio n. 8
0
def printTraceBack(e_type, e_value, tblist):
    from ooflib.common.IO import reporter  # avoid import loop
    for line in traceback.format_exception_only(e_type, e_value):
        reporter.error(line.rstrip())
    if isinstance(e_value, ooferror.ErrErrorPtr):
        moreinfo = e_value.details()
        if moreinfo:
            reporter.error(moreinfo)
    if tblist:
        for line in traceback.format_list(tblist):
            reporter.error(line.rstrip())
Esempio n. 9
0
def printTraceBack(e_type, e_value, tblist):
    from ooflib.common.IO import reporter # avoid import loop
    for line in traceback.format_exception_only(e_type, e_value):
        reporter.error(line.rstrip())
    if isinstance(e_value, ooferror.ErrErrorPtr):
        moreinfo = e_value.details()
        if moreinfo:
            reporter.error(moreinfo)
    if tblist:
        for line in traceback.format_list(tblist):
            reporter.error(line.rstrip())