-
Notifications
You must be signed in to change notification settings - Fork 23
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
Adding User-Agent string to urllib #64
base: master
Are you sure you want to change the base?
Conversation
shellshare.net doesn't like urllib downloads of script.exe by default. Adding a User-Agent header to sidestep this until a server-side fix can be applied.
Hey @mikerenfro, when I try your patch, I get another error:
I'm using Ubuntu 20.04. I modified the |
I haven't seen that before. Building some test code now. |
Test code, I think it's something server-side or network-related, as I've run this repeatedly with no changes to the Python code, and get the 520 error about 10% of the time. #!/usr/bin/env python
try:
import urllib.request as url_req # for Python 3
test_opener = True
if test_opener:
opener = url_req.build_opener()
opener.addheaders = [('User-Agent', 'Mozilla/5.0')]
url_req.install_opener(opener)
except ImportError:
import urllib as url_req # for Python 2
import os
bindir = os.path.join(os.path.expanduser('~'), '.shellshare')
if not os.path.exists(bindir):
os.mkdir(bindir)
script_path = os.path.join(bindir, 'script.exe')
script_url = 'https://shellshare.net/bin/script.exe'
url_req.urlretrieve(script_url, script_path) |
@vitorbaptista so I guess see if there are any corresponding 520 errors logged in whatever stack of web servers run shellshare.net? |
shellshare.net doesn't like urllib downloads of script.exe by default. Adding a User-Agent header to sidestep this until a server-side fix can be applied.