Auto-format python scripts with autopep8 (#61085)
This commit is contained in:
parent
0338c46781
commit
b0c1c8ce03
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue