I am attempting to run a command in terminal through a Python script. The command, which only takes three arguments, works perfectly when performed in terminal. Here is what is entered in the command line:
gpmetis inputfile numberOfSections
Wherever the inputfile
is from, say the Desktop, the outputfile
is dumped in the same location after gpmetis
is executed (it is named inputfile.part.numberOfSections
). gpmetis
only works in terminal, but for condensing purposes, I want to use it during the middle of the Python script to save time. (I would previously just shuffle around files to and from terminal and Python)
But this is where I run into problems... this question and this forum gave helpful hints on how to execute terminal within Python, but I'm still not receiving the outputfile
when I run the python code. It's like the output is suppressed or the way I call terminal is faulty.
I'm currently calling terminal like:
def Terminal(inputfile, NumParts):
os.system("gpmetis inputfile NumParts")
outputfile = "inputfile.part." + NumParts
return outputfile
And I don't get an error from this, but I don't receive any output file either. What am I missing here and if you know could you explain it? I'm trying to learn Python, so describing what I'm screwing up would be much appreciated.
os
has been imported. There may be a fault with how I am "returning" the outputfile
in my script, but I also do not see an outputfile
on my desktop, which is the first problem to be dealt with (one step at a time!)
NOTE: I found documentation that is related, but will it help me? I'm having trouble understanding it..