From: Marcin Krol Date: Sun, 2 May 2021 11:39:50 +0000 (+0200) Subject: - use builtin urllib instead of urllib3 X-Git-Url: https://git.tld-linux.org/?a=commitdiff_plain;h=152e487d9b9a69fd7cf20c23ed8550d7e25cd8ef;p=tld-builder.git - use builtin urllib instead of urllib3 - ported skip to python3 too --- diff --git a/client/make-request.sh b/client/make-request.sh index fdb750b..8467bf1 100755 --- a/client/make-request.sh +++ b/client/make-request.sh @@ -102,7 +102,8 @@ send_request() { *) msg "Sending using HTTP mode to $url" cat - | python3 -c ' -import sys, socket, urllib3, ssl +import sys, socket, ssl +from urllib import request try: _create_unverified_https_context = ssl._create_unverified_context @@ -112,11 +113,12 @@ else: ssl._create_default_https_context = _create_unverified_https_context try: - data = sys.stdin.read() + data = sys.stdin.read().encode("utf-8") url = sys.argv[1] socket.setdefaulttimeout(30) - http = urllib3.PoolManager(cert_reqs="CERT_NONE") - http.request("POST",url, body=data) + req = request.Request(url, data=data) + f = request.urlopen(req) + f.close() except Exception as e: print("Problem while sending request via HTTP: %s: %s" % (url, e), file=sys.stderr) sys.exit(1) @@ -539,35 +541,35 @@ esac # need to do this after dist selection if [ "$skip" ]; then skip=$(skip="$skip" control_url="$control_url" python3 -c ' -import urllib2 import sys -import StringIO import gzip import re import os import string +from urllib import request +from io import BytesIO from xml.dom import minidom skip = os.environ.get("skip").split(","); control_url = os.environ.get("control_url") -print >> sys.stderr, "* Check queue_id-s against %s" % control_url +print("* Check queue_id-s against %s" % control_url, file=sys.stderr) try: headers = { "Cache-Control": "no-cache", "Pragma": "no-cache" } - req = urllib2.Request(url=control_url + "/queue.gz", headers=headers) - f = urllib2.urlopen(req) -except Exception, e: - print >> sys.stderr, "Fetch error %s: %s" % (control_url + "/queue.gz", e) + req = request.Request(url=control_url + "/queue.gz", headers=headers) + f = request.urlopen(req) +except Exception as e: + print("Fetch error %s: %s" % (control_url + "/queue.gz", e), file=sys.stderr) sys.exit(1) -sio = StringIO.StringIO() +sio = BytesIO() sio.write(f.read()) f.close() sio.seek(0) f = gzip.GzipFile(fileobj = sio) -xml = re.compile("(.*?)", re.DOTALL).match(f.read()).group(1) +xml = re.compile("(.*?)", re.DOTALL).match(f.read().decode("utf-8")).group(1) d = minidom.parseString(xml) q = [] @@ -579,13 +581,13 @@ for c in d.documentElement.childNodes: err = 0 for s in skip: if s not in q: - print >> sys.stderr, "- Check %s: ERROR: Not valid queue-id" % s + print("- Check %s: ERROR: Not valid queue-id" % s, file=sys.stderr) err = 1 else: - print >> sys.stderr, "- Check %s: OK" % s + print("- Check %s: OK" % s, file=sys.stderr) if err == 1: sys.exit(1) -print string.join(skip, ",") +print(",".join(skip)) ') || exit $? f_upgrade=no build_mode=test