예제 #1
0
def telnet(*k, **kw):
    """
    sends text via telnet
    example: telnet(port=2000, host="someotherhost.com")
    """
    if (len(k) == 3 and len(kw) == 0):
        port = 8999
        host = "127.0.0.1"
        if (not telnetOutput.has_key((port, host))):
            telnetOutput[(port, host)] = Telnet(host, port)
        _within = k[0]
        _text = k[1]
        _text = _text % _getNamespace(back=2)
        print "sending %s " % _text
        telnetOutput[(port, host)].write(_text)
        return
    port = kw.get("port", 8999)
    host = kw.get("host", "127.0.0.1")

    if (not telnetOutput.has_key((port, host))):
        telnetOutput[(port, host)] = Telnet(host, port)

    def telnettransform(within, _text, g):
        _text = _text % _getNamespace(back=2)
        print "sending %s " % _text
        telnetOutput[(port, host)].write(_text)

    return telnettransform
예제 #2
0
파일: TextTransforms.py 프로젝트: EQ4/Field
def telnet(*k, **kw):
    """
    sends text via telnet
    example: telnet(port=2000, host="someotherhost.com")
    """
    if (len(k)==3 and len(kw)==0):
        port=8999
        host="127.0.0.1"
        if (not telnetOutput.has_key((port, host))):
            telnetOutput[(port, host)] = Telnet(host, port)
        _within = k[0]
        _text = k[1]
        _text = _text % _getNamespace(back=2)
        print "sending %s " % _text
        telnetOutput[(port, host)].write(_text)
        return
    port = kw.get("port", 8999)
    host = kw.get("host", "127.0.0.1")

    if (not telnetOutput.has_key((port, host))):
        telnetOutput[(port, host)] = Telnet(host, port)
    def telnettransform(within, _text, g):
        _text = _text % _getNamespace(back=2)
        print "sending %s " % _text
        telnetOutput[(port, host)].write(_text)

    return telnettransform
예제 #3
0
def bash(*args):
    """Execute in a bash shell.
	There are two ways to call this, first as just 'bash' this executes the text and prints the output. Secondly, bash("varname"), executes the text and sets varname equal to this output.
	"""
    if (len(args) == 3):
        a, b, c = args
        ss = b % _getNamespace(2)
        print ss
        pp = File.createTempFile("field_tmpBash", "").getAbsolutePath()
        f = file(pp, "w")
        print >> f, ss
        f.close()
        ex = ExecuteCommand(".", ["/bin/bash", pp], 1)
        ex.waitFor(1)
        print ex.getOutput()
        return ex.getOutput()
    else:

        def doBash(a, b, c):
            ss = b % _getNamespace(2)
            pp = File.createTempFile("field_tmpBash", "").getAbsolutePath()
            f = file(pp, "w")
            print >> f, ss
            f.close()
            ex = ExecuteCommand(".", ["/bin/bash", pp], 1)
            ex.waitFor(1)
            c[args[0]] = ex.getOutput()
            return ex.getOutput()

        return doBash
예제 #4
0
파일: TextTransforms.py 프로젝트: EQ4/Field
def bash(*args):
	"""Execute in a bash shell.
	There are two ways to call this, first as just 'bash' this executes the text and prints the output. Secondly, bash("varname"), executes the text and sets varname equal to this output.
	"""
	if (len(args)==3):
		a,b,c = args
		ss = b % _getNamespace(2)
		print ss
		pp = File.createTempFile("field_tmpBash", "").getAbsolutePath()
		f = file(pp, "w")
		print >> f, ss
		f.close()
		ex = ExecuteCommand(".", ["/bin/bash", pp], 1)
		ex.waitFor(1)
		print ex.getOutput()
		return ex.getOutput()
	else:
		def doBash(a,b,c):
			ss = b % _getNamespace(2)
			pp = File.createTempFile("field_tmpBash", "").getAbsolutePath()
			f = file(pp, "w")
			print >> f, ss
			f.close()
			ex = ExecuteCommand(".", ["/bin/bash", pp], 1)
			ex.waitFor(1)
			c[args[0]]=ex.getOutput()
			return ex.getOutput()
		return doBash
예제 #5
0
파일: TextTransforms.py 프로젝트: EQ4/Field
 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)
예제 #6
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)
예제 #7
0
 def doBash(a, b, c):
     ss = b % _getNamespace(2)
     pp = File.createTempFile("field_tmpBash", "").getAbsolutePath()
     f = file(pp, "w")
     print >> f, ss
     f.close()
     ex = ExecuteCommand(".", ["/bin/bash", pp], 1)
     ex.waitFor(1)
     c[args[0]] = ex.getOutput()
     return ex.getOutput()
예제 #8
0
파일: TextTransforms.py 프로젝트: EQ4/Field
		def doBash(a,b,c):
			ss = b % _getNamespace(2)
			pp = File.createTempFile("field_tmpBash", "").getAbsolutePath()
			f = file(pp, "w")
			print >> f, ss
			f.close()
			ex = ExecuteCommand(".", ["/bin/bash", pp], 1)
			ex.waitFor(1)
			c[args[0]]=ex.getOutput()
			return ex.getOutput()
예제 #9
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
예제 #10
0
파일: TextTransforms.py 프로젝트: EQ4/Field
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
예제 #11
0
파일: TextTransforms.py 프로젝트: EQ4/Field
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
예제 #12
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
예제 #13
0
파일: TextTransforms.py 프로젝트: EQ4/Field
def defaultTransform(within, _text, g):
    """ do nothing, just execute the text itself """
    exec _text in _getNamespace(back=2)
예제 #14
0
파일: TextTransforms.py 프로젝트: EQ4/Field
 def telnettransform(within, _text, g):
     _text = _text % _getNamespace(back=2)
     print "sending %s " % _text
     telnetOutput[(port, host)].write(_text)
예제 #15
0
def defaultTransform(within, _text, g):
    """ do nothing, just execute the text itself """
    exec _text in _getNamespace(back=2)
예제 #16
0
 def telnettransform(within, _text, g):
     _text = _text % _getNamespace(back=2)
     print "sending %s " % _text
     telnetOutput[(port, host)].write(_text)
예제 #17
0
파일: TextTransforms.py 프로젝트: EQ4/Field
def applescript(inside, text, l, back=2):
    """Execute as AppleScript"""
    script = AppleScript(text % _getNamespace(back), 1)
    print "script:%s"%script.getOutput()
예제 #18
0
def applescript(inside, text, l, back=2):
    """Execute as AppleScript"""
    script = AppleScript(text % _getNamespace(back), 1)
    print "script:%s" % script.getOutput()