Builder problem. Cross-platform issues?

18 views
Skip to first unread message

Michael MacAskill

unread,
Jul 7, 2016, 9:52:07 PM7/7/16
to psychop...@googlegroups.com
Hi All,

I'm having a really frustrating problem working collaboratively on a Builder experiment. During development, we have the experiment in a DropBox folder so we can make changes and test them interactively across sites.

I'm on OS X, the other party is running Windows. I enter something like this in a code component:

# if the participant made a decision, go on to the feedback:
if 'left' in resp.keys or 'right' in resp.keys:
repeats.finished = True

And that is exactly what Builder generates for me when it creates the .py file (i.e. correctly formatted and indented code). But when the other person runs the same Builder file under Windows, this is what gets generated in their .py file:

# if the participant made a decision, go on to the feedback:
if 'left' in resp.keys or 'right' in resp.keys:
 repeats.finished = True


In this case, the code is skipped entirely, as it all ends up as a single-line comment. But if there is no leading comment, then syntax errors are generated because the '
' sequences end up within executable code.

Has anyone else seen this and knows what the issue is with not getting line endings into the .py file from code components?

Debugging the experiment is grinding to a halt here…

Regards,

Michael

--
Michael R. MacAskill, PhD 66 Stewart St
Research Director, Christchurch 8011
New Zealand Brain Research Institute NEW ZEALAND

Senior Research Fellow, michael....@nzbri.org
Te Whare Wānanga o Otāgo, Otautahi Ph: +64 3 3786 072
University of Otago, Christchurch http://www.nzbri.org/macaskill

Anneke Haddad

unread,
Jul 8, 2016, 5:39:26 AM7/8/16
to psychopy-users
Hi Michael,

This sounds like the same problem I've reported here: https://groups.google.com/forum/#!topic/psychopy-users/Ltt9f7t-Ils

I've not tested exhaustively whether this is due to switching between OS and Windows or switching between Psychopy 1.83.03 and 1.03.04 or both - but my first suggestion would be to check that you and your collaborator are both using the same version of Psychopy.

I've not found a solution so have been reduced to copy-pasting each offending bit of code into Word and find-replacing all instances of 
 with a paragraph mark and then copy-pasting back into Psychopy. It's tedious but doesn't take as long as I feared.

I hope someone can find a better solution soon!

Anneke

Richard Höchenberger

unread,
Jul 8, 2016, 6:16:34 AM7/8/16
to psychopy-users
On Fri, Jul 8, 2016 at 3:51 AM, Michael MacAskill
<michael....@nzbri.org> wrote:
> # if the participant made a decision, go on to the feedback:&#10;if 'left' in resp.keys or 'right' in resp.keys:&#10; repeats.finished = True&#10;

Seems like a problem re encoding of line ends on different platforms:
&#10; is a line feed. Really weird.

Richard

Jon Peirce

unread,
Jul 8, 2016, 7:09:24 AM7/8/16
to psychop...@googlegroups.com
Just looking into this and I think Anneke has nailed the problem correctly (thanks Anneke!). Looking at the code I'm pretty sure it comes from saving a file in 1.83.04 or later and opening it in 1.83.03 or earlier.

If your colleague could upgrade to 1.83.04 I think it will go away.

FWIW the issue is that the new file-saving mechanism we switched to (the builtin python xml rather than the needs-compiling lxml lib) didn't handle the character \n for some reason so I had to replace it with its html equivalent (&#10;) and then switch back when reading the file back in. The problem here is that older versions don't know do the second step of switching it back. :-/

If anyone knows how to fix the issue (so that we don't need to switch to the html character in the first place) then the relevant lines to work on would be lines 293 and 310 in the repository experiment.py file:
https://github.com/psychopy/psychopy/blob/master/psychopy/app/builder/experiment.py
Possibly we can do somethig inbetween the step where we prettyprint using the xml module and where we write the string to the file so that it will be saved using proper unicode characters rather than web characters.

best wishes
Jon
--
You received this message because you are subscribed to the Google Groups "psychopy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to psychopy-user...@googlegroups.com.
To post to this group, send email to psychop...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/psychopy-users/f2e7112c-ce8b-4778-a56f-bf3c3ca3bd76%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

-- 
Jon Peirce
http://www.peirce.org.uk

Michael MacAskill

unread,
Jul 11, 2016, 8:05:05 PM7/11/16
to psychop...@googlegroups.com
Thanks all,

It was the version problem. I knew that line endings were the issue, but assumed that was a cross-platform rather than version thing. 

Unfortunately she can't upgrade, as that causes issues with playing sound files… But we found a Frankenstein solution to get by.

Regards,

Michael


On 8/07/2016, at 23:09, Jon Peirce <jon.p...@gmail.com> wrote:

Just looking into this and I think Anneke has nailed the problem correctly (thanks Anneke!). Looking at the code I'm pretty sure it comes from saving a file in 1.83.04 or later and opening it in 1.83.03 or earlier. 

If your colleague could upgrade to 1.83.04 I think it will go away.

FWIW the issue is that the new file-saving mechanism we switched to (the builtin python xml rather than the needs-compiling lxml lib) didn't handle the character \n for some reason so I had to replace it with its html equivalent (&#10;) and then switch back when reading the file back in. The problem here is that older versions don't know do the second step of switching it back. :-/

If anyone knows how to fix the issue (so that we don't need to switch to the html character in the first place) then the relevant lines to work on would be lines 293 and 310 in the repository experiment.py file:
https://github.com/psychopy/psychopy/blob/master/psychopy/app/builder/experiment.py
Possibly we can do somethig inbetween the step where we prettyprint using the xml module and where we write the string to the file so that it will be saved using proper unicode characters rather than web characters.

best wishes
Jon

Reply all
Reply to author
Forward
0 new messages