I'm trying to use a QProcess
to run a mkdir
command (I'm using linux). The process would create a folder on the user's Desktop called 'output'. The code looks like this:
def mkOutput():
# get the user's environmental variables
env = QtCore.QProcessEnvironment.systemEnvironment()
proc = QtCore.QProcess()
proc.setProcessEnvironment(env)
# find the HOME variable, append it to args
HOME = env.value('HOME', defaultValue='./')
args = "/Desktop/output/"
args = HOME+args
proc.setStandardOutputFile('out.txt')
proc.setStandardErrorFile('err.txt')
proc.start("mkdir", args)
proc.waitForFinished()
out.txt is empty while err.txt reads:
/usr/bin/mkdir: cannot create directory ‘/’: File exists
/usr/bin/mkdir: cannot create directory ‘o’: File exists
/usr/bin/mkdir: cannot create directory ‘t’: File exists
/usr/bin/mkdir: cannot create directory ‘p’: File exists
/usr/bin/mkdir: cannot create directory ‘u’: File exists
/usr/bin/mkdir: cannot create directory ‘t’: File exists
/usr/bin/mkdir: cannot create directory ‘/’: File exists
For some reason it's trying to run mkdir
on each letter in the argument rather than using the whole string itself.
I've tried to use str() to on the args
variable but nothing seems to work. Every time it just creates multiple folders in the directory I run the program from.