Skip to content

Commit af6622c

Browse files
committed
BF: local-debug of online studies fetched incorrect lib version name
Really we should have a method to generate the correct version name (out of Experiment class?) so that the same code is used during compilePsyexp and in RunnerPanel.getPsychoJS() but for now I've just fixed in the one place
1 parent 0419007 commit af6622c

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

psychopy/app/runner/runner.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# Distributed under the terms of the GNU General Public License (GPL).
77
import glob
88
import json
9-
9+
import errno
1010
from psychopy.app.themes._themes import ThemeSwitcher
1111

1212
from ..themes import ThemeMixin
@@ -686,6 +686,7 @@ def runOnlineDebug(self, evt, port=12002):
686686
stderr=PIPE,
687687
shell=False,
688688
universal_newlines=True,
689+
689690
)
690691

691692
time.sleep(.1) # Wait for subprocess to start server
@@ -702,20 +703,23 @@ def getPsychoJS(self):
702703
703704
Useful for debugging, amending scripts.
704705
"""
705-
libPath = str(self.currentFile.parent / self.outputPath / 'lib')
706-
ver = '.'.join(self.app.version.split('.')[:2])
706+
libPath = self.currentFile.parent / self.outputPath / 'lib'
707+
ver = '.'.join(self.app.version.split('.')[:3])
707708
psychoJSLibs = ['core', 'data', 'util', 'visual', 'sound']
708709

709-
os.path.exists(libPath) or os.makedirs(libPath)
710-
711-
if len(sorted(Path(libPath).glob('*.js'))) >= len(psychoJSLibs): # PsychoJS lib files exist
712-
print("##### PsychoJS lib already exists in {} #####\n".format(libPath))
713-
return
710+
try: # ask-for-forgiveness rather than query-then-make
711+
os.makedirs(libPath)
712+
except OSError as e:
713+
if e.errno != errno.EEXIST: # we only want to ignore "exists", not others like permissions
714+
raise # raises the error again
714715

715716
for lib in psychoJSLibs:
717+
finalPath = libPath / ("{}-{}.js".format(lib, ver))
718+
if finalPath.exists():
719+
continue
716720
url = "https://lib.pavlovia.org/{}-{}.js".format(lib, ver)
717721
req = requests.get(url)
718-
with open(libPath + "/{}-{}.js".format(lib, ver), 'wb') as f:
722+
with open(finalPath, 'wb') as f:
719723
f.write(req.content)
720724

721725
print("##### PsychoJS libs downloaded to {} #####\n".format(libPath))

0 commit comments

Comments
 (0)