Browse Source

Keep py3.X compatibility for urllib

Change-Id: Iba10637688ada66f2e3003cd87bbba7d4db4abc7
Closes-Bug: #1280105
tags/12.1.0
Yatin Kumbhare 3 years ago
parent
commit
2e2c83a527
2 changed files with 8 additions and 8 deletions
  1. +4
    -4
      tools/check_logs.py
  2. +4
    -4
      tools/find_stack_traces.py

+ 4
- 4
tools/check_logs.py View File

@@ -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

+ 4
- 4
tools/find_stack_traces.py View File

@@ -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…
Cancel
Save