handle case where response is None
This commit is contained in:
parent
f1914df700
commit
b402c2c6f2
1 changed files with 11 additions and 9 deletions
|
@ -314,7 +314,7 @@ def send_action(project=None, branch=None, stats=None, key=None, targetFile=None
|
||||||
queue.push(data, plugin)
|
queue.push(data, plugin)
|
||||||
if log.isEnabledFor(logging.DEBUG):
|
if log.isEnabledFor(logging.DEBUG):
|
||||||
log.warn(exception_data)
|
log.warn(exception_data)
|
||||||
if response.getcode() in ALWAYS_LOG_CODES:
|
if response is not None and response.getcode() in ALWAYS_LOG_CODES:
|
||||||
log.error({
|
log.error({
|
||||||
'response_code': response.getcode(),
|
'response_code': response.getcode(),
|
||||||
})
|
})
|
||||||
|
@ -333,35 +333,37 @@ def send_action(project=None, branch=None, stats=None, key=None, targetFile=None
|
||||||
log.error(exception_data)
|
log.error(exception_data)
|
||||||
elif log.isEnabledFor(logging.DEBUG):
|
elif log.isEnabledFor(logging.DEBUG):
|
||||||
log.warn(exception_data)
|
log.warn(exception_data)
|
||||||
if response.getcode() in ALWAYS_LOG_CODES:
|
if response is not None and response.getcode() in ALWAYS_LOG_CODES:
|
||||||
log.error({
|
log.error({
|
||||||
'response_code': response.getcode(),
|
'response_code': response.getcode(),
|
||||||
})
|
})
|
||||||
else:
|
else:
|
||||||
log.error(exception_data)
|
log.error(exception_data)
|
||||||
else:
|
else:
|
||||||
if response.getcode() == 201:
|
if response is not None and response.getcode() == 201:
|
||||||
log.debug({
|
log.debug({
|
||||||
'response_code': response.getcode(),
|
'response_code': response.getcode(),
|
||||||
})
|
})
|
||||||
return True
|
return True
|
||||||
|
response_code = response.getcode() if response is not None else None
|
||||||
|
response_content = response.read() if response is not None else None
|
||||||
if offline:
|
if offline:
|
||||||
queue = Queue()
|
queue = Queue()
|
||||||
queue.push(data, plugin)
|
queue.push(data, plugin)
|
||||||
if log.isEnabledFor(logging.DEBUG):
|
if log.isEnabledFor(logging.DEBUG):
|
||||||
log.warn({
|
log.warn({
|
||||||
'response_code': response.getcode(),
|
'response_code': response_code,
|
||||||
'response_content': response.read(),
|
'response_content': response_content,
|
||||||
})
|
})
|
||||||
else:
|
else:
|
||||||
log.error({
|
log.error({
|
||||||
'response_code': response.getcode(),
|
'response_code': response_code,
|
||||||
'response_content': response.read(),
|
'response_content': response_content,
|
||||||
})
|
})
|
||||||
else:
|
else:
|
||||||
log.error({
|
log.error({
|
||||||
'response_code': response.getcode(),
|
'response_code': response_code,
|
||||||
'response_content': response.read(),
|
'response_content': response_content,
|
||||||
})
|
})
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue