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"
;;
*)
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
data = sys.stdin.read()
url = sys.argv[1]
socket.setdefaulttimeout(30)
- req = urllib2.Request(url, data)
- f = urllib2.urlopen(req)
- f.close()
-except Exception, e:
- print >> sys.stderr, "Problem while sending request via HTTP: %s: %s" % (url, e)
+ http = urllib3.PoolManager(cert_reqs="CERT_NONE")
+ http.request("POST",url, body=data)
+except Exception as 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
# htmlspecialchars: escape <, > and &
hsc() {
local input=$1
- echo -E "$input" | sed -e 's,&,\&,g;s,<,\<,g;s,>,\>,g'
+ printf "%s\n" "$input" | sed -e 's,&,\&,g;s,<,\<,g;s,>,\>,g'
}
# simple df_fetcher, based on packages/fetchsrc_request
# 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
if [ "$command" ]; then
bid=$(uuidgen)
- echo -E >&2 "* Command: $command"
+ printf "%s\n" "* Command: $command" >&2
echo " <batch id='$bid' depends-on=''>"
echo " <command flags='$command_flags'>"
hsc "$command"
if [ "$no_depend" = yes ]; then
depend=
fi
- echo -E >&2 "* Post-Command: $post_command"
+ printf "%s\n" "* Post-Command: $post_command" >&2
echo " <batch id='$bid' depends-on='$depend'>"
echo " <command flags='$command_flags'>"
hsc "$post_command"