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
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
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
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
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)
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)
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()
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()
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
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
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
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
def defaultTransform(within, _text, g): """ do nothing, just execute the text itself """ exec _text in _getNamespace(back=2)
def telnettransform(within, _text, g): _text = _text % _getNamespace(back=2) print "sending %s " % _text telnetOutput[(port, host)].write(_text)
def applescript(inside, text, l, back=2): """Execute as AppleScript""" script = AppleScript(text % _getNamespace(back), 1) print "script:%s"%script.getOutput()
def applescript(inside, text, l, back=2): """Execute as AppleScript""" script = AppleScript(text % _getNamespace(back), 1) print "script:%s" % script.getOutput()