From b06ac0a74084c2ed513ecead310ea47208344d14 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bartosz=20=C5=9Awi=C4=85tek?= Date: Tue, 13 Apr 2021 15:31:56 +0200 Subject: [PATCH] - Update make-request to python3 with urllib3 --- client/make-request.sh | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/client/make-request.sh b/client/make-request.sh index d83e7ac..fdb750b 100755 --- a/client/make-request.sh +++ b/client/make-request.sh @@ -21,7 +21,7 @@ pkgrevision=no requester_override= relup=no -if [ -x /usr/bin/python ]; then +if [ -x /usr/bin/python3 ]; then send_mode="python" else echo "No python present, using mail mode" @@ -101,8 +101,8 @@ send_request() { ;; *) msg "Sending using HTTP mode to $url" - cat - | python -c ' -import sys, socket, urllib2, ssl + cat - | python3 -c ' +import sys, socket, urllib3, ssl try: _create_unverified_https_context = ssl._create_unverified_context @@ -115,13 +115,12 @@ try: data = sys.stdin.read() url = sys.argv[1] socket.setdefaulttimeout(30) - req = urllib2.Request(url, data) - f = urllib2.urlopen(req) - f.close() + http = urllib3.PoolManager(cert_reqs="CERT_NONE") + http.request("POST",url, body=data) except Exception as e: - print >> sys.stderr, "Problem while sending request via HTTP: %s: %s" % (url, e) + print("Problem while sending request via HTTP: %s: %s" % (url, e), file=sys.stderr) sys.exit(1) -print >> sys.stdout, "Request queued via HTTP." + print("Request queued via HTTP.", file=sys.stdout) ' "$url" ;; esac @@ -539,7 +538,7 @@ esac # need to do this after dist selection if [ "$skip" ]; then - skip=$(skip="$skip" control_url="$control_url" python -c ' + skip=$(skip="$skip" control_url="$control_url" python3 -c ' import urllib2 import sys import StringIO -- 2.46.0