Beispiel #1
0
 def telnettransform(within, _text, g):
     _text = IndentationUtils.indentTo(0, _text)
     _text = _text.replace("\n","\\n")
     _text = _text.replace("\t","\\t")
     _text = _text.replace("\"","\\\"")
     if (injectGlobals):
         _text = _text % _getNamespace(2)
     _text = "python\"%s\"" % _text
     telnetOutput[(port, host)].write(_text)
Beispiel #2
0
 def telnettransform(within, _text, g):
     _text = IndentationUtils.indentTo(0, _text)
     _text = _text.replace("\n", "\\n")
     _text = _text.replace("\t", "\\t")
     _text = _text.replace("\"", "\\\"")
     if (injectGlobals):
         _text = _text % _getNamespace(2)
     _text = "python\"%s\"" % _text
     telnetOutput[(port, host)].write(_text)
Beispiel #3
0
def telnetMaya(*k, **kw):
    """Sends code (python) to Maya.
    example: telnetMaya(port=8000,host="someotherhost.com",injectGlobals=1)
    """
    if (len(k) == 3 and len(kw) == 0):
        port = 8999
        host = "127.0.0.1"
        injectGlobals = 1
        if (not telnetOutput.has_key((port, host))):
            telnetOutput[(port, host)] = Telnet(host, port)
        within = k[0]
        _text = k[1]
        g = k[2]
        _text = IndentationUtils.indentTo(0, _text)
        _text = _text.replace("\n", "\\n")
        _text = _text.replace("\t", "\\t")
        _text = _text.replace("\"", "\\\"")
        if (injectGlobals):
            _text = _text % _getNamespace(2)
        _text = "python\"%s\"" % _text
        telnetOutput[(port, host)].write(_text)
        return
    port = kw.get("port", 8999)
    host = kw.get("host", "127.0.0.1")
    injectGlobals = kw.get("injectGlobals", 1)
    if (not telnetOutput.has_key((port, host))):
        telnetOutput[(port, host)] = Telnet(host, port)

    def telnettransform(within, _text, g):
        _text = IndentationUtils.indentTo(0, _text)
        _text = _text.replace("\n", "\\n")
        _text = _text.replace("\t", "\\t")
        _text = _text.replace("\"", "\\\"")
        if (injectGlobals):
            _text = _text % _getNamespace(2)
        _text = "python\"%s\"" % _text
        telnetOutput[(port, host)].write(_text)

    return telnettransform
Beispiel #4
0
def telnetMaya(*k, **kw):
    """Sends code (python) to Maya.
    example: telnetMaya(port=8000,host="someotherhost.com",injectGlobals=1)
    """
    if (len(k)==3 and len(kw)==0):
        port=8999
        host="127.0.0.1"
        injectGlobals=1
        if (not telnetOutput.has_key((port, host))):
            telnetOutput[(port, host)] = Telnet(host, port)
        within = k[0]
        _text = k[1]
        g = k[2]
        _text = IndentationUtils.indentTo(0, _text)
        _text = _text.replace("\n","\\n")
        _text = _text.replace("\t","\\t")
        _text = _text.replace("\"","\\\"")
        if (injectGlobals):
            _text = _text % _getNamespace(2)
        _text = "python\"%s\"" % _text
        telnetOutput[(port, host)].write(_text)
        return 
    port = kw.get("port", 8999)
    host = kw.get("host", "127.0.0.1")
    injectGlobals = kw.get("injectGlobals", 1)
    if (not telnetOutput.has_key((port, host))):
        telnetOutput[(port, host)] = Telnet(host, port)
    def telnettransform(within, _text, g):
        _text = IndentationUtils.indentTo(0, _text)
        _text = _text.replace("\n","\\n")
        _text = _text.replace("\t","\\t")
        _text = _text.replace("\"","\\\"")
        if (injectGlobals):
            _text = _text % _getNamespace(2)
        _text = "python\"%s\"" % _text
        telnetOutput[(port, host)].write(_text)
    return telnettransform
Beispiel #5
0
def insideGenerator(within, _text, g):
    """ wrap inside generator, and perform """
    genPreamble = """
#from __future__ import generators
def __exit0():
	_environment.exit()
def __enter0():
	_environment.enter()
def __tmp0():
	yield 0
"""
    genPostamble = """
#	globals().update(locals())
u.stackPrePost(__enter0, __tmp0(), _progress, __exit0)
"""
    _text = IndentationUtils.indentTo(1, _text)
    _text = genPreamble+_text+genPostamble
    localLocal = {"_progress":None}
    if (within):
	if (within.get()):
	    if (within.get().reference):
		localLocal["_progress"]=within.get().reference

    exec _text in _getNamespace(back=2), localLocal
Beispiel #6
0
def insideGenerator(within, _text, g):
    """ wrap inside generator, and perform """
    genPreamble = """
#from __future__ import generators
def __exit0():
	_environment.exit()
def __enter0():
	_environment.enter()
def __tmp0():
	yield 0
"""
    genPostamble = """
#	globals().update(locals())
u.stackPrePost(__enter0, __tmp0(), _progress, __exit0)
"""
    _text = IndentationUtils.indentTo(1, _text)
    _text = genPreamble + _text + genPostamble
    localLocal = {"_progress": None}
    if (within):
        if (within.get()):
            if (within.get().reference):
                localLocal["_progress"] = within.get().reference

    exec _text in _getNamespace(back=2), localLocal