Skip to content
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

set urllib user-agent #2437

Merged
merged 1 commit into from
Mar 5, 2021
Merged

set urllib user-agent #2437

merged 1 commit into from
Mar 5, 2021

Conversation

obfusk
Copy link
Contributor

@obfusk obfusk commented Mar 5, 2021

fixes #2418

# jqueryui.com returns a 403 w/ the default user agent
url_opener = urllib.request.build_opener()
url_opener.addheaders = [('User-agent', 'Mozilla/5.0')]
urllib.request.install_opener(url_opener)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this change it at global level? Can't we use some kind of context manager or something so it's rolled back after the recipe download is done?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does. But since this is the only use of urllib in p4a and it seems unlikely that a different user agent would matter to any other code anyway, it seemed like the easiest solution.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the code. Is this better?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, looks good to me

Copy link
Member

@AndreMiras AndreMiras left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix

@AndreMiras AndreMiras merged commit 2bf2c6a into kivy:develop Mar 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error (Downloading matplotlib from https://jqueryui.com/resources/download/jquery-ui-1.12.1.zip)
2 participants