Example #1
0
    def getAvailablePlanes(self, departure_time, arrival_time):
        '''Finds which planes are available at departing and arriving time. Returns list of instances of 
        available planes.'''

        available_tuples_by_time = []
        # value to increase datetime object in each loop
        delta = datetime.timedelta(hours=0.1)

        # list of tuples which show available planes at each time between departure and arrival
        while departure_time <= arrival_time:
            available_tuples_by_time.append(
                AirplaneLL().getAirplanesByDateTime(departure_time))
            departure_time += delta

        all_airplanes = AirplaneLL().getAirplanes()
        not_available_planes_insignia = []
        available_planes = []

        for available_tuple in available_tuples_by_time:
            if available_tuple != None:  # if available tuple is None there are no unavailable planes
                not_available_planes_at_time, available_planes_at_time = available_tuple

                # add unavailable planes to list
                for item in not_available_planes_at_time:
                    if item[0].get_planeInsignia(
                    ) not in not_available_planes_insignia:
                        not_available_planes_insignia.append(
                            item[0].get_planeInsignia())

        # create list af available planes by comparing all planes to unavailable planes
        for plane in all_airplanes:
            if plane.get_planeInsignia() not in not_available_planes_insignia:
                available_planes.append(plane)

        return available_planes
Example #2
0
    def getUpcomingVoyages(self):
        '''Returns a list of instances of all future voyages'''

        # all voyages
        voyage_list = IO_API().loadVoyageFromFile()
        date_today = datetime.date.today()
        upcoming_voyages_list = []

        for voyage in voyage_list:
            # datetime of voyage instance
            voyage_departure_datetime = AirplaneLL(
            ).revertDatetimeStrtoDatetime(voyage.getDepartureTime())
            voyage_departure_date = voyage_departure_datetime.date()
            # if departure of voyage is in the future
            if voyage_departure_date >= date_today:
                upcoming_voyages_list.append(voyage)

        return upcoming_voyages_list
Example #3
0
    def assignFlightNo(self, destination, depart_time):
        '''Assigns a departing and arriving flight number based on a location
        and other trips that day.'''

        # first two letters are dictated by destination
        if destination == 'LYR':
            first_two = '01'
        elif destination == 'GOH':
            first_two = '02'
        elif destination == 'KUS':
            first_two = '03'
        elif destination == 'FAE':
            first_two = '04'
        else:
            first_two = '05'

        # all voyages on departing day
        voyage_list = self.getVoyageInDateRange(depart_time, depart_time)

        # if no voyages are on the departing day
        latter_two_depart = '00'
        latter_two_arrive = '01'

        for voyage_instance in voyage_list:

            voyage_instance_depart_time = AirplaneLL(
            ).revertDatetimeStrtoDatetime(voyage_instance.getDepartureTime())
            # if the dest IATA code matches the voyage in file there is another voyage to
            # the same destination on the same day
            if destination == voyage_instance.getDestination(
            ).getDestinationAirport():
                if depart_time >= voyage_instance_depart_time:
                    # flight numbers of registered voyage:
                    depart_num, arrival_num = voyage_instance.getFlightNumbers(
                    )

                    # if the registered voyage has higher numbers
                    if latter_two_depart <= depart_num[-2:]:
                        latter_two_depart = str(int(depart_num[-2:]) + 2)
                        latter_two_arrive = str(int(arrival_num[-2:]) + 2)
                    # int() removes the zero so it is added back in
                    if len(latter_two_depart) == 1:
                        latter_two_depart = '0' + latter_two_depart
                        latter_two_arrive = '0' + latter_two_arrive
                else:
                    # change flight number of old voyage
                    self.changeFlightNo(voyage_instance)
                    departing_num, arriving_num = voyage_instance.getFlightNumbers(
                    )

        departing_num = 'NA' + first_two + latter_two_depart
        arriving_num = 'NA' + first_two + latter_two_arrive

        return departing_num, arriving_num
