コード例 #1
0
ファイル: reporter.py プロジェクト: mcenirm/vbox
def testFailureXcpt(sDetails = ''):
    """
    Reports a failure with exception.
    We count these calls and testDone will use them to report PASSED or FAILED.

    Returns False so that a return False line can be saved.
    """
    # Extract exception info.
    try:
        oType, oValue, oTraceback  = sys.exc_info();
    except:
        oType = oValue, oTraceback = None;
    if oType is not None:
        sCaller = utils.getCallerName(oTraceback.tb_frame);
        sXcpt   = ' '.join(traceback.format_exception_only(oType, oValue));
    else:
        sCaller = utils.getCallerName();
        sXcpt   = 'No exception at %s' % (sCaller,);

    # Use testFailure to do the work.
    g_oLock.acquire();
    if sDetails == '':
        g_oReporter.testFailure('Exception: %s' % (sXcpt,), sCaller);
    else:
        g_oReporter.testFailure('%s: %s' % (sDetails, sXcpt), sCaller);
    g_oLock.release();
    return False;
コード例 #2
0
ファイル: reporter.py プロジェクト: susanych1234/virtualbox
def testFailureXcpt(sDetails=''):
    """
    Reports a failure with exception.
    We count these calls and testDone will use them to report PASSED or FAILED.

    Returns False so that a return False line can be saved.
    """
    # Extract exception info.
    try:
        oType, oValue, oTraceback = sys.exc_info()
    except:
        oType = oValue, oTraceback = None
    if oType is not None:
        sCaller = utils.getCallerName(oTraceback.tb_frame)
        sXcpt = ' '.join(traceback.format_exception_only(oType, oValue))
    else:
        sCaller = utils.getCallerName()
        sXcpt = 'No exception at %s' % (sCaller, )

    # Use testFailure to do the work.
    g_oLock.acquire()
    if sDetails == '':
        g_oReporter.testFailure('Exception: %s' % (sXcpt, ), sCaller)
    else:
        g_oReporter.testFailure('%s: %s' % (sDetails, sXcpt), sCaller)
    g_oLock.release()
    return False
コード例 #3
0
ファイル: reporter.py プロジェクト: mcenirm/vbox
def logXcptWorker(iLevel, fIncErrors, sPrefix="", sText=None, cFrames=1):
    """
    Log an exception, optionally with a preceeding message and more than one
    call frame.
    """
    g_oLock.acquire();
    if fIncErrors:
        g_oReporter.testIncErrors();

    ## @todo skip all this if iLevel is too high!

    # Try get exception info.
    sTsPrf = utils.getTimePrefix();
    try:
        oType, oValue, oTraceback = sys.exc_info();
    except:
        oType = oValue = oTraceback = None;
    if oType is not None:

        # Try format the info
        try:
            rc      = 0;
            sCaller = utils.getCallerName(oTraceback.tb_frame);
            if sText is not None:
                rc = g_oReporter.log(iLevel, "%s%s" % (sPrefix, sText), sCaller, sTsPrf);
            asInfo = [];
            try:
                asInfo = asInfo + traceback.format_exception_only(oType, oValue);
                if cFrames is not None and cFrames <= 1:
                    asInfo = asInfo + traceback.format_tb(oTraceback, 1);
                else:
                    asInfo.append('Traceback:')
                    asInfo = asInfo + traceback.format_tb(oTraceback, cFrames);
                    asInfo.append('Stack:')
                    asInfo = asInfo + traceback.format_stack(oTraceback.tb_frame.f_back, cFrames);
            except:
                g_oReporter.log(0, 'internal-error: Hit exception #2! %s' % (traceback.format_exc()), sCaller, sTsPrf);

            if len(asInfo) > 0:
                # Do the logging.
                for sItem in asInfo:
                    asLines = sItem.splitlines();
                    for sLine in asLines:
                        rc = g_oReporter.log(iLevel, '%s%s' % (sPrefix, sLine), sCaller, sTsPrf);

            else:
                g_oReporter.log(iLevel, 'No exception info...', sCaller, sTsPrf);
                rc = -3;
        except:
            g_oReporter.log(0, 'internal-error: Hit exception! %s' % (traceback.format_exc()), None, sTsPrf);
            rc = -2;
    else:
        g_oReporter.log(0, 'internal-error: No exception! %s'
                      % (utils.getCallerName(iFrame=3)), utils.getCallerName(iFrame=3), sTsPrf);
        rc = -1;

    g_oLock.release();
    return rc;
