コード例 #1
0
def do_job(api_key):
    """
    Gets a job from the server and handles the job based on the type of job
    """
    try:
        LOGGER.info('Getting job from server...')
        job = requests.get('http://capstone.cs.moravian.edu:5000/get_job')
        job = job.json()
        LOGGER.info("Job has been acquired")

    except Exception:
        LOGGER.error("A connection error has occurred")
        raise NoConnectionError

    results = handle_specific_job(job, api_key)

    if results is None:
        return

    post_job(results)
コード例 #2
0
def check_status(status_code):
    if status_code == 400:
        LOGGER.error('The given ID is incorrect')
        raise reggov_api_doc_error.IncorrectIDPatternException
    if status_code == 403:
        LOGGER.error('The given API key is incorrect')
        raise reggov_api_doc_error.IncorrectApiKeyException
    if status_code == 404:
        LOGGER.error('The given Doc ID was bad')
        raise reggov_api_doc_error.BadDocIDException
    if status_code == 429:
        LOGGER.error('The 1000 call an hour limit has been exceeded')
        raise reggov_api_doc_error.ExceedCallLimitException