code reduce
This commit is contained in:
parent
b143f34fbf
commit
03ad05bcfb
1 changed files with 11 additions and 14 deletions
|
@ -178,12 +178,10 @@ class DownloadUtils():
|
||||||
|
|
||||||
def getHeader(self, authenticate=True):
|
def getHeader(self, authenticate=True):
|
||||||
|
|
||||||
clientInfo = self.clientInfo
|
deviceName = self.clientInfo.getDeviceName()
|
||||||
|
|
||||||
deviceName = clientInfo.getDeviceName()
|
|
||||||
deviceName = utils.normalize_string(deviceName.encode('utf-8'))
|
deviceName = utils.normalize_string(deviceName.encode('utf-8'))
|
||||||
deviceId = clientInfo.getDeviceId()
|
deviceId = self.clientInfo.getDeviceId()
|
||||||
version = clientInfo.getVersion()
|
version = self.clientInfo.getVersion()
|
||||||
|
|
||||||
if not authenticate:
|
if not authenticate:
|
||||||
# If user is not authenticated
|
# If user is not authenticated
|
||||||
|
@ -222,7 +220,6 @@ class DownloadUtils():
|
||||||
|
|
||||||
self.logMsg("=== ENTER downloadUrl ===", 2)
|
self.logMsg("=== ENTER downloadUrl ===", 2)
|
||||||
|
|
||||||
timeout = self.timeout
|
|
||||||
default_link = ""
|
default_link = ""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -237,11 +234,11 @@ class DownloadUtils():
|
||||||
|
|
||||||
# Prepare request
|
# Prepare request
|
||||||
if type == "GET":
|
if type == "GET":
|
||||||
r = s.get(url, json=postBody, params=parameters, timeout=timeout)
|
r = s.get(url, json=postBody, params=parameters, timeout=self.timeout)
|
||||||
elif type == "POST":
|
elif type == "POST":
|
||||||
r = s.post(url, json=postBody, timeout=timeout)
|
r = s.post(url, json=postBody, timeout=self.timeout)
|
||||||
elif type == "DELETE":
|
elif type == "DELETE":
|
||||||
r = s.delete(url, json=postBody, timeout=timeout)
|
r = s.delete(url, json=postBody, timeout=self.timeout)
|
||||||
|
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
# request session does not exists
|
# request session does not exists
|
||||||
|
@ -269,21 +266,21 @@ class DownloadUtils():
|
||||||
json=postBody,
|
json=postBody,
|
||||||
params=parameters,
|
params=parameters,
|
||||||
headers=header,
|
headers=header,
|
||||||
timeout=timeout,
|
timeout=self.timeout,
|
||||||
verify=verifyssl)
|
verify=verifyssl)
|
||||||
|
|
||||||
elif type == "POST":
|
elif type == "POST":
|
||||||
r = requests.post(url,
|
r = requests.post(url,
|
||||||
json=postBody,
|
json=postBody,
|
||||||
headers=header,
|
headers=header,
|
||||||
timeout=timeout,
|
timeout=self.timeout,
|
||||||
verify=verifyssl)
|
verify=verifyssl)
|
||||||
|
|
||||||
elif type == "DELETE":
|
elif type == "DELETE":
|
||||||
r = requests.delete(url,
|
r = requests.delete(url,
|
||||||
json=postBody,
|
json=postBody,
|
||||||
headers=header,
|
headers=header,
|
||||||
timeout=timeout,
|
timeout=self.timeout,
|
||||||
verify=verifyssl)
|
verify=verifyssl)
|
||||||
|
|
||||||
# If user is not authenticated
|
# If user is not authenticated
|
||||||
|
@ -306,14 +303,14 @@ class DownloadUtils():
|
||||||
json=postBody,
|
json=postBody,
|
||||||
params=parameters,
|
params=parameters,
|
||||||
headers=header,
|
headers=header,
|
||||||
timeout=timeout,
|
timeout=self.timeout,
|
||||||
verify=verifyssl)
|
verify=verifyssl)
|
||||||
|
|
||||||
elif type == "POST":
|
elif type == "POST":
|
||||||
r = requests.post(url,
|
r = requests.post(url,
|
||||||
json=postBody,
|
json=postBody,
|
||||||
headers=header,
|
headers=header,
|
||||||
timeout=timeout,
|
timeout=self.timeout,
|
||||||
verify=verifyssl)
|
verify=verifyssl)
|
||||||
|
|
||||||
##### THE RESPONSE #####
|
##### THE RESPONSE #####
|
||||||
|
|
Loading…
Reference in a new issue