コード例 #4
0
def _logXcptWorker(fnLogger, sPrefix = '', sText = None, cFrames = 1, fnLogger1 = log):
    """
    Log an exception, optionally with a preceeding message and more than one
    call frame.
    """
    ## @todo skip all this if iLevel is too high!

    # Try get exception info.
    sTsPrf = utils.getTimePrefix();
    try:
        oType, oValue, oTraceback = sys.exc_info();
    except:
        oType = oValue = oTraceback = None;
    if oType is not None:

        # Try format the info
        try:
            rc      = 0;
            sCaller = utils.getCallerName(oTraceback.tb_frame);
            if sText is not None:
                rc = fnLogger('%s%s' % (sPrefix, sText), sCaller, sTsPrf);
            asInfo = [];
            try:
                asInfo = asInfo + traceback.format_exception_only(oType, oValue);
                if cFrames is not None and cFrames <= 1:
                    asInfo = asInfo + traceback.format_tb(oTraceback, 1);
                else:
                    asInfo.append('Traceback:')
                    asInfo = asInfo + traceback.format_tb(oTraceback, cFrames);
                    asInfo.append('Stack:')
                    asInfo = asInfo + traceback.format_stack(oTraceback.tb_frame.f_back, cFrames);
            except:
                fnLogger1('internal-error: Hit exception #2! %s' % (traceback.format_exc()), sCaller, sTsPrf);

            if len(asInfo) > 0:
                # Do the logging.
                for sItem in asInfo:
                    asLines = sItem.splitlines();
                    for sLine in asLines:
                        rc = fnLogger('%s%s' % (sPrefix, sLine), sCaller, sTsPrf);

            else:
                fnLogger('No exception info...', sCaller, sTsPrf);
                rc = -3;
        except:
            fnLogger1('internal-error: Hit exception! %s' % (traceback.format_exc()), None, sTsPrf);
            rc = -2;
    else:
        fnLogger1('internal-error: No exception! %s' % (utils.getCallerName(iFrame=3)), utils.getCallerName(iFrame=3), sTsPrf);
        rc = -1;

    return rc;
コード例 #5
0
ファイル: reporter.py プロジェクト: susanych1234/virtualbox
def logAllStacks(cFrames=None):
    """
    Logs the stacks of all python threads.
    """
    sTsPrf = utils.getTimePrefix()
    sCaller = utils.getCallerName()
    g_oLock.acquire()

    cThread = 0
    for idThread, oStack in sys._current_frames().items():  # >=2.5, a bit ugly - pylint: disable=W0212
        try:
            if cThread > 0:
                g_oReporter.log(1, '', sCaller, sTsPrf)
            g_oReporter.log(1, 'Thread %s (%#x)' % (idThread, idThread),
                            sCaller, sTsPrf)
            try:
                asInfo = traceback.format_stack(oStack, cFrames)
            except:
                g_oReporter.log(1, '  Stack formatting failed w/ exception',
                                sCaller, sTsPrf)
            else:
                for sInfo in asInfo:
                    asLines = sInfo.splitlines()
                    for sLine in asLines:
                        g_oReporter.log(1, sLine, sCaller, sTsPrf)
        except:
            pass
        cThread += 1

    g_oLock.release()
    return None
コード例 #6
0
ファイル: reporter.py プロジェクト: susanych1234/virtualbox
def addLogFile(sFilename, sKind, sDescription='', sAltName=None):
    """
    Adds the specified log file to the report if the file exists.

    The sDescription is a free form description of the log file.

    The sKind parameter is for adding some machine parsable hint what kind of
    log file this really is.

    Returns True on success, False on failure (no ENOENT errors are logged).
    """
    sTsPrf = utils.getTimePrefix()
    sCaller = utils.getCallerName()
    fRc = False
    if sAltName is None:
        sAltName = sFilename

    try:
        oSrcFile = utils.openNoInherit(sFilename, 'rb')
    except IOError, oXcpt:
        if oXcpt.errno != errno.ENOENT:
            logXcpt('addLogFile(%s,%s,%s)' % (sFilename, sDescription, sKind))
        else:
            logXcpt('addLogFile(%s,%s,%s) IOError' %
                    (sFilename, sDescription, sKind))
