def authenticate_with_server():
    http_session = requests.session()
    http_session.get(LOGIN_PAGE, headers=HEADER)
    data = {"pseudo": USERNAME, "passe": PASSWORD, "souvenir": 1}
    http_session.post(POST_LOGIN_PAGE, data, headers=HEADER)
    logger.warning('LOGIN')
    save_session_in_cache(http_session)
    save_session_to_db()
    return http_session
Beispiel #2
0
def view_generic(_, view_name):
    """ First parameter request is not used. Replaced by _ for sonar """
    requested_view = 'view_{}()'.format(view_name)
    action_url = 'Requested view: {}'.format(requested_view)
    try:
        logger.info(action_url)
        eval(requested_view)
        logger.info('Successful')
    except Exception as e:
        exception_text = traceback.format_exc()
        logger.error(exception_text)
        notify('FM: Exception', 'Exception:\n{}'.format(exception_text))
        raise e
    finally:
        save_session_to_db()
    return HttpResponse('started')