def cmdCallback( nativeMsg, messageType, data ):
    global callbackState

    #outputFile = open( '/var/tmp/commandOutput', 'a')
    #outputFile.write( '============\n%s\n%s %s, length %s \n' % (nativeMsg, messageType, callbackState, len(nativeMsg))  )
    #outputFile.close()


    if callbackState == 'ignoreCommand':
        callbackState = 'ignoreResult'
        return
    elif callbackState == 'ignoreResult':
        callbackState = 'normal'
        return

    global sourceType
    global allHistory

    syntaxError = False
    convertedMsg = None

    # Command History
    if messageType == OpenMaya.MCommandMessage.kHistory:
        callbackState = 'normal'
        #if nativeMsg.rfind(';') == len(nativeMsg)-2 : # and len(nativeMsg) >= 2:
        if nativeMsg.endswith(';\n') : # and len(nativeMsg) >= 2:
            sourceType = kMel
            try:
                #convertedMsg = mel2py.mel2pyStr( nativeMsg )
                convertedMsg = mparser.parse( nativeMsg )
            except Exception, msg:
                syntaxError = True
                pass
        else:
            sourceType = kPython

    # Display - unaltered strings, such as that printed by the print command
    elif messageType == OpenMaya.MCommandMessage.kDisplay and ( nativeMsg.endswith(';\n') or nativeMsg.startswith( '//' ) ):
        try:
            #convertedMsg = mel2py.mel2pyStr( nativeMsg )
            convertedMsg = mparser.parse( nativeMsg )
        except Exception, msg:
            pass
    else:
        try:
            nativeMsg = {
                    #OpenMaya.MCommandMessage.kDisplay: 'Output',
                    OpenMaya.MCommandMessage.kInfo: '',
                    OpenMaya.MCommandMessage.kWarning: 'Warning: ',
                    OpenMaya.MCommandMessage.kError: 'Error: ',
                    OpenMaya.MCommandMessage.kResult: 'Result: '
                }[ messageType ] + nativeMsg

            if sourceType == kMel:
                convertedMsg = '# %s #\n' % nativeMsg
                nativeMsg = '// %s //\n' % nativeMsg
            else:
                nativeMsg = '# %s #\n' % nativeMsg

        except __HOLE__:
            pass

    nativeMsg = encodeString( nativeMsg )
    if convertedMsg is not None:
        convertedMsg = encodeString( convertedMsg )

    #outputFile = open( '/var/tmp/commandOutput', 'a')
    #outputFile.write( '---------\n%s %s\n' % ( convertedMsg, sourceType ) )
    #outputFile.close()

    line = [ messageType, sourceType, nativeMsg, convertedMsg ]

    allHistory.append( line )

    #if messageType == OpenMaya.MCommandMessage.kError : # and 'Syntax error' in nativeMsg:
    #    return

    for reporter in reporters.values():
        reporter.appendHistory( line )

    if syntaxError:
        callbackState = 'syntax_error'

    #elif callbackState == 'syntax_error' and 'Syntax error' in nativeMsg:
    #    callbackState = 'normal'

    #global output
    #output += encodeString( message )

    #cmd = 'global string $gCommandReporter;cmdScrollFieldReporter -edit -text \"%s\" $gCommandReporter;' % output
    #cmd = 'scrollField -e -text \"%s\" %s;\n' % ( output, scrollFieldName )



    #OpenMaya.MGlobal.executeCommand( cmd, False, False )

# command
dataset/ETHPy150Open CountZer0/PipelineConstructionSet/python/maya/site-packages/pymel-1.0.3/pymel/tools/scriptEditor/pymelScrollFieldReporter.py/cmdCallback