accept 201 or 202 response codes as success from api

This commit is contained in:
Alan Hamlett 2016-01-11 02:13:58 -08:00
parent 88e253d164
commit 85cecd6280
2 changed files with 3 additions and 2 deletions

View file

@ -1,5 +1,5 @@
Traceback (most recent call last): Traceback (most recent call last):
File "{file}", line 229, in parseArguments File "{file}", line 230, in parseArguments
args.timeout = int(configs.get('settings', 'timeout')) args.timeout = int(configs.get('settings', 'timeout'))
ValueError: invalid literal for int() with base 10: 'abc' ValueError: invalid literal for int() with base 10: 'abc'

View file

@ -34,6 +34,7 @@ from .constants import SUCCESS, API_ERROR, CONFIG_FILE_PARSE_ERROR
from .logger import setup_logging from .logger import setup_logging
from .offlinequeue import Queue from .offlinequeue import Queue
from .packages import argparse from .packages import argparse
from .packages import requests
from .packages.requests.exceptions import RequestException from .packages.requests.exceptions import RequestException
from .project import get_project_info from .project import get_project_info
from .session_cache import SessionCache from .session_cache import SessionCache
@ -369,7 +370,7 @@ def send_heartbeat(project=None, branch=None, hostname=None, stats={}, key=None,
else: else:
response_code = response.status_code if response is not None else None response_code = response.status_code if response is not None else None
response_content = response.text if response is not None else None response_content = response.text if response is not None else None
if response_code == 201: if response_code == requests.codes.created or response_code == requests.codes.accepted:
log.debug({ log.debug({
'response_code': response_code, 'response_code': response_code,
}) })