Example #4
0
    def getVoyageStatus(self, voyage_instance):
        '''Takes a voyage instance and checks its status based on current time. A string describing 
        the status is returned.'''

        time_now_datetime = datetime.datetime.now()

        # departing and arriving time of flight at KEF
        voyage_depart_time_home_str = voyage_instance.getDepartureTime()
        voyage_arrive_time_home_str = voyage_instance.getArrivalTimeHome()

        # departing and arriving time of flight at destination
        voyage_arrive_time_out_str = voyage_instance.getArrivalTimeOut()
        voyage_depart_time_out_str = voyage_instance.getDepartureTimeAtDestination(
        )

        # Turn depart and arrive time string into a datetime value
        voyage_depart_home_datetime = AirplaneLL().revertDatetimeStrtoDatetime(
            voyage_depart_time_home_str)
        voyage_arrive_home_datetime = AirplaneLL().revertDatetimeStrtoDatetime(
            voyage_depart_time_home_str)

        voyage_depart_out_datetime = AirplaneLL().revertDatetimeStrtoDatetime(
            voyage_depart_time_out_str)
        voyage_arrive_out_datetime = AirplaneLL().revertDatetimeStrtoDatetime(
            voyage_depart_time_out_str)

        # if voyage departed before current time
        if time_now_datetime < voyage_depart_home_datetime:
            status_str = 'Not departed'
        # if voyage departed before current time but has not yet arrived out OR if it has departed back home and hasnt arrived
        elif (time_now_datetime >= voyage_depart_home_datetime and time_now_datetime < voyage_arrive_out_datetime)\
            or (time_now_datetime >= voyage_depart_out_datetime and time_now_datetime < voyage_arrive_home_datetime):
            status_str = 'In air'
        # if voyage has landed in destination but not departed back
        elif time_now_datetime >= voyage_arrive_out_datetime and time_now_datetime < voyage_depart_out_datetime:
            status_str = 'At destination'
        # if voyage has arrived
        else:
            status_str = 'Completed'

        return status_str
Example #5
0
    def startDisplayMenuWorkingCrew(self):
        '''Menu for displaying working/nonworking crew'''
        while True:

            print('\nWhat would you like to display?')
            print('-' * 45)
            print('1 - Working crew on a specific day')
            print('2 - Nonworking crew on a specific day')
            print('m - Back to main menu')
            print()

            selection = input('Please choose one of the above: ').strip()
            print()

            if selection == '1' or selection == '2':
                print('Enter the date you want to display')
                year_str = input('Year: ').strip()
                month_str = input('Month: ').strip()
                day_str = input('Day: ').strip()

                #verifies if the date is correct
                year_int, month_int, day_int = AirplaneLL().verifyDate(
                    year_str, month_str, day_str)

                # creates datetime object from input
                date_datetime = datetime.datetime(year_int, month_int, day_int,
                                                  0, 0, 0).isoformat()

            if selection == '1':
                # goes to menu to show working crew on specific day
                return CrewUI().showWorkingCrew(date_datetime)

            elif selection == '2':
                # goes to menu to show nonworking crew on specific day
                return CrewUI().showNotWorkingCrew(date_datetime)

            elif selection == 'm':
                # goes back to main menu
                return

            else:
                print('Invalid selection')
Example #6
0
 def showAllPlanes(self):
     '''Returns a list of airplane instances'''
     return AirplaneLL().getAirplanes()
Example #7
0
 def showAirplaneTypes(self):
     '''Returns a dictionary with airplane types as keys
     and number of pilots with license
     on that type as value'''
     return AirplaneLL().getNumberOfPilotsWithLicense()
Example #8
0
 def getAirplaneInsigniaList(self):
     '''Returns a list of all airplane insignias.'''
     return AirplaneLL().getAirplaneInsigniaList()
Example #9
0
 def revertDatetimeStrtoDatetime(self, datetime_str):
     '''Takes in a datetime string and returns a datetime object'''
     return AirplaneLL().revertDatetimeStrtoDatetime(datetime_str)
Example #10
0
 def addAirplane(self, planeInsignia, planeTypeID, manufacturer, seats):
     ''' Sends info for new airplane to be added'''
     return AirplaneLL().addAirplane(planeInsignia, planeTypeID,
                                     manufacturer, seats)
Example #11
0
 def addAirplaneType(self,planeTypeId,manufacturer,model,capacity,\
         emptyWeight,maxTakeoffWeight,unitThrust,serviceCeiling,length,height,wingspan):
     '''Adds an airplane'''
     return AirplaneLL().addAirplaneType(planeTypeId,manufacturer,model,capacity,\
         emptyWeight,maxTakeoffWeight,unitThrust,serviceCeiling,length,height,wingspan)
Example #12
0
 def verifyDate(self, year_str, month_str, day_str):
     '''Checks if date is valid. If it is not valid, 
     it will ask user to input another date.'''
     return AirplaneLL().verifyDate(year_str, month_str, day_str)
Example #13
0
 def verifyTime(self, hour_str, minute_str):
     '''Checks if time is valid. If it is not valid, 
     it will ask user to input another time.'''
     return AirplaneLL().verifyTime(hour_str, minute_str)
Example #14
0
 def __init__(self):
     self.staffObject = StaffLL()
     self.airplaneObject = AirplaneLL()
     self.destinationObject = DestinationLL()
     self.voyageObject = VoyageLL()
