Exemple #1
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
Exemple #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
Exemple #3
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()
Exemple #4
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()
Exemple #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()
Exemple #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()