예제 #1
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
예제 #2
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
예제 #3
0
파일: TextTransforms.py 프로젝트: EQ4/Field
def rawPython(a,b,c):
    """Execute the text as a new CPython process"""
    tmpFile = File.createTempFile("fieldRawPython", ".py", None)
    writer = BufferedWriter(FileWriter(tmpFile))
    writer.write(b, 0, len(b))
    writer.close()
    com = ExecuteCommand(".", ("/System/Library/Frameworks/Python.framework/Versions/Current/bin/python", tmpFile.getAbsolutePath()),1)
    com.waitFor(1)
    print com.getOutput()
예제 #4
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()
예제 #5
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()
예제 #6
0
def rawPython(a, b, c):
    """Execute the text as a new CPython process"""
    tmpFile = File.createTempFile("fieldRawPython", ".py", None)
    writer = BufferedWriter(FileWriter(tmpFile))
    writer.write(b, 0, len(b))
    writer.close()
    com = ExecuteCommand(".", (
        "/System/Library/Frameworks/Python.framework/Versions/Current/bin/python",
        tmpFile.getAbsolutePath()), 1)
    com.waitFor(1)
    print com.getOutput()