示例#1
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()
示例#2
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()
示例#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
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
 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()
示例#7
0
def openFile(filename):
    """Opens a file with that file's default Application.

	For example open("/var/tmp/something.pdf") will open that file in Preview (or Acrobat)
	"""
    ExecuteCommand(".", ("/usr/bin/open", filename), 0).waitFor()