Merge "Keep py3.X compatibility for urllib"
This commit is contained in:
commit
a97a32eccb
@ -20,8 +20,8 @@ import gzip
|
||||
import os
|
||||
import re
|
||||
import six
|
||||
import six.moves.urllib.request as urlreq
|
||||
import sys
|
||||
import urllib2
|
||||
|
||||
import yaml
|
||||
|
||||
@ -67,9 +67,9 @@ def process_files(file_specs, url_specs, whitelists):
|
||||
logs_with_errors.append(name)
|
||||
for (name, url) in url_specs:
|
||||
whitelist = whitelists.get(name, [])
|
||||
req = urllib2.Request(url)
|
||||
req = urlreq.Request(url)
|
||||
req.add_header('Accept-Encoding', 'gzip')
|
||||
page = urllib2.urlopen(req)
|
||||
page = urlreq.urlopen(req)
|
||||
buf = six.StringIO(page.read())
|
||||
f = gzip.GzipFile(fileobj=buf)
|
||||
if scan_content(name, f.read().splitlines(), regexp, whitelist):
|
||||
@ -95,7 +95,7 @@ def scan_content(name, content, regexp, whitelist):
|
||||
|
||||
|
||||
def collect_url_logs(url):
|
||||
page = urllib2.urlopen(url)
|
||||
page = urlreq.urlopen(url)
|
||||
content = page.read()
|
||||
logs = re.findall('(screen-[\w-]+\.txt\.gz)</a>', content)
|
||||
return logs
|
||||
|
@ -19,8 +19,8 @@ import gzip
|
||||
import pprint
|
||||
import re
|
||||
import six
|
||||
import six.moves.urllib.request as urlreq
|
||||
import sys
|
||||
import urllib2
|
||||
|
||||
|
||||
pp = pprint.PrettyPrinter()
|
||||
@ -65,9 +65,9 @@ class StackTrace(object):
|
||||
|
||||
def hunt_for_stacktrace(url):
|
||||
"""Return TRACE or ERROR lines out of logs."""
|
||||
req = urllib2.Request(url)
|
||||
req = urlreq.Request(url)
|
||||
req.add_header('Accept-Encoding', 'gzip')
|
||||
page = urllib2.urlopen(req)
|
||||
page = urlreq.urlopen(req)
|
||||
buf = six.StringIO(page.read())
|
||||
f = gzip.GzipFile(fileobj=buf)
|
||||
content = f.read()
|
||||
@ -105,7 +105,7 @@ def log_url(url, log):
|
||||
|
||||
|
||||
def collect_logs(url):
|
||||
page = urllib2.urlopen(url)
|
||||
page = urlreq.urlopen(url)
|
||||
content = page.read()
|
||||
logs = re.findall('(screen-[\w-]+\.txt\.gz)</a>', content)
|
||||
return logs
|
||||
|
Loading…
Reference in New Issue
Block a user