Auto-format python scripts with autopep8 (#61085)

This commit is contained in:
Vítor Galvão 2019-03-29 15:18:22 +00:00 committed by GitHub
parent 0338c46781
commit b0c1c8ce03
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 35 additions and 33 deletions

View File

@ -7,15 +7,16 @@ form = cgi.FieldStorage()
url = form.getvalue("url", "")
ua = form.getvalue("user_agent", "Mozilla")
try:
headers = { 'User-Agent' : ua }
req = urllib2.Request(url, None, headers)
response = urllib2.urlopen(req)
_, params = cgi.parse_header(response.headers.get('Content-Disposition', ''))
filename = params['filename']
try:
headers = {'User-Agent': ua}
req = urllib2.Request(url, None, headers)
response = urllib2.urlopen(req)
_, params = cgi.parse_header(
response.headers.get('Content-Disposition', ''))
filename = params['filename']
except Exception:
import traceback
filename = 'generic exception: ' + traceback.format_exc()
import traceback
filename = 'generic exception: ' + traceback.format_exc()
print "Content-type: text/html"
print

View File

@ -5,19 +5,20 @@ import urllib2
url = sys.argv[1]
headers = {'User-Agent' : 'Mozilla'}
headers = {'User-Agent': 'Mozilla'}
if len(sys.argv) > 2:
ua = sys.argv[2]
headers = { 'User-Agent' : ua }
ua = sys.argv[2]
headers = {'User-Agent': ua}
try:
req = urllib2.Request(url, None, headers)
response = urllib2.urlopen(req)
_, params = cgi.parse_header(response.headers.get('Content-Disposition', ''))
filename = params['filename']
try:
req = urllib2.Request(url, None, headers)
response = urllib2.urlopen(req)
_, params = cgi.parse_header(
response.headers.get('Content-Disposition', ''))
filename = params['filename']
except Exception:
import traceback
filename = 'generic exception: ' + traceback.format_exc()
import traceback
filename = 'generic exception: ' + traceback.format_exc()
print filename

View File

@ -7,13 +7,13 @@ form = cgi.FieldStorage()
url = form.getvalue("url", "")
ua = form.getvalue("user_agent", "Mozilla")
try:
headers = { 'User-Agent' : ua }
req = urllib2.Request(url, None, headers)
response = urllib2.urlopen(req)
redir = response.geturl()
headers = {'User-Agent': ua}
req = urllib2.Request(url, None, headers)
response = urllib2.urlopen(req)
redir = response.geturl()
except Exception:
import traceback
redir = 'generic exception: ' + traceback.format_exc()
import traceback
redir = 'generic exception: ' + traceback.format_exc()
print "Content-type: text/html"
print

View File

@ -5,17 +5,17 @@ import urllib2
url = sys.argv[1]
headers = {'User-Agent' : 'Mozilla'}
headers = {'User-Agent': 'Mozilla'}
if len(sys.argv) > 2:
ua = sys.argv[2]
headers = { 'User-Agent' : ua }
ua = sys.argv[2]
headers = {'User-Agent': ua}
try:
req = urllib2.Request(url, None, headers)
response = urllib2.urlopen(req)
redir = response.geturl()
req = urllib2.Request(url, None, headers)
response = urllib2.urlopen(req)
redir = response.geturl()
except Exception:
import traceback
redir = 'generic exception: ' + traceback.format_exc()
import traceback
redir = 'generic exception: ' + traceback.format_exc()
print redir