[Interest] script invoked with QProcess cannot open files, with spaces in path

Roland Hughes roland at logikalsolutions.com
Wed Aug 31 01:56:04 CEST 2016


Please provide the entire QProcess() call.


On 08/30/2016 06:53 PM, Larry Martell wrote:
> On Tue, Aug 30, 2016 at 7:38 PM, Roland Hughes
> <roland at logikalsolutions.com> wrote:
>> I am invoking a python script with QProcess. I have found that if the
>> script tries to open a file that has spaces in the path, no error is
>> thrown, but the file always appears to have 0 length. The same script
>> with the same file with spaces in the path invoked from the command
>> line works fine. Note that this has nothing to do with argument
>> passing from the C++ code to the script via QProcess - the file path
>> name is hardcoded in the script. If the file has no spaces in its path
>> it is opened fine. I have tied escaping the spaces with \ but no joy.
>> Anyone know why this would be happening and know a way around this?
>> <<
>>
>> QProcess() as I recall, parses the string and assumes space to mark the end
>> of a command and start of the parameter list. Ran into this on Linux as
>> well. You need an extra set of quotes (or some other kind of delimiter) in
>> the command to stop QProcess() from "helping you out."
> No parameters are being passed to QProcess. Its start method is being
> called with:
>
> ("/usr/bin/python2.7", "myscript.py")
>
> The path of the file being opened is hard coded in the python script.

-- 
Roland Hughes, President
Logikal Solutions
(630)-205-1593

http://www.theminimumyouneedtoknow.com
http://www.infiniteexposure.net
http://www.johnsmith-book.com
http://www.logikalblog.com
http://www.interestingauthors.com/blog




More information about the Interest mailing list