Пример #1
0
    def get_flight_from_old_voyages(old_voyages_list):
        """ Takes in a list of old voyages objects and returns a list of flights """

        flights_list = []
        for old_voyage in old_voyages_list:
            # Flight 1
            flight_1 = Flight(old_voyage.flight_1_number, old_voyage.plane_str, "BIRK", old_voyage.destination_str, \
                 Date_parser.date_parser(old_voyage.departure_1_time), Date_parser.date_parser(old_voyage.arrival_1_time), old_voyage.employees_string_list)
            # Flight 2
            flight_2 = Flight(old_voyage.flight_2_number, old_voyage.plane_str, old_voyage.destination_str, "BIRK", \
                Date_parser.date_parser(old_voyage.departure_2_time), Date_parser.date_parser(old_voyage.arrival_2_time), old_voyage.employees_string_list)
            flights_list.append((flight_1, flight_2))

        return flights_list
Пример #2
0
    def create_old_voyage(voyage):
        """ Takes in a Voayge object and returns an old voyage object """

        # Variables for Old_Voyage object
        destination = Voyage_LL.get_destination_by_id(
            voyage.get_destination_id())
        departure_1_time, arrival_1_time, departure_2_time, arrival_2_time = \
            Date_parser.get_arrival_times(voyage.get_departure_time().isoformat(timespec="seconds"), destination.get_flight_time())
        # Check if voyage has an airplane assigned
        if voyage.get_aircraft_id() != None:
            aircraft = Voyage_LL.get_aircraft_by_id(voyage.get_aircraft_id())
            aircraft_str = aircraft.get_name()
        else:
            aircraft_str = "None"
        destination_str = destination.code
        unique_id = voyage.get_id()
        flight_1_number, flight_2_number = voyage.flight1_number, voyage.flight2_number
        employees_list = Voyage_LL.get_employees_list(
            voyage.get_employee_ids())

        # Create Old_Voyage object
        old_voyage = Old_Voyage(aircraft_str, destination_str, \
            departure_1_time.isoformat(), arrival_1_time.isoformat(), \
            departure_2_time.isoformat(), arrival_2_time.isoformat(), flight_1_number, flight_2_number, \
            unique_id, employees_list)

        return old_voyage
Пример #3
0
 def __get_arrival_day_of_voyage(voyage):
     destination = Voyage_LL.get_destination_by_id(
         voyage.get_destination_id())
     arrival_day = Date_parser.get_arrival_times(
         str(voyage.get_departure_time()),
         str(destination.get_flight_time()))[3]
     arrival_day = datetime.datetime(arrival_day.year, arrival_day.month,
                                     arrival_day.day)
     return arrival_day
Пример #4
0
 def __init__(self, aircraft_id, destination_id, departure_time,
              flight1_number, flight2_number, employee_ids, manned_bool,
              id_int):
     self.aircraft_id = aircraft_id
     self.destination_id = destination_id
     self.departure_time = Date_parser.date_parser(departure_time)
     self.flight1_number = flight1_number
     self.flight2_number = flight2_number
     self.employee_ids = employee_ids
     self.manned_bool = manned_bool
     self.id_int = id_int
Пример #5
0
    def check_if_voyage_complete(voyage):
        """ Checks if a voyage is complete or not. Returns true if it is complete and None otherwise """

        destination = Voyage_LL.get_destination_by_id(
            voyage.get_destination_id())
        departure_time = voyage.get_departure_time().isoformat(
            timespec="seconds")
        dep, arr, dep_2, arr_2 = Date_parser.get_arrival_times(
            departure_time, destination.get_flight_time())
        if arr_2 < datetime.datetime.now():
            return True
        return False
