Пример #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()