コード例 #7
0
ファイル: reporter.py プロジェクト: mcenirm/vbox
def logAllStacks(cFrames = None):
    """
    Logs the stacks of all python threads.
    """
    sTsPrf  = utils.getTimePrefix();
    sCaller = utils.getCallerName();
    g_oLock.acquire();

    cThread = 0;
    for idThread, oStack in sys._current_frames().items(): # >=2.5, a bit ugly - pylint: disable=W0212
        try:
            if cThread > 0:
                g_oReporter.log(1, '', sCaller, sTsPrf);
            g_oReporter.log(1, 'Thread %s (%#x)' % (idThread, idThread), sCaller, sTsPrf);
            try:
                asInfo = traceback.format_stack(oStack, cFrames);
            except:
                g_oReporter.log(1, '  Stack formatting failed w/ exception', sCaller, sTsPrf);
            else:
                for sInfo in asInfo:
                    asLines = sInfo.splitlines();
                    for sLine in asLines:
                        g_oReporter.log(1, sLine, sCaller, sTsPrf);
        except:
            pass;
        cThread += 1;

    g_oLock.release();
    return None;
コード例 #8
0
ファイル: reporter.py プロジェクト: susanych1234/virtualbox
def testStart(sName):
    """
    Starts a new test (pushes it).
    """
    g_oLock.acquire()
    rc = g_oReporter.testStart(sName, utils.getCallerName())
    g_oLock.release()
    return rc
コード例 #9
0
ファイル: db.py プロジェクト: hygonsoc/virtualbox
    def execute(self, sOperation, aoArgs = None):
        """
        Execute a query or command.

        Mostly a wrapper around the psycopg2 cursor method with the same name,
        but collect data for traceback.
        """
        return self.executeInternal(self._oCursor, sOperation, aoArgs, utils.getCallerName());
コード例 #10
0
ファイル: reporter.py プロジェクト: mcenirm/vbox
def testValue(sName, sValue, sUnit):
    """
    Reports a benchmark value or something simiarlly useful.
    """
    g_oLock.acquire();
    rc = g_oReporter.testValue(sName, str(sValue), sUnit, utils.getCallerName());
    g_oLock.release();
    return rc;
コード例 #11
0
ファイル: db.py プロジェクト: miguelinux/vbox
    def callProc(self, sProcedure, aoArgs = None):
        """
        Call a stored procedure.

        Mostly a wrapper around the psycopg2 cursor method 'callproc', but
        collect data for traceback.
        """
        return self.callProcInternal(self._oCursor, sProcedure, aoArgs, utils.getCallerName());
コード例 #12
0
ファイル: db.py プロジェクト: hygonsoc/virtualbox
    def callProc(self, sProcedure, aoArgs = None):
        """
        Call a stored procedure.

        Mostly a wrapper around the psycopg2 cursor method 'callproc', but
        collect data for traceback.
        """
        return self.callProcInternal(self._oCursor, sProcedure, aoArgs, utils.getCallerName());
コード例 #13
0
ファイル: db.py プロジェクト: miguelinux/vbox
    def execute(self, sOperation, aoArgs = None):
        """
        Execute a query or command.

        Mostly a wrapper around the psycopg2 cursor method with the same name,
        but collect data for traceback.
        """
        return self.executeInternal(self._oCursor, sOperation, aoArgs, utils.getCallerName());
コード例 #14
0
ファイル: reporter.py プロジェクト: mcenirm/vbox
def testStart(sName):
    """
    Starts a new test (pushes it).
    """
    g_oLock.acquire();
    rc = g_oReporter.testStart(sName, utils.getCallerName());
    g_oLock.release();
    return rc;
コード例 #15
0
ファイル: db.py プロジェクト: hygonsoc/virtualbox
    def rollback(self):
        """ Wrapper around Psycopg2.connection.rollback."""
        nsStart = utils.timestampNano();
        oRc = self._oConn.rollback();
        cNsElapsed = utils.timestampNano() - nsStart;

        self._aoTraceBack.append([nsStart, 'ROLLBACK', cNsElapsed, 0, utils.getCallerName(), None]);
        self._endedTransaction();
        return oRc;
