Beispiel #1
0
def navigate_between(source_name, destination_name):
    starting_destination_id = get_id_of_station(source_name)
    #print(starting_destination_id)

    destination_station_id = get_id_of_station(destination_name)
    #print(destination_station_id)

    return mvg_api.get_route(starting_destination_id, destination_station_id)
Beispiel #2
0
def get_mvv_duration(start, destination, date):
    td = 0
    try:
        route = mvg_api.get_route((start.x, start.y), (destination.x, destination.y), time=date)
        if (len(route) >= 1):
            arrival = route[0]['arrival_datetime']
            departure = route[0]['departure_datetime']
            td = divide((arrival - departure).seconds, 60)
        return {"price": 3.3, "duration": td}
    except:
        return None
Beispiel #3
0
def test(_start: str, _dest: str):
    now = datetime.now()
    # for debug proposes
    # now = datetime(2020, 3, 30, 17, 25, 0, 0)
    test_start = mvg_api.get_id_for_station(_start)
    test_dest = mvg_api.get_id_for_station(_dest)
    print("ID test_start: ", test_start)
    print("ID test_dest: ", test_dest)
    print("\n")
    routes = mvg_api.get_route(test_start, test_dest, now)
    for e in routes:
        print(e)
        print_route(e)
        print("\n")
    return
Beispiel #4
0
def main():
    start = "de:09162:9"  # Laim
    dest = "de:09178:2680"  # Freising
    connections = mvg_api.get_route(start, dest)

    for connection in connections:
        departure = connection["departure"]
        arrival = connection["arrival"]
        print("{}min".format(round((arrival - departure) / 1000 / 60), ))

        for part in connection["connectionPartList"]:
            line = "{}+{} -> {}+{} ".format(
                time_of_day(part["departure"]),
                part.get("delay", 0),
                time_of_day(part["arrival"]),
                part.get("arrDelay", 0),
            )

            if part["connectionPartType"] == "FOOTWAY":
                line += "Footway"
            else:
                line += "[{}] {} {} ({})".format(
                    part["departurePlatform"],
                    part["product"],
                    part["label"],
                    part["destination"],
                )

            if part["cancelled"]:
                line = "CANCELLED! " + line

            if part["sev"]:
                line = "SEV!!! " + line

            print(line)

            for nt in part.get("notifications", []):
                if any(l["lineNumber"] == part["label"] for l in nt["lines"]):
                    print("  NOTE: " + nt["title"])

        print()
Beispiel #5
0
def get_next_departures() -> List[MyEntry]:
    Logger.info("Model.get_next_departures: started")
    _now = datetime.now()
    # _now = datetime(2020, 3, 31, 16, 15, 0, 0)
    _list: List[MyEntry] = []
    try:
        _start = mvg_api.get_id_for_station(start_str)
        _dest = mvg_api.get_id_for_station(destination_str)
        if _start is None or _dest is None:
            raise ValueError('Route nicht definiert.', _start, _dest)
        _routes = mvg_api.get_route(_start, _dest, _now)
        for c in range(amount):
            _list.append(process_route(_routes[c]))
        Logger.info("Model.get_next_departures: normal fetch")

    except requests.exceptions.ConnectionError:
        Logger.info("Model.get_next_departures: Connectionerror")
        # error entry
        _error_entry: MyEntry = MyEntry()
        _error_entry.img_ok_path = res_path + ok_path + resources_dict.get(
            "WARNING") + ok_ext
        _error_entry.img_N_path = res_path + notification_path + resources_dict.get(
            "WARNING") + notification_ext
        _error_entry.label = 'Verbindungsfehler'
        _error_entry.destination = '.'
        # help entry
        _help_entry: MyEntry = MyEntry()
        _help_entry.img_ok_path = res_path + ok_path + resources_dict.get(
            "WARNING") + ok_ext
        _help_entry.img_N_path = res_path + notification_path + resources_dict.get(
            "WARNING") + notification_ext
        _help_entry.destination = '.'
        _help_entry.label = 'WLAN überprüfen'
        # append
        _list.append(_error_entry)
        _list.append(_help_entry)
    except ValueError as verror:
        Logger.info("Model.get_next_departures: Valueerror")
        # error entry
        _error_entry: MyEntry = MyEntry()
        _error_entry.img_ok_path = res_path + ok_path + resources_dict.get(
            "WARNING") + ok_ext
        _error_entry.img_N_path = res_path + notification_path + resources_dict.get(
            "WARNING") + notification_ext
        _error_entry.destination = '!'
        if verror.args[1] is None:
            _error_entry.label = 'Startort unbekannt'
        elif verror.args[2] is None:
            _error_entry.label = 'Zielort unbekannt'
        # help entry
        _help_entry: MyEntry = MyEntry()
        _help_entry.img_ok_path = res_path + ok_path + resources_dict.get(
            "WARNING") + ok_ext
        _help_entry.img_N_path = res_path + notification_path + resources_dict.get(
            "WARNING") + notification_ext
        _help_entry.destination = '!'
        _help_entry.label = 'Überprüfe die Einstellungen'
        # append
        _list.append(_error_entry)
        _list.append(_help_entry)
    finally:
        Logger.info("Model.get_next_departures: finished!")
        return _list
Beispiel #6
0
station_id_from = station_data_from[0]['id']
station_to = input("Enter Destination : ")
station_data_to = mvg.get_stations(station_to)  # Feldmoching   Frankfurter Ring Scheidplatz
station_id_to = station_data_to[0]['id']

#print (station_id_from)
#print (station_id_to)
route_data = mvg.get_route(station_id_from, station_id_to)

#print(route_data[0]['ringFrom'])
#print(route_data[0]['ringTo'])
print (route_data)

print('You have to travel from Ring: ' + str(route_data[0]['ringFrom']) + ' to Ring: ' + str(route_data[0]['ringTo']))
'''

new_list_stations = []
idss = mvg.get_stations('')
for station in idss:
    #print(station)
    id = station['id']
    name = station['name']
    new_idss = {'id': id, 'name': name}
    print(new_idss)

    new_list_stations.append(new_idss)

start_station = 1110
for station in new_list_stations:
    mvg.get_route(start_station, station['id'])
Beispiel #7
0
    index += 1

print(route[8]['ringFrom'])'''

station_from = input("Enter Origin : ")
station_data_from = mvg.get_stations(
    station_from)  #'Karlsplatz (Stachus)' Isartor Marienplatz
station_id_from = station_data_from[0]['id']
station_to = input("Enter Destination : ")
station_data_to = mvg.get_stations(
    station_to)  # Feldmoching   Frankfurter Ring Scheidplatz
station_id_to = station_data_to[0]['id']

print(station_id_from)
print(station_id_to)
route_data = mvg.get_route(station_id_from, station_id_to)

print(route_data[0]['ringFrom'])
#print(route_data[0]['ringTo'])
print(route_data)

print('You have to travel from Ring: ' + str(route_data[0]['ringFrom']) +
      ' to Ring: ' + str(route_data[0]['ringTo']))
'''

new_list_stations = []
idss = mvg.get_stations('')
for station in idss:
    #print(station)
    id = station['id']
    name = station['name']