On Wed, Aug 31, 2016 at 4:34 AM, Viktor Engelmann
<viktor.engelm...@qt.io> wrote:
>
>
>
> Am 31.08.2016 um 10:28 schrieb Viktor Engelmann:
>
>
>
> Am 31.08.2016 um 02:02 schrieb Kyle Altendorf:
>
> On August 30, 2016 7:44:14 PM EDT, Kyle Altendorf <s...@fstab.net> wrote:
>
> On August 30, 2016 4:28:25 PM EDT, Larry Martell
> <larry.mart...@gmail.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?
>
> Try printing sys.executable and os.getcwd() and see if they show any
> differences that might shed some light.  I'm on my phone so hopefully I
> am remembering those correctly.
>
> Or, is the file being accessed or created by the calling C++ application?  
> Depending on how each opens it there could be a conflict of sorts there.
>
>
> Interesting idea - if the C++ code creates the file and starts python without 
> closing the file, that might explain the behavior... although the python 
> script SHOULD throw an exception or something instead of "loading" an "empty 
> file" - but such "improvements" wouldn't surprise me in python...
>
> Viktor
>
>
> Although... then it should also not work with filenames without spaces...

This indeed was the issue. The filename with spaces was being created
by the C++ code and the buffer had not been flushed. Adding a flush
fixed it. When I was testing with a filename without spaces I was not
using a file created by the C++ program. Much thanks to everyone who
replied and offered advice and suggestions.
_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to