コード例 #16
0
ファイル: db.py プロジェクト: hygonsoc/virtualbox
 def begin(self):
     """
     Currently just for marking where a transaction starts in the code.
     """
     assert self._oConn is not None;
     assert self.isAutoCommitting() is False;
     self._aoTraceBack.append([utils.timestampNano(), 'START TRANSACTION', 0, 0, utils.getCallerName(), None]);
     self._startedTransaction();
     return True;
コード例 #17
0
ファイル: reporter.py プロジェクト: susanych1234/virtualbox
def testValue(sName, sValue, sUnit):
    """
    Reports a benchmark value or something simiarlly useful.
    """
    g_oLock.acquire()
    rc = g_oReporter.testValue(sName, str(sValue), sUnit,
                               utils.getCallerName())
    g_oLock.release()
    return rc
コード例 #18
0
ファイル: db.py プロジェクト: flamenca/virtualbox
 def maybeCommit(self, fCommit):
     """
     Commits if fCommit is True.
     Returns True if committed, False if not.
     """
     if fCommit is True:
         self.commit(utils.getCallerName())
         return True
     return False
コード例 #19
0
ファイル: db.py プロジェクト: miguelinux/vbox
 def begin(self):
     """
     Currently just for marking where a transaction starts in the code.
     """
     assert self._oConn is not None;
     assert self.isAutoCommitting() is False;
     self._aoTraceBack.append([utils.timestampNano(), 'START TRANSACTION', 0, 0, utils.getCallerName(), None]);
     self._startedTransaction();
     return True;
コード例 #20
0
ファイル: db.py プロジェクト: miguelinux/vbox
 def maybeCommit(self, fCommit):
     """
     Commits if fCommit is True.
     Returns True if committed, False if not.
     """
     if fCommit is True:
         self.commit(utils.getCallerName());
         return True;
     return False;
コード例 #21
0
ファイル: db.py プロジェクト: miguelinux/vbox
    def rollback(self):
        """ Wrapper around Psycopg2.connection.rollback."""
        nsStart = utils.timestampNano();
        oRc = self._oConn.rollback();
        cNsElapsed = utils.timestampNano() - nsStart;

        self._aoTraceBack.append([nsStart, 'ROLLBACK', cNsElapsed, 0, utils.getCallerName(), None]);
        self._endedTransaction();
        return oRc;
コード例 #22
0
ファイル: reporter.py プロジェクト: mcenirm/vbox
def log2(sText):
    """Log level 2: Writes the specfied text to the log."""
    g_oLock.acquire();
    try:
        rc = g_oReporter.log(2, sText, utils.getCallerName(), utils.getTimePrefix());
    except:
        rc = -1;
    g_oLock.release();
    return rc;
コード例 #23
0
ファイル: reporter.py プロジェクト: mcenirm/vbox
def testDone(fSkipped = False):
    """
    Completes the current test (pops it), logging PASSED / FAILURE.

    Returns a tuple with the name of the test and its error count.
    """
    g_oLock.acquire();
    rc = g_oReporter.testDone(fSkipped, utils.getCallerName());
    g_oLock.release();
    return rc;
コード例 #24
0
ファイル: reporter.py プロジェクト: susanych1234/virtualbox
def testDone(fSkipped=False):
    """
    Completes the current test (pops it), logging PASSED / FAILURE.

    Returns a tuple with the name of the test and its error count.
    """
    g_oLock.acquire()
    rc = g_oReporter.testDone(fSkipped, utils.getCallerName())
    g_oLock.release()
    return rc
コード例 #25
0
ファイル: reporter.py プロジェクト: susanych1234/virtualbox
def log2(sText):
    """Log level 2: Writes the specfied text to the log."""
    g_oLock.acquire()
    try:
        rc = g_oReporter.log(2, sText, utils.getCallerName(),
                             utils.getTimePrefix())
    except:
        rc = -1
    g_oLock.release()
    return rc
コード例 #26
0
ファイル: reporter.py プロジェクト: susanych1234/virtualbox
def testFailure(sDetails):
    """
    Reports a failure.
    We count these calls and testDone will use them to report PASSED or FAILED.

    Returns False so that a return False line can be saved.
    """
    g_oLock.acquire()
    g_oReporter.testFailure(sDetails, utils.getCallerName())
    g_oLock.release()
    return False
