Well, it’s supposed to be the same in jython as in python. I’ve used it myself in a public project: lsdrv. Look at the runx() function starting around line 102.
You are supposed to be able to do this kind of thing with the script function: system.utils.execute([arg1, arg2, …])
But I have not had much success yet using this.
To use subprocess, you import it first. Take a look at this StackOverflow article for some more information on launching Windows commands through Python using subprocess: http://stackoverflow.com/a/435669/579148
I’ve been doing some testing with this today. Make sure you save before running any commands with subprocess. I locked up my designer completely and had to hard kill the application and lost all my unsaved changes.
from subprocess import Popen, call
call(["{command line text here}"], shell=True)
What I was trying to do is open a document that is being stored in the database in it’s default Windows program. So the full code for me is:
[code]from subprocess import Popen, call
#Get the document id
docid = event.source.parent.getComponent(‘ptDocs’).DocID
if docid > 0: #Get the document data and extension
sql = “SELECT Extension, Data FROM Documents WHERE id = ?”
res = system.db.runPrepQuery(sql, [docid])
ext = res[0][0]
data = res[0][1]
#Get the temp file
path = system.file.getTempFile(ext)
try:
#Save the file data
system.file.writeFile(path, data, False) #False=>overwrite
#Open the file
call([path], shell=True)
except Exception:
system.gui.messageBox("Unable to open the file.", "Open File Error")