import datetime
import os

from alice_check_train.main import rasp_to_text
from alice_check_train.rasp_api import get_rasp, filter_rasp


def main():
    key = os.getenv('RASP_KEY')
    station_from = os.getenv('STATION_FROM')
    station_to = os.getenv('STATION_TO')
    date = datetime.date.today().strftime('%Y-%m-%d')

    js = get_rasp(key, station_from, station_to, date)
    filtered = filter_rasp(js['segments'], 300)
    message = rasp_to_text(filtered, 1000)
    if len(message) > 1024:
        print('Too long message: {} > 1024'.format(len(message)))
    print(message)


if __name__ == '__main__':
    main()

[(9, 'os.getenv', 'os.getenv', False, 'import os\n'), (10, 'os.getenv', 'os.getenv', False, 'import os\n'), (11, 'os.getenv', 'os.getenv', False, 'import os\n'), (14, 'alice_check_train.rasp_api.get_rasp', 'get_rasp', False, 'from alice_check_train.rasp_api import get_rasp, filter_rasp\n'), (15, 'alice_check_train.rasp_api.filter_rasp', 'filter_rasp', False, 'from alice_check_train.rasp_api import get_rasp, filter_rasp\n'), (16, 'alice_check_train.main.rasp_to_text', 'rasp_to_text', False, 'from alice_check_train.main import rasp_to_text\n'), (12, 'datetime.date.today', 'datetime.date.today', False, 'import datetime\n')]