コード例 #27
0
ファイル: reporter.py プロジェクト: mcenirm/vbox
def testCleanup():
    """
    Closes all open tests with a generic error condition.

    Returns True if no open tests, False if something had to be closed with failure.
    """
    g_oLock.acquire();
    fRc = g_oReporter.testCleanup(utils.getCallerName());
    g_oReporter.xmlFlush(fRetry = False, fForce = True);
    g_oLock.release();
    return fRc;
コード例 #28
0
ファイル: reporter.py プロジェクト: mcenirm/vbox
def testFailure(sDetails):
    """
    Reports a failure.
    We count these calls and testDone will use them to report PASSED or FAILED.

    Returns False so that a return False line can be saved.
    """
    g_oLock.acquire();
    g_oReporter.testFailure(sDetails, utils.getCallerName());
    g_oLock.release();
    return False;
コード例 #29
0
ファイル: reporter.py プロジェクト: susanych1234/virtualbox
def testCleanup():
    """
    Closes all open tests with a generic error condition.

    Returns True if no open tests, False if something had to be closed with failure.
    """
    g_oLock.acquire()
    fRc = g_oReporter.testCleanup(utils.getCallerName())
    g_oReporter.xmlFlush(fRetry=False, fForce=True)
    g_oLock.release()
    return fRc
コード例 #30
0
ファイル: db.py プロジェクト: hygonsoc/virtualbox
    def commit(self, sCallerName = None):
        """ Wrapper around Psycopg2.connection.commit."""
        assert self._fTransaction is True;

        nsStart = utils.timestampNano();
        oRc = self._oConn.commit();
        cNsElapsed = utils.timestampNano() - nsStart;

        if sCallerName is None:
            sCallerName = utils.getCallerName();
        self._aoTraceBack.append([nsStart, 'COMMIT', cNsElapsed, 0, sCallerName, None]);
        self._endedTransaction();
        return oRc;
コード例 #31
0
ファイル: db.py プロジェクト: miguelinux/vbox
    def commit(self, sCallerName = None):
        """ Wrapper around Psycopg2.connection.commit."""
        assert self._fTransaction is True;

        nsStart = utils.timestampNano();
        oRc = self._oConn.commit();
        cNsElapsed = utils.timestampNano() - nsStart;

        if sCallerName is None:
            sCallerName = utils.getCallerName();
        self._aoTraceBack.append([nsStart, 'COMMIT', cNsElapsed, 0, sCallerName, None]);
        self._endedTransaction();
        return oRc;
コード例 #32
0
ファイル: reporter.py プロジェクト: mcenirm/vbox
def fatal(sText):
    """
    Writes a fatal error to the log.

    This will add an error to the current test.

    Always returns False for the convenience of methods returning boolean
    success indicators.
    """
    g_oLock.acquire();
    g_oReporter.testIncErrors();
    try:
        g_oReporter.log(0, 'fatal error: %s' % (sText), utils.getCallerName(), utils.getTimePrefix());
    except:
        pass
    g_oLock.release();
    return False;
コード例 #33
0
ファイル: reporter.py プロジェクト: mcenirm/vbox
def errorTimeout(sText):
    """
    Flags the current test as having timed out and writes the specified message to the log.

    This will add an error to the current test.

    Always returns False for the convenience of methods returning boolean
    success indicators.
    """
    g_oLock.acquire();
    g_oReporter.testSetTimedOut();
    try:
        g_oReporter.log(0, 'timeout-error: %s' % (sText), utils.getCallerName(), utils.getTimePrefix());
    except:
        pass;
    g_oLock.release();
    return False;
コード例 #34
0
ファイル: reporter.py プロジェクト: mcenirm/vbox
 def write(self, sText):
     """file.write"""
     if isinstance(sText, array.array):
         try:
             sText = sText.tostring();
         except:
             pass;
     g_oLock.acquire();
     try:
         sTsPrf  = utils.getTimePrefix();
         sCaller = utils.getCallerName();
         asLines = sText.splitlines();
         for sLine in asLines:
             g_oReporter.log(0, '%s: %s' % (self.sPrefix, sLine), sCaller, sTsPrf);
     except:
         traceback.print_exc();
     g_oLock.release();
     return None;
