@app.route('/status', methods=['GET'])
def status():
    '\n    Runs smoke tests and reports status\n    '
    try:
        job_queue_length = len(q.jobs)
    except ConnectionError:
        job_queue_length = (- 1)
    status = {'tool': 'Quiz Extensions', 'checks': {'index': False, 'xml': False, 'api_key': False, 'redis': False, 'db': False, 'worker': False}, 'url': url_for('index', _external=True), 'api_url': config.API_URL, 'debug': app.debug, 'xml_url': url_for('xml', _external=True), 'job_queue': job_queue_length}
    try:
        response = requests.get(url_for('index', _external=True), verify=False)
        status['checks']['index'] = (response.text == 'Please contact your System Administrator.')
    except Exception:
        logger.exception('Index check failed.')
    try:
        response = requests.get(url_for('xml', _external=True), verify=False)
        status['checks']['xml'] = ('application/xml' in response.headers.get('Content-Type'))
    except Exception:
        logger.exception('XML check failed.')
    try:
        response = requests.get('{}users/self'.format(config.API_URL), headers={'Authorization': ('Bearer ' + config.API_KEY)})
        status['checks']['api_key'] = (response.status_code == 200)
    except Exception:
        logger.exception('API Key check failed.')
    try:
        response = conn.echo('test')
        status['checks']['redis'] = (response == b'test')
    except ConnectionError:
        logger.exception('Redis connection failed.')
    try:
        db.session.query(text('1')).all()
        status['checks']['db'] = True
    except Exception:
        logger.exception('DB connection failed.')
    status['checks']['worker'] = (call('ps aux | grep "rq worker" | grep "quizext" | grep -v grep', shell=True) == 0)
    status['healthy'] = all(((v is True) for (k, v) in status['checks'].items()))
    return Response(json.dumps(status), mimetype='application/json')
Runs smoke tests and reports status
@app.route('/status', methods=['GET'])
def status():
    '\n    \n    '
    try:
        job_queue_length = len(q.jobs)
    except ConnectionError:
        job_queue_length = (- 1)
    status = {'tool': 'Quiz Extensions', 'checks': {'index': False, 'xml': False, 'api_key': False, 'redis': False, 'db': False, 'worker': False}, 'url': url_for('index', _external=True), 'api_url': config.API_URL, 'debug': app.debug, 'xml_url': url_for('xml', _external=True), 'job_queue': job_queue_length}
    try:
        response = requests.get(url_for('index', _external=True), verify=False)
        status['checks']['index'] = (response.text == 'Please contact your System Administrator.')
    except Exception:
        logger.exception('Index check failed.')
    try:
        response = requests.get(url_for('xml', _external=True), verify=False)
        status['checks']['xml'] = ('application/xml' in response.headers.get('Content-Type'))
    except Exception:
        logger.exception('XML check failed.')
    try:
        response = requests.get('{}users/self'.format(config.API_URL), headers={'Authorization': ('Bearer ' + config.API_KEY)})
        status['checks']['api_key'] = (response.status_code == 200)
    except Exception:
        logger.exception('API Key check failed.')
    try:
        response = conn.echo('test')
        status['checks']['redis'] = (response == b'test')
    except ConnectionError:
        logger.exception('Redis connection failed.')
    try:
        db.session.query(text('1')).all()
        status['checks']['db'] = True
    except Exception:
        logger.exception('DB connection failed.')
    status['checks']['worker'] = (call('ps aux | grep "rq worker" | grep "quizext" | grep -v grep', shell=True) == 0)
    status['healthy'] = all(((v is True) for (k, v) in status['checks'].items()))
    return Response(json.dumps(status), mimetype='application/json')