Пример #6
0
    def get_aircraft_status(aircraft_id, time_to_find):
        """ Takes in an aircraft id and returns its status. If it is unavailable then returns time when it will be available """

        time_to_find = Date_parser.date_parser(time_to_find)
        status = "Available"
        flight_info = "N/A"
        voyages_list = Aircraft_LL.get_voyages(aircraft_id)
        for voyage in voyages_list:
            destination = Voyage_LL.get_destination_by_id(
                voyage.get_destination_id())
            time_to_dest_str = destination.get_flight_time()
            departure_time, arrival_time, departure_2_time, arrival_2_time = Date_parser.get_arrival_times(
                str(voyage.get_departure_time()), time_to_dest_str)

            if departure_time <= time_to_find <= arrival_2_time:
                status = "Available on: " + str(arrival_2_time)
                if departure_time <= time_to_find <= arrival_time:
                    flight_info = voyage.flight1_number + " to " + destination.get_airport(
                    )
                elif departure_2_time <= time_to_find <= arrival_2_time:
                    flight_info = voyage.flight2_number + " to BIRK"

        return status, flight_info
Пример #7
0
 def get_all_times(voyage):
     """ Returns a tuple of 4 values. Departure times and arrival times of both flights from voyage """
     destination = Voyage_LL.get_destination_by_id(
         voyage.get_destination_id())
     return Date_parser.get_arrival_times(voyage.get_departure_time_str(),
                                          destination.get_flight_time())
Пример #8
0
    def get_info(voyage):
        if voyage.get_aircraft_id() is not None:
            aircraft = Voyage_LL.get_aircraft_by_id(voyage.get_aircraft_id())
        else:
            aircraft = None

        destination = Voyage_LL.get_destination_by_id(
            voyage.get_destination_id())
        employees = []
        for employee_id in voyage.get_employee_ids():
            employees += [Voyage_LL.get_employee_by_id(employee_id)]

        pilots = []
        cabin_crew = []
        for employee in employees:
            if employee.get_job() == "pilot":
                pilots += [employee]
            elif employee.get_job() == "cabin_crew":
                cabin_crew += [employee]

        departure_time = voyage.get_departure_time()
        if aircraft is not None:
            aircraft_name = aircraft.get_name()
            aircraft_model = aircraft.get_model()
        else:
            aircraft_name = "None"
            aircraft_model = "None"
        destination_airport = destination.get_airport()
        destination_code = destination.get_code()
        destination_flight_time = destination.get_flight_time()
        departure_time, arrival_time, departure_2_time, arrival_2_time = Date_parser.get_arrival_times(
            str(departure_time), destination_flight_time)
        destination_dist_from_birk = destination.get_dist_from_birk() + " km"


        detailed_info = \
            [
                ["FLIGHT 1", None, 1],
                ["FLIGHT NUMBER", voyage.flight1_number, 2],
                ["DESTINATION", "{} ({})".format(destination_code, destination_airport), 2],
                ["DEPARTURE", "BIRK (Reykjavik)", 2],
                ["DEPARTURE TIME", str(departure_time), 2],
                ["ARRIVAL TIME", str(arrival_time), 2],
                ["DISTANCE", destination_dist_from_birk, 2],
                ["FLIGHT 2", None, 1],
                ["FLIGHT NUMBER", voyage.flight2_number, 2],
                ["DESTINATION", "BIRK (Reykjavik)", 2],
                ["DEPARTURE", "{} ({})".format(destination_code, destination_airport), 2],
                ["DEPARTURE TIME", str(departure_2_time), 2],
                ["ARRIVAL TIME", str(arrival_2_time), 2],
                ["DISTANCE", destination_dist_from_birk, 2],
                ["AIRCRAFT NAME", aircraft_name, 1],
                ["AIRCRAFT MODEL", aircraft_model, 1],
            ]
        detailed_info += [["PILOTS", None, 1]]
        for pilot in pilots:
            detailed_info += [[pilot.get_rank(), pilot.get_name(), 2]]
        detailed_info += [["CABIN CREW:", None, 1]]
        for cc in cabin_crew:
            detailed_info += [[cc.get_rank(), cc.get_name(), 2]]
        return detailed_info
Пример #9
0
 def get_departure_time(self):
     return Date_parser.date_parser(self.departure_1_time)