コード例 #35
0
ファイル: reporter.py プロジェクト: susanych1234/virtualbox
def errorTimeout(sText):
    """
    Flags the current test as having timed out and writes the specified message to the log.

    This will add an error to the current test.

    Always returns False for the convenience of methods returning boolean
    success indicators.
    """
    g_oLock.acquire()
    g_oReporter.testSetTimedOut()
    try:
        g_oReporter.log(0, 'timeout-error: %s' % (sText),
                        utils.getCallerName(), utils.getTimePrefix())
    except:
        pass
    g_oLock.release()
    return False
コード例 #36
0
ファイル: reporter.py プロジェクト: susanych1234/virtualbox
def fatal(sText):
    """
    Writes a fatal error to the log.

    This will add an error to the current test.

    Always returns False for the convenience of methods returning boolean
    success indicators.
    """
    g_oLock.acquire()
    g_oReporter.testIncErrors()
    try:
        g_oReporter.log(0, 'fatal error: %s' % (sText), utils.getCallerName(),
                        utils.getTimePrefix())
    except:
        pass
    g_oLock.release()
    return False
コード例 #37
0
ファイル: reporter.py プロジェクト: susanych1234/virtualbox
 def write(self, sText):
     """file.write"""
     if isinstance(sText, array.array):
         try:
             sText = sText.tostring()
         except:
             pass
     g_oLock.acquire()
     try:
         sTsPrf = utils.getTimePrefix()
         sCaller = utils.getCallerName()
         asLines = sText.splitlines()
         for sLine in asLines:
             g_oReporter.log(0, '%s: %s' % (self.sPrefix, sLine), sCaller,
                             sTsPrf)
     except:
         traceback.print_exc()
     g_oLock.release()
     return None
コード例 #38
0
ファイル: reporter.py プロジェクト: mcenirm/vbox
    def write(self, sText):
        """file.write"""
        # lazy start.
        if self.fStarted is not True:
            try:
                g_oReporter.subXmlStart(self);
            except:
                traceback.print_exc();
            self.fStarted = True;

        if isinstance(sText, array.array):
            try:
                sText = sText.tostring();
            except:
                pass;
        try:
            g_oReporter.subXmlWrite(self, sText, utils.getCallerName());
        except:
            traceback.print_exc();
        return None;
コード例 #39
0
ファイル: reporter.py プロジェクト: susanych1234/virtualbox
    def write(self, sText):
        """file.write"""
        # lazy start.
        if self.fStarted is not True:
            try:
                g_oReporter.subXmlStart(self)
            except:
                traceback.print_exc()
            self.fStarted = True

        if isinstance(sText, array.array):
            try:
                sText = sText.tostring()
            except:
                pass
        try:
            g_oReporter.subXmlWrite(self, sText, utils.getCallerName())
        except:
            traceback.print_exc()
        return None
コード例 #40
0
ファイル: reporter.py プロジェクト: mcenirm/vbox
def addLogFile(sFilename, sKind, sDescription = '', sAltName = None):
    """
    Adds the specified log file to the report if the file exists.

    The sDescription is a free form description of the log file.

    The sKind parameter is for adding some machine parsable hint what kind of
    log file this really is.

    Returns True on success, False on failure (no ENOENT errors are logged).
    """
    sTsPrf  = utils.getTimePrefix();
    sCaller = utils.getCallerName();
    fRc     = False;
    if sAltName is None:
        sAltName = sFilename;

    try:
        oSrcFile = utils.openNoInherit(sFilename, 'rb');
    except IOError, oXcpt:
        if oXcpt.errno != errno.ENOENT:
            logXcpt('addLogFile(%s,%s,%s)' % (sFilename, sDescription, sKind));
        else:
            logXcpt('addLogFile(%s,%s,%s) IOError' % (sFilename, sDescription, sKind));
コード例 #41
0
ファイル: db.py プロジェクト: miguelinux/vbox
 def insertList(self, sInsertSql, aoList, fnEntryFmt):
     """
     Optimizes the insertion of a list of values.
     """
     return self.insertListInternal(self._oCursor, sInsertSql, aoList, fnEntryFmt, utils.getCallerName());
