def create_AWS_request_url(base_url, argd, _amazon_secret_access_key,<EOL>_timestamp=None):
<EOL>def get_AWS_signature(argd, _amazon_secret_access_key,<EOL>method="<STR_LIT:GET>", request_host="<STR_LIT>",<EOL>request_uri="<STR_LIT>",<EOL>_timestamp=None):<EOL><INDENT>"""<STR_LIT>"""<EOL>if not _timestamp:<EOL><INDENT>argd["<STR_LIT>"] = time.strftime("<STR_LIT>",<EOL>time.gmtime())<EOL><DEDENT>else:<EOL><INDENT>argd["<STR_LIT>"] = _timestamp<EOL><DEDENT>parameter_keys = sorted(argd.keys())<EOL>arguments = [quote(str(key), safe="<STR_LIT>") + "<STR_LIT:=>" +<EOL>quote(str(argd[key]), safe="<STR_LIT>")<EOL>for key in parameter_keys]<EOL>parameters_string = "<STR_LIT:&>".join(arguments)<EOL>parameters_string = method.upper() + "<STR_LIT:\n>" +request_host.lower() + "<STR_LIT:\n>" +(request_uri or "<STR_LIT:/>") + "<STR_LIT:\n>" +parameters_string<EOL>return calculate_RFC2104_HMAC(parameters_string,<EOL>_amazon_secret_access_key)<EOL><DEDENT>def calculate_RFC2104_HMAC(data, _amazon_secret_access_key):<EOL><INDENT>"""<STR_LIT>"""<EOL>if not HASHLIB_IMPORTED:<EOL><INDENT>current_app.logger.warning(<EOL>"<STR_LIT>"<EOL>)<EOL>return "<STR_LIT>"<EOL><DEDENT>else:<EOL><INDENT>if sys.version_info < (<NUM_LIT:2>, <NUM_LIT:5>):<EOL><INDENT>my_digest_algo = _MySHA256(sha256())<EOL><DEDENT>else:<EOL><INDENT>my_digest_algo = sha256<EOL><DEDENT><DEDENT>return base64.encodestring(<EOL>hmac.new(<EOL>_amazon_secret_access_key,<EOL>data,<EOL>my_digest_algo).digest()).strip()<EOL><DEDENT>parsed_url = urlparse(base_url)<EOL>signature = get_AWS_signature(argd, _amazon_secret_access_key,<EOL>request_host=parsed_url[<NUM_LIT:1>],<EOL>request_uri=parsed_url[<NUM_LIT:2>],<EOL>_timestamp=_timestamp)<EOL>if signature:<EOL><INDENT>argd["<STR_LIT>"] = signature<EOL><DEDENT>return base_url + "<STR_LIT:?>" + urlencode(argd)<EOL>
Create a signed AWS (Amazon Web Service) request URL corresponding
to the given parameters.

Example:
>> create_AWS_request_url("http://ecs.amazon.com/onca/xml",
                         {'AWSAccessKeyID': '0000000000',
                          'Service': 'AWSECommerceService',
                          'Operation': 'ItemLookup',
                          'ItemID': '0679722769',
                          'ResponseGroup': 'ItemAttributes,Offers,Images,Review'},
                         "1234567890")

@param base_url: Service URL of the Amazon store to query
@param argd: dictionary of arguments defining the query
@param _amazon_secret_access_key: your Amazon secret key
@param _timestamp: for testing purpose only (default: current timestamp)

@type base_url: string
@type argd: dict
@type _amazon_secret_access_key: string
@type _timestamp: string

@return signed URL of the request (string)