Back-port #36714 to 2016.11 (#39133)

* Fix: local variable result referenced before assignment

* Fix: if 'path' variable is None convert it into an empty string
This commit is contained in:
Nicole Thomas 2017-02-02 08:35:46 -07:00 committed by GitHub
parent 8b34fcdb45
commit f2c309af73

View file

@ -106,6 +106,9 @@ def query(key, keyid, method='GET', params=None, headers=None,
if local_file:
payload_hash = salt.utils.get_hash(local_file, form='sha256')
if path is None:
path = ''
if not requesturl:
requesturl = 'https://{0}/{1}'.format(endpoint, path)
headers, requesturl = salt.utils.aws.sig4(
@ -132,13 +135,13 @@ def query(key, keyid, method='GET', params=None, headers=None,
if method == 'PUT':
if local_file:
with salt.utils.fopen(local_file, 'r') as data:
result = requests.request(method,
requesturl,
headers=headers,
data=data,
verify=verify_ssl,
stream=True)
data = salt.utils.fopen(local_file, 'r')
result = requests.request(method,
requesturl,
headers=headers,
data=data,
verify=verify_ssl,
stream=True)
response = result.content
elif method == 'GET' and local_file and not return_bin:
result = requests.request(method,