Skip to content

Can't log on to Pavlovia from Builder on first go #5382

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jomimc opened this issue Feb 15, 2023 · 1 comment
Closed

Can't log on to Pavlovia from Builder on first go #5382

jomimc opened this issue Feb 15, 2023 · 1 comment
Labels
💻 app/ui PsychoPy app changes (often wxPython issues) 🐞 bug Issue describes a bug (crash or error) or undefined behavior.

Comments

@jomimc
Copy link

jomimc commented Feb 15, 2023

Description of the problem:
On the Builder, when I click "Pavlovia.org -> User -> Log in to Pavlovia...", I get the following error message.

Traceback (most recent call last):
File "/home/johnmcbride/.local/lib/python3.8/site-packages/psychopy/app/pavlovia_ui/menu.py", line 121, in onLogInPavlovia
logInPavlovia(parent=self.parent)
File "/home/johnmcbride/.local/lib/python3.8/site-packages/psychopy/app/pavlovia_ui/functions.py", line 93, in logInPavlovia
dlg = PavloviaMiniBrowser(parent=parent, loginOnly=True)
File "/home/johnmcbride/.local/lib/python3.8/site-packages/psychopy/app/pavlovia_ui/_base.py", line 79, in init
self.user = pavlovia.getCurrentSession().user
File "/home/johnmcbride/.local/lib/python3.8/site-packages/psychopy/projects/pavlovia.py", line 442, in user
if not hasattr(self.gitlab, "user") or self.gitlab.user.username is None:
AttributeError: 'NoneType' object has no attribute 'username'

I am new to using the Builder, so, this is my first time trying to log in to Pavlovia through the Builder. This problem occurred first while I was using psychopy version 2022.2; the problem persists after installing the latest (2023.1) version.

Upon inspection of "./psychopy/projects/pavlovia.py", it looks like line 442 might have a bug. When a PavloviaSession class is initialized without a token, self.gitlab.user is initialized as "None" (I checked that this is the case). Hence, line 442 "if not hasattr(self.gitlab, "user") or self.gitlab.user.username is None" will throw an error in this case.

In my case, the problem is solved by replacing lines 442-444 with the following:
try: self._user = User(self.gitlab.user.username) except: return None

@TEParsons
Copy link
Contributor

Thanks for catching this and for doing the legwork to track it down! Your solution seems reasonable - only thing is that we try to avoid using except without catching a specific exception type, so I think except AttributeError is better in this case. I'll apply your fix and put in a PR now :)

@TEParsons TEParsons added 💻 app/ui PsychoPy app changes (often wxPython issues) 🐞 bug Issue describes a bug (crash or error) or undefined behavior. labels Mar 15, 2023
TEParsons added a commit that referenced this issue Mar 15, 2023
BF: Catch AttributeErrors on Pavlovia login rather than trying to pre-empt them, fixes #5382
@peircej peircej closed this as completed in 8de7a1f Apr 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💻 app/ui PsychoPy app changes (often wxPython issues) 🐞 bug Issue describes a bug (crash or error) or undefined behavior.
Projects
None yet
Development

No branches or pull requests

2 participants