Example #15
0
 def showAirplanesByDateTime(self, date_str):
     '''Returns a tuple of lists of instances. First tuple 
     is planes that are not available,
     the second is planes that are available at the time
     inputted by user.'''
     return AirplaneLL().getAirplanesByDateTime(date_str)
Example #16
0
 def showAirplanesByType(self, planeTypeId=''):
     '''Returns a list of airplane instances that have a type inputted by user'''
     return AirplaneLL().getAirplanesByType(planeTypeId)
Example #17
0
 def loadAirplaneTypes(self):
     return AirplaneLL().loadAirplaneTypes()
Example #18
0
 def getAirplaneTypes(self):
     return AirplaneLL().getAirplaneTypes()
Example #19
0
 def getAirplanebyInsignia(self, planeInsignia):
     '''Returns an airplane instance 
     with the input planeinsignia'''
     return AirplaneLL().getAirplanebyInsignia(planeInsignia)
Example #20
0
class MainLL:
    '''Instances of all sub LL classes created so that MainLL has access to all
       functions within them. The MainLL class functionality is only to be the link 
       between the UI layer and appropriate LL classes. Therefore the MainLL class
       is only function calls'''
    def __init__(self):
        self.staffObject = StaffLL()
        self.airplaneObject = AirplaneLL()
        self.destinationObject = DestinationLL()
        self.voyageObject = VoyageLL()

    def getAllStaffLL(self):
        return self.staffObject.getAllStaff()

    def getStaffByIDLL(self, ssn):
        return self.staffObject.getStaffByID(ssn)

    def getAirplanesLL(self):
        return self.airplaneObject.getAirplanes()

    def getAirplaneByIdLL(self, ID):
        return self.airplaneObject.getAirplaneByID(ID)

    def getVoyageLL(self):
        return self.voyageObject.listVoyage()

    def getAllPilotsLL(self):
        return self.staffObject.getAllPilots()

    def getLicenseDictLL(self):
        return self.airplaneObject.getLicenseDict()

    def getAllCabinCrewLL(self):
        return self.staffObject.getAllCabinCrew()

    def addAirplaneLL(self, newAirplane):
        return self.airplaneObject.addAirplane(newAirplane)

    def getAirplaneStatusLL(self, date, time):
        return self.airplaneObject.getAirplaneStatus(date, time)

    def getStaffDataLL(self, dataList):
        return self.staffObject.getStaffData(dataList)

    def addNewStaffLL(self, newEmployee):
        return self.staffObject.addNewStaff(newEmployee)

    def getAllDestinationsLL(self):
        return self.destinationObject.getDestination()

    def addNewDestinationLL(self, newDestination):
        return self.destinationObject.addNewDestination(newDestination)

    def addNewVoyageLL(self, newFlight):
        return self.voyageObject.addVoyages(newFlight)

    def updateVoyageLL(self, dataList, staffList):
        return self.voyageObject.updateVoyage(dataList, staffList)

    def updateDestinationLL(self, dataList):
        return self.destinationObject.updateDestination(dataList)

    def addLicenseLL(self, dataList):
        return self.airplaneObject.addLicense(dataList)

    def workScheduleLL(self, workDay):
        return self.staffObject.getWorkSchedule(workDay)

    def workScheduleAvailableLL(self, workDay):
        return self.staffObject.getWorkSchedlueAvailable(workDay)

    def generateFlightNumberLL(self, flight):
        return self.voyageObject.generateFlightNumber(flight)

    def availableDatesLL(self):
        return self.voyageObject.availableDates()

    def workWeekLL(self, dataList):
        return self.voyageObject.getWorkWeek(dataList)

    def getAvailableFlightAttendantsLL(self, flight):
        return self.voyageObject.findAvailableFlightAttendants(flight)

    def getAvailableFlightServiceManagersLL(self, flight):
        return self.voyageObject.findAvailableFlightServiceManagers(flight)

    def getAvailableCoPilotsLL(self, flight):
        return self.voyageObject.findAvailableCoPilots(flight)

    def getAvailableCaptainsLL(self, flight):
        return self.voyageObject.findAvailableCaptains(flight)

    def errorCheckDateLL(self, flight):
        return self.voyageObject.errorCheckDate(flight)

    def flightCollisionLL(self, flight):
        return self.voyageObject.flightCollision(flight)

    def findArrivalTimeLL(self, flight):
        return self.voyageObject.findArrivalTime(flight)

    def findAvalibleAirplanesLL(self, flight):
        return self.voyageObject.findAvalibleAirplanes(flight)

    def generateSecondFlightLL(self, flight):
        return self.voyageObject.generateSecondFlight(flight)

    def generadeDestinationIdLL(self):
        return self.destinationObject.generadeDestinationId()