From 5ac708c69105c8393b6b8528d141574a1aaeefd4 Mon Sep 17 00:00:00 2001 From: Quinn Jarrell Date: Tue, 25 Jul 2017 15:29:00 -0500 Subject: [PATCH] Updated to work with python 3.5. quote_plus is now under a parse object in urllib and hmac now requires the secret in byte form instead of string form --- aws_query.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/aws_query.py b/aws_query.py index 5182455..a640e78 100644 --- a/aws_query.py +++ b/aws_query.py @@ -2,7 +2,7 @@ import hmac import base64 import hashlib -import urllib +from urllib import parse if len(sys.argv) != 5: print ('Output HTTPS GET links to be used to check the oracle status') @@ -22,11 +22,12 @@ def makeurl(args, endpoint, abbr): args.sort() argstr = '' for arg in args: - argstr += urllib.quote_plus(arg, '=')+'&' + argstr += parse.quote_plus(arg, '=')+'&' argstr = argstr[:-1] - mhmac = hmac.new(secret, ('GET\n'+endpoint+'\n/\n'+argstr).encode('utf-8'),hashlib.sha256) + secret_bytes = bytes(secret , 'latin-1') + mhmac = hmac.new(secret_bytes, ('GET\n'+endpoint+'\n/\n'+argstr).encode('utf-8'),hashlib.sha256) base64str = base64.b64encode(mhmac.digest()).strip().decode('utf-8') - urlenc_sig = urllib.quote_plus(base64str) + urlenc_sig = parse.quote_plus(base64str) final_string='https://'+endpoint+'/?'+argstr+'&Signature='+urlenc_sig print ("'" + abbr + "':'" + final_string + "',")