コード例 #42
0
ファイル: reporter.py プロジェクト: susanych1234/virtualbox
def logXcptWorker(iLevel, fIncErrors, sPrefix="", sText=None, cFrames=1):
    """
    Log an exception, optionally with a preceeding message and more than one
    call frame.
    """
    g_oLock.acquire()
    if fIncErrors:
        g_oReporter.testIncErrors()

    ## @todo skip all this if iLevel is too high!

    # Try get exception info.
    sTsPrf = utils.getTimePrefix()
    try:
        oType, oValue, oTraceback = sys.exc_info()
    except:
        oType = oValue = oTraceback = None
    if oType is not None:

        # Try format the info
        try:
            rc = 0
            sCaller = utils.getCallerName(oTraceback.tb_frame)
            if sText is not None:
                rc = g_oReporter.log(iLevel, "%s%s" % (sPrefix, sText),
                                     sCaller, sTsPrf)
            asInfo = []
            try:
                asInfo = asInfo + traceback.format_exception_only(
                    oType, oValue)
                if cFrames is not None and cFrames <= 1:
                    asInfo = asInfo + traceback.format_tb(oTraceback, 1)
                else:
                    asInfo.append('Traceback:')
                    asInfo = asInfo + traceback.format_tb(oTraceback, cFrames)
                    asInfo.append('Stack:')
                    asInfo = asInfo + traceback.format_stack(
                        oTraceback.tb_frame.f_back, cFrames)
            except:
                g_oReporter.log(
                    0, 'internal-error: Hit exception #2! %s' %
                    (traceback.format_exc()), sCaller, sTsPrf)

            if len(asInfo) > 0:
                # Do the logging.
                for sItem in asInfo:
                    asLines = sItem.splitlines()
                    for sLine in asLines:
                        rc = g_oReporter.log(iLevel, '%s%s' % (sPrefix, sLine),
                                             sCaller, sTsPrf)

            else:
                g_oReporter.log(iLevel, 'No exception info...', sCaller,
                                sTsPrf)
                rc = -3
        except:
            g_oReporter.log(
                0,
                'internal-error: Hit exception! %s' % (traceback.format_exc()),
                None, sTsPrf)
            rc = -2
    else:
        g_oReporter.log(
            0, 'internal-error: No exception! %s' %
            (utils.getCallerName(iFrame=3)), utils.getCallerName(iFrame=3),
            sTsPrf)
        rc = -1

    g_oLock.release()
    return rc
コード例 #43
0
ファイル: db.py プロジェクト: flamenca/virtualbox
 def callProc(self, sProcedure, aoArgs=None):
     """ See TMDatabaseConnection.callProc()"""
     return self._oDb.callProcInternal(self._oCursor, sProcedure, aoArgs,
                                       utils.getCallerName())
コード例 #44
0
ファイル: db.py プロジェクト: flamenca/virtualbox
 def execute(self, sOperation, aoArgs=None):
     """ See TMDatabaseConnection.execute()"""
     return self._oDb.executeInternal(self._oCursor, sOperation, aoArgs,
                                      utils.getCallerName())
コード例 #45
0
ファイル: db.py プロジェクト: miguelinux/vbox
 def insertList(self, sInsertSql, aoList, fnEntryFmt):
     """ See TMDatabaseConnection.insertList. """
     return self._oDb.insertListInternal(self._oCursor, sInsertSql, aoList, fnEntryFmt, utils.getCallerName());
コード例 #46
0
ファイル: db.py プロジェクト: miguelinux/vbox
 def callProc(self, sProcedure, aoArgs = None):
     """ See TMDatabaseConnection.callProc()"""
     return self._oDb.callProcInternal(self._oCursor, sProcedure, aoArgs, utils.getCallerName());
コード例 #47
0
ファイル: db.py プロジェクト: miguelinux/vbox
 def execute(self, sOperation, aoArgs = None):
     """ See TMDatabaseConnection.execute()"""
     return self._oDb.executeInternal(self._oCursor, sOperation, aoArgs, utils.getCallerName());
コード例 #48
0
ファイル: db.py プロジェクト: flamenca/virtualbox
 def insertList(self, sInsertSql, aoList, fnEntryFmt):
     """
     Optimizes the insertion of a list of values.
     """
     return self.insertListInternal(self._oCursor, sInsertSql, aoList,
                                    fnEntryFmt, utils.getCallerName())
コード例 #49
0
ファイル: db.py プロジェクト: flamenca/virtualbox
 def insertList(self, sInsertSql, aoList, fnEntryFmt):
     """ See TMDatabaseConnection.insertList. """
     return self._oDb.insertListInternal(self._oCursor, sInsertSql, aoList,
                                         fnEntryFmt, utils.getCallerName())