Пример #1
0
def main():
    # entry point, create global event loop
    loop = asyncio.get_event_loop()

    # fetch query along with other settings
    settings = get_user_settings()
    seed_query = parse_query(settings["seed"])

    # retry until there is something to filter
    while len(seed_query) == 0:
        logging.info("no seed input, waiting for user setting")
        time.sleep(10)

        settings = get_user_settings()
        seed_query = parse_query(settings["seed"])

    # get stream
    del settings["seed"]
    listener, stream = get_stream(**settings)

    # start streaming
    try:
        stream.filter(track=seed_query, languages=['en'])
    except Exception as e:
        logging.exception("exception fall through all catches, closing loop")
    finally:
        loop.close()
Пример #2
0
def setup():
    # fetch query along with other settings
    settings = get_user_settings()

    # get tracking query
    seed_query = parse_query("seed", settings)
    pinned_query = parse_query("pinned", settings)
    query = seed_query + pinned_query

    # get side spec
    user_query = parse_query("user", settings)
    location_query = parse_query("location", settings)

    # format input
    query = seed_query + pinned_query + user_query + location_query
    query_dict = {
        'track': seed_query + pinned_query,
        'follow': user_query,
        'locations': location_query
    }
    query_dict = {k:v for k,v in query_dict.items() if len(v) > 0}

    # get stream
    stream = get_stream(
        consumerKey=settings["consumerKey"],
        consumerSecret=settings["consumerSecret"],
        accessToken=settings["accessToken"],
        accessTokenSecret=settings["accessTokenSecret"]
    )

    # delete information from RAM
    del settings
    return query_dict, stream
Пример #3
0
def config_ini_save():
    user_settings = get_user_settings(loop=loop)
    set_user_settings(
        {
            setting_key: request.args.get(setting_key, default="", type=str)
            for setting_key in user_settings.keys()
        },
        loop=loop)

    subprocess.run("circusctl restart python3 &", shell=True)
    return "All quiet on the western front"
Пример #4
0
def config_ini_save():
    token = request.headers.get("X-CSRFToken")
    validate_csrf(token)
    user_settings = get_user_settings()
    set_user_settings({
        setting_key : request.args.get(setting_key, default="", type=str).strip()
        for setting_key in user_settings.keys()
    })

    subprocess.run("circusctl restart python3 &", shell=True)
    return "All quiet on the western front"
Пример #5
0
def jsonify_user_settings():
    output = jsonify(get_user_settings(loop=loop))
    return output