| Reference | Downloads | Github

Builder JS export evaluating conditions file


when I try to export my experiment from builder into javascript, I get this error message:

Traceback (most recent call last):
  File "C:\Program Files\PsychoPy\lib\site-packages\psychopy\app\builder\", line 793, in fileExport
  File "C:\Program Files\PsychoPy\lib\site-packages\psychopy\scripts\", line 74, in generateScript
    compileScript(infile=exp, version=None, outfile=filename)
  File "C:\Program Files\PsychoPy\lib\site-packages\psychopy\scripts\", line 247, in compileScript
    _makeTarget(thisExp, outfile, targetOutput)
  File "C:\Program Files\PsychoPy\lib\site-packages\psychopy\scripts\", line 219, in _makeTarget
    script = thisExp.writeScript(outfile, target=targetOutput, modular=True)
  File "C:\Program Files\PsychoPy\lib\site-packages\psychopy\experiment\", line 240, in writeScript
    localDateTime, modular)
  File "C:\Program Files\PsychoPy\lib\site-packages\psychopy\experiment\components\settings\", line 746, in writeInitCodeJS
  File "C:\Program Files\PsychoPy\lib\site-packages\psychopy\experiment\components\settings\", line 734, in prepareResourcesJS
    resourceFiles = self.exp.getResourceFiles()
  File "C:\Program Files\PsychoPy\lib\site-packages\psychopy\experiment\", line 877, in getResourceFiles
    condsPaths = findPathsInFile(params['conditionsFile'].val)
  File "C:\Program Files\PsychoPy\lib\site-packages\psychopy\experiment\", line 860, in findPathsInFile
    conds = data.importConditions(thisFile['abs'])  # load the abs path
  File "C:\Program Files\PsychoPy\lib\site-packages\psychopy\data\", line 409, in importConditions
    val = eval(val)
  File "<string>", line 1, in <module>
NameError: name 'blk4' is not defined

This is because I have the names to my image components without quotes in my conditions file ([blk4,blk2,blk9]). If I put them in quotes ([“blk4”,“blk2”,“blk9”]), the export to js works.
However, I cannot put them into quotes since the quotes will also get imported into the experiment and then these names don’t refer to the component named blk4 but rather to a nonexistent component “blk4”. What I am doing in my conditions file is setting a few possible sequences for the components.

Is there an easy way to stop the evaluation of the conditions file during the js export? I am aware that one solution to this would be to manually remove the quotes in a code component or manually copying the .xlsx file after conversion but I am looking for a simpler solution.

Thanks for any ideas!