Exemplo n.º 1
0
def runPytonTest(filepath, update, printoutput):

    def format_exception(e):
        krakenPath = os.environ['KRAKEN_PATH']
        stack = traceback.format_tb(sys.exc_info()[2])
        newStack = []
        for line in stack:
            if 'runTests.py' in line:
                continue
            lineParts = line.split('"')
            if len(lineParts) >= 3:
                modulePath = os.path.normpath(lineParts[1])
                if modulePath.startswith(krakenPath):
                    lineParts[1] = os.path.relpath(modulePath, krakenPath)
                    line = '"'.join(lineParts)
            newStack.append(line)
        exception_list = []
        exception_list.extend(newStack)
        exception_list.extend(traceback.format_exception_only(sys.exc_info()[0], sys.exc_info()[1]))

        exception_str = "Traceback (most recent call last):\n"
        exception_str += "".join(exception_list)
        # Removing the last \n
        exception_str = exception_str[:-1]

        return exception_str

    @contextlib.contextmanager
    def stdoutIO(stdout=None):
        old = sys.stdout
        if stdout is None:
            stdout = StringIO.StringIO()
        sys.stdout = stdout
        yield stdout
        sys.stdout = old

    with stdoutIO() as s:
        try:
            logger = getLogger('kraken')
            logger.setLevel(logging.DEBUG)

            for handler in logger.handlers:
                handler.setLevel(logging.DEBUG)

            execfile(filepath, {})
            output = s.getvalue()
        except Exception as e:
            print(format_exception(e))
            output = s.getvalue() + '\n'

    # Now remove all the output that comes from Fabric Engine loading...
    lines = output.split('\n')
    strippedlines = []
    for line in lines:
        if not line.startswith('[FABRIC'):
            strippedlines.append(line)

    output = '\n'.join(strippedlines)

    checkTestOutput(filepath, output, update, printoutput=printoutput)
Exemplo n.º 2
0
from PySide import QtGui, QtCore

from kraken.log import getLogger

logger = getLogger('kraken')


class KrakenStatusBar(QtGui.QStatusBar):
    """Custom status bar widget for Kraken."""

    def __init__(self, parent=None):
        super(KrakenStatusBar, self).__init__(parent)
        self.setObjectName('krakenStatusBar')

        for handler in logger.handlers:
            if type(handler).__name__ == 'WidgetHandler':
                handler.addWidget(self)

        self.createLayout()

    def createLayout(self):
        self.outputLogButton = QtGui.QPushButton('Log', self)
        self.outputLogButton.setObjectName('outputLog_button')
        self.insertPermanentWidget(0, self.outputLogButton)

    def showMessage(self, message, timeout=0):
        super(KrakenStatusBar, self).showMessage(message, timeout)

    def write(self, msg, level):
Exemplo n.º 3
0
import logging

from kraken.core.maths import Xfo, Vec3, Quat, Math_degToRad

from kraken.log import getLogger

from kraken.core.synchronizer import Synchronizer
from kraken.plugins.max_plugin.utils import *
from kraken.plugins.max_plugin.utils.curves import curveToKraken

logger = getLogger('kraken')


class Synchronizer(Synchronizer):
    """The Synchronizer is a singleton object used to synchronize data between
    Kraken objects and the DCC objects."""
    def __init__(self):
        super(Synchronizer, self).__init__()

    # ============
    # DCC Methods
    # ============
    def getDCCItem(self, kObject):
        """Gets the DCC Item from the full decorated path.

        Args:
            kObject (object): The Kraken Python object that we must find the corresponding DCC item.

        Returns:
            object: The created DCC object.
Exemplo n.º 4
0
def runPytonTest(filepath, update, printoutput):
    def format_exception(e):
        krakenPath = os.environ['KRAKEN_PATH']
        stack = traceback.format_tb(sys.exc_info()[2])
        newStack = []
        for line in stack:
            if 'runTests.py' in line:
                continue
            lineParts = line.split('"')
            if len(lineParts) >= 3:
                modulePath = os.path.normpath(lineParts[1])
                if modulePath.startswith(krakenPath):
                    lineParts[1] = os.path.relpath(modulePath, krakenPath)
                    line = '"'.join(lineParts)
            newStack.append(line)
        exception_list = []
        exception_list.extend(newStack)
        exception_list.extend(
            traceback.format_exception_only(sys.exc_info()[0],
                                            sys.exc_info()[1]))

        exception_str = "Traceback (most recent call last):\n"
        exception_str += "".join(exception_list)
        # Removing the last \n
        exception_str = exception_str[:-1]

        return exception_str

    @contextlib.contextmanager
    def stdoutIO(stdout=None):
        old = sys.stdout
        if stdout is None:
            stdout = StringIO.StringIO()
        sys.stdout = stdout
        yield stdout
        sys.stdout = old

    with stdoutIO() as s:
        try:
            logger = getLogger('kraken')
            logger.setLevel(logging.DEBUG)

            for handler in logger.handlers:
                handler.setLevel(logging.DEBUG)

            execfile(filepath, {})
            output = s.getvalue()
        except Exception as e:
            print(format_exception(e))
            output = s.getvalue() + '\n'

    # Now remove all the output that comes from Fabric Engine loading...
    lines = output.split('\n')
    strippedlines = []
    for line in lines:
        if not line.startswith('[FABRIC'):
            strippedlines.append(line)

    output = '\n'.join(strippedlines)

    checkTestOutput(filepath, output, update, printoutput=printoutput)