Exemple #1
0
 def get_report(self, e, tb=None):
     e, tb = self.get_exception(e, tb)
     s = ''.join(traceback.format_exception(type(e), e, tb))
     with captured_output("stderr") as sio:
         traceback.print_exception(type(e), e, tb)
     self.assertEqual(sio.getvalue(), s)
     return s
 def get_report(self, e, tb=None):
     e, tb = self.get_exception(e, tb)
     s = ''.join(
         traceback.format_exception(type(e), e, tb))
     with captured_output("stderr") as sio:
         traceback.print_exception(type(e), e, tb)
     self.assertEqual(sio.getvalue(), s)
     return s
Exemple #3
0
def LogException(extraText='',
                 channel='general',
                 toConsole=1,
                 toLogServer=1,
                 toAlertSvc=None,
                 toMsgWindow=1,
                 exctype=None,
                 exc=None,
                 tb=None,
                 severity=None,
                 show_locals=1):
    """Log an exception to the log server. this code prevents recursion so a exception in the exception processing wont crash."""
    global logExceptionLevel
    if logExceptionLevel > 0:
        return
    _tmpctx = blue.pyos.taskletTimer.EnterTasklet('Logging::LogException')
    logExceptionLevel += 1
    if not exctype:
        exctype, exc, tb = sys.exc_info()
    try:
        try:
            _LogException((exctype, exc, tb), extraText, channel, toConsole,
                          toLogServer, toAlertSvc, toMsgWindow, severity,
                          show_locals)
            return
        except Exception:
            try:
                traceback2.print_exc(show_locals=3)
                stream = LogChannelStream(GetChannel('general'))
                traceback2.print_exc(show_locals=3, file=stream)
                stream.close()
            except Exception:
                pass

        try:
            traceback2.print_exception(exctype,
                                       exc,
                                       tb,
                                       file=sys.stdout,
                                       show_locals=show_locals)
            stream = LogChannelStream(GetChannel(channel), ERR)
            print >> stream, 'retrying traceback log, got an error in _LogException'
            traceback2.print_exception(exctype,
                                       exc,
                                       tb,
                                       file=stream,
                                       show_locals=show_locals)
            stream.close()
        except Exception:
            try:
                traceback2.print_exc(show_locals=3)
            except:
                pass

    finally:
        del tb
        logExceptionLevel -= 1
        blue.pyos.taskletTimer.ReturnFromTasklet(_tmpctx)
def LogException(extraText = '', channel = 'general', toConsole = 1, toLogServer = 1, toAlertSvc = None, toMsgWindow = 1, exctype = None, exc = None, tb = None, severity = None, show_locals = 1):
    global logExceptionLevel
    if logExceptionLevel > 0:
        return
    _tmpctx = blue.pyos.taskletTimer.EnterTasklet('logmodule::LogException')
    logExceptionLevel += 1
    if not exctype:
        exctype, exc, tb = sys.exc_info()
    try:
        try:
            _LogException((exctype, exc, tb), extraText, channel, toConsole, toLogServer, toAlertSvc, toMsgWindow, severity, show_locals)
            return
        except Exception:
            try:
                traceback2.print_exc(show_locals=3)
                stream = LogChannelStream(GetChannel('general'))
                traceback2.print_exc(show_locals=3, file=stream)
                stream.close()
            except Exception:
                pass

        try:
            traceback2.print_exception(exctype, exc, tb, file=sys.stdout, show_locals=show_locals)
            stream = LogChannelStream(GetChannel(channel), ERR)
            print >> stream, 'retrying traceback log, got an error in _LogException'
            traceback2.print_exception(exctype, exc, tb, file=stream, show_locals=show_locals)
            stream.close()
        except Exception:
            try:
                traceback2.print_exc(show_locals=3)
            except:
                pass

    finally:
        del tb
        logExceptionLevel -= 1
        blue.pyos.taskletTimer.ReturnFromTasklet(_tmpctx)
Exemple #5
0
        print('File not found {}. Skipping it.'.format(nixFile))
        continue
    print('Processing ' + expName)
    try:
        see = RawDataProcessor(expName=expName,
                               dirpath=NIXPath,
                               askShouldReprocess=False)
        see.detectSpikes()
        see.downSampleVibSignal()
        see.getStimulusEpochs(5 * qu.ms)
        see.extractResponse()
        see.sortSegments()
        see.write2nixFile()
        see.close()
        resultsDF = resultsDF.append({
            "Experiment ID": expName,
            "Result": True
        },
                                     ignore_index=True)
    except Exception as exep:
        exc_type, exc_value, exc_traceback = sys.exc_info()
        print_exception(type(exep), str(exep), exc_traceback, file=sys.stdout)
        resultsDF = resultsDF.append(
            {
                "Experiment ID": expName,
                "Result": False
            }, ignore_index=True)

resultsDF.set_index("Experiment ID", inplace=True)
resultsDF.to_excel(processedResultsFile)