Beispiel #1
0
    def SetCabinCrew(self):
        ''' set new cabin crew '''
        ssn = input('Social security number: ')
        valid_ssn = LL_API().checkIfValidssn(ssn)
        if valid_ssn == None:
            print(":: Not a valid social security number ::")
        else:
            name = input('Full name: ').title()
            firstname = name.split()
            role = 'Cabincrew'
            print("\n{:^44}".format('Choose rank'))
            print("."*44) 
            print("1: Flight Attendant")
            print("2: Flight Service Manager")
            print("_"*44)
            rank_input = int(input('Rank: '))   
            if rank_input == 1:
                rank = "Flight Attendant"
            elif rank_input == 2:
                rank = "Flight Service Manager"
            pilot_license = 'N/A'
            address = input('Address: ')
            try:
                phone = int(input('Phone: '))
            except ValueError:
                print("\n:: Invalid phone ::\n")
                phone = input('Phone: ')
            email = firstname[0] + "@nan.is"

            employee = Model_Employee(ssn, name, role, rank, pilot_license, address, phone, email)
            LL_API().createEmployee(employee)
        
            print("\n:: {} has been added to Cabin crew ::".format(name))
Beispiel #2
0
 def listPilots(self):
     ''' prints all pilots '''
     pilot_list = LL_API().get_Pilots()
     print("{:^44}".format('All pilots'))
     print("."*44)
     print()
     for name, rank in pilot_list.items():
         print(name, '-', rank)
Beispiel #3
0
 def listCabinCrew(self):
     ''' prints all cabin crew '''
     cabin_list = LL_API().get_Cabin()
     print("{:^44}".format('All cabin crew members'))
     print("."*44)
     print()
     for name, rank in cabin_list.items():
         print(name, '-', rank)
Beispiel #4
0
 def list_pilots_for_planetypeID(self):
     '''Prints all pilots with license on each plane type'''
     pilotlisence_dict = LL_API().listPilots_planetype()
     for plane, pilots in pilotlisence_dict.items():
         print('\n\n{:^44}'.format(plane))
         print('.'*44)
         print()
         for name, rank in pilots.items():
             print('{} - {}'.format(name, rank))
Beispiel #5
0
    def listEmployeesVoyagesInSpecificWeek(self):
        ''' prints a list of employyes voyages in specific week '''
        name = input("Full name: ").title()
        usersWithName = LL_API().getOneEmployeeName(name)

        if len(usersWithName) == 0:
            print(":: No user with that name ::")
        else:
            for elem in usersWithName:
                ssn = elem.ssn

        print("From")
        print("----")
        from_year_input = input("Year: ")
        from_year = LL_API().checkIfValidDate(from_year_input)
        if from_year == None:
            print(":: Not a valid year ::")
        else:
            from_month_input = input("Month: ")
            from_month = LL_API().checkIfValidDate(from_month_input)
            if from_month == None:
                print(":: Not a valid month ::")
            else:
                from_day_input = input("Day: ")
                from_day = LL_API().checkIfValidDate(from_day_input)
                if from_day == None:
                    print(":: Not a valid day ::")
                else:
                    print("\nTo")
                    print("----")
                    to_year_input = input("Year: ")
                    to_year = LL_API().checkIfValidDate(to_year_input)
                    if to_year == None:
                        print(":: Not a valid year ::")
                    else:
                        to_month_input = input("Month: ")
                        to_month = LL_API().checkIfValidDate(to_month_input)
                        if to_month == None:
                            print(":: Not a valid month ::")
                        else:
                            to_day_input = input("Day: ")
                            to_day = LL_API().checkIfValidDate(to_day_input)
                            if to_day == None:
                                print(":: Not a valid day ::")
                            else:
                                print()
                                from_date = datetime.datetime(from_year, from_month, from_day, 0, 0, 0).isoformat()
                                to_date = datetime.datetime(to_year, to_month, to_day+1, 0, 0, 0).isoformat()

                                result = LL_API().Week_Time(from_date, to_date)
                                employee_list = LL_API().EmployeesVoyagesInSpecificWeek(ssn, result)

                                for voyage in employee_list:

                                    print('{:>22} {} {:<22}'.format(voyage.flightOut.flightNumber, '-', voyage.flightBack.flightNumber))
                                    print('.'*44,'\n')
                                    print('{}-{}: \n\t{} \n\t{}'.format(voyage.flightOut.departingFrom, voyage.flightOut.arrivingAt, voyage.flightOut.departure, voyage.flightOut.arrival))
                                    print('{}-{}: \n\t{} \n\t{}'.format(voyage.flightBack.departingFrom, voyage.flightBack.arrivingAt, voyage.flightBack.departure, voyage.flightBack.arrival))
                                    print('Crew: \n\tCaptain: {} \n\tCopilot: {} \n\tfsm: {} \n\tfa1: {} \n\tfa2: {}'.format(voyage.captain, voyage.copilot, voyage.fsm, voyage.fa1, voyage.fa2))
                                    print()
Beispiel #6
0
 def listByDateFilter(self):
     ''' prints all voyages on a specific day '''
     year_input = input("Year: ")
     year = LL_API().checkIfValidDate(year_input)
     if year == None:
         print("\n:: Not a valid year::")
     else:
         month_input = input("Month: ")
         month = LL_API().checkIfValidDate(month_input)
         if month == None:
             print("\n:: Not a valid month ::")
         else:
             day_input = input("Day: ")
             day = LL_API().checkIfValidDate(day_input)
             if day == None:
                 print("\n:: Not a valid day ::")
             else:
                 print()
                 date_time = datetime.datetime(year, month, day, 0, 0,
                                               0).isoformat()
                 result = LL_API().Date_Time(date_time)
                 print()
                 if len(result) == 0:
                     print(":: No Voyage on selected date ::")
                 else:
                     for voyage in result:
                         status_now = self.VoyageStatusNow(voyage)
                         crew_status = self.VoyageCrewStatus(voyage)
                         print('{:>22} {} {:<22}'.format(
                             voyage.flightOut.flightNumber, '-',
                             voyage.flightBack.flightNumber))
                         print('.' * 44, '\n')
                         print('{}-{}: \n\t{} \n\t{}'.format(
                             voyage.flightOut.departingFrom,
                             voyage.flightOut.arrivingAt,
                             voyage.flightOut.departure,
                             voyage.flightOut.arrival))
                         print()
                         print('{}-{}: \n\t{} \n\t{}'.format(
                             voyage.flightBack.departingFrom,
                             voyage.flightBack.arrivingAt,
                             voyage.flightBack.departure,
                             voyage.flightBack.arrival))
                         if crew_status == True:
                             print(
                                 'Crew: \n\tCaptain: {} \n\tCopilot: {} \n\tfsm: {} \n\tfa1: {} \n\tfa2: {}'
                                 .format(voyage.captain, voyage.copilot,
                                         voyage.fsm, voyage.fa1,
                                         voyage.fa2))
                         else:
                             print()
                             print(crew_status)
                         print('\nStatus: \n\t{}'.format(status_now))
                         print()
Beispiel #7
0
    def changePilotInfo(self):
        ''' change employee information '''
        print("\n{:^44}".format('Fill in the information below'))
        print("."*44) 
        input_name = input('\nFull name: ').title()
        emp_info_list = LL_API().getOneEmployeeName(input_name)
        aircraftType_list = LL_API().get_aircraftType_list()

        if len(emp_info_list) == 0:
            print(":: No user with that name ::")

        else:
            for elem in emp_info_list:
                if elem.role == "Pilot":
                    ssn = elem.ssn
                    name = input_name
                    firstname = name.split()
                    role = 'Pilot'   
                    print("\n{:^44}".format('Captain or Copilot?'))
                    print("."*44) 
                    print("1: Captain")
                    print("2: Copilot")
                    print("_"*44)
                    rank_input = int(input('Rank: '))   
                    if rank_input == 1:
                        rank = "Captain"
                    elif rank_input == 2:
                        rank = "Copilot"
                    print("\n{:^44}".format('Choose aircraft license'))
                    print("."*44) 
                    for num, elem in enumerate(aircraftType_list):
                        print('{}: {}'.format(num+1, elem.planeTypeId))
                    print("_"*44)
                    pilotlicense_inp = int(input('Pilot license: '))
                    plicense = aircraftType_list[pilotlicense_inp-1]
                    pilot_license = plicense.planeTypeId
                    address = input('\nAddress: ')
                    try:
                        phone = int(input('Phone: '))
                    except ValueError:
                        print("\n:: Invalid phone ::\n")
                        phone = input('Phone: ')
                    email = firstname[0] + "@nan.is"

                    employee = Model_Employee(ssn, name, role, rank, pilot_license, address, phone, email)
                    LL_API().change_Employee(employee)
                    print("\n:: Information on {} has been updated ::".format(input_name))

                else:
                    print("\n:: Employee not a pilot::")
Beispiel #8
0
    def SetDestination(self):
        ''' set new destination '''
        Id = input('Id: ').upper()
        destination = input('Destination: ').title()
        try:
            flighttimehours = int(input('Flight time hours: '))
        except ValueError:
            print("\n:: Invalid, enter a integer ::\n")
            flighttimehours = int(input('Flight time hours: '))
        try:
            flighttimeminu = int(input("Flight time minutes: "))
        except ValueError:
            print("\n:: Invalid, enter a integer ::\n")
            flighttimeminu = int(input("Flight time minutes: "))
        flighttime = str(flighttimehours) + ":" + str(flighttimeminu)
        try:
            distance = int(input('Distance: '))
        except ValueError:
            print("\n:: Invalid, enter a integer ::\n")
            distance = int(input('Distance: '))
        name_emergencycontact = input('Emergency contact name: ').title()
        try:
            number_emergencycontact = int(
                input('Emergency contact phone number: '))
        except ValueError:
            print("\n:: Invalid, enter a integer ::\n")
            number_emergencycontact = int(
                input('Emergency contact phone number: '))

        destination = Model_Destinations(Id, destination, flighttime, distance,
                                         name_emergencycontact,
                                         number_emergencycontact)
        LL_API().set_destination(destination)
        print("\n:: Destination to {} has been added ::".format(Id))
Beispiel #9
0
 def setAircraft(self, planeTypeId):
     ''' set new aircraft '''
     planeInsignia_inp = input('Plane Insignia: TF-').upper()
     planeInsignia = "TF-" + planeInsignia_inp
     planeTypeId = planeTypeId
     aircraft = Model_Aircrafts(planeInsignia, planeTypeId)
     LL_API().set_aircraft(aircraft)
Beispiel #10
0
 def listVoyage(self):
     ''' prints all voyages '''
     result = LL_API().get_voyage_list()
     if len(result) == 0:
         print(":: No Voyage on selected date ::")
     else:
         for voyage in result:
             status_now = self.VoyageStatusNow(voyage)
             crew_status = self.VoyageCrewStatus(voyage)
             print('{:>22} {} {:<22}'.format(
                 voyage.flightOut.flightNumber, '-',
                 voyage.flightBack.flightNumber))
             print('.' * 44, '\n')
             print('{}-{}: \n\t{} \n\t{}'.format(
                 voyage.flightOut.departingFrom,
                 voyage.flightOut.arrivingAt, voyage.flightOut.departure,
                 voyage.flightOut.arrival))
             print()
             print('{}-{}: \n\t{} \n\t{}'.format(
                 voyage.flightBack.departingFrom,
                 voyage.flightBack.arrivingAt, voyage.flightBack.departure,
                 voyage.flightBack.arrival))
             if crew_status == True:
                 print(
                     'Crew: \n\tCaptain: {} \n\tCopilot: {} \n\tfsm: {} \n\tfa1: {} \n\tfa2: {}'
                     .format(voyage.captain, voyage.copilot, voyage.fsm,
                             voyage.fa1, voyage.fa2))
             else:
                 print()
                 print(crew_status)
             print('\nStatus: \n\t{}'.format(status_now))
             print()
Beispiel #11
0
 def listEmployee(self):
     ''' prints all employees '''
     result = LL_API().get_crew_list()
     print("{:^44}".format('All crew members'))
     print("."*44)
     print()
     for crewMember in result:
         print(crewMember.name, '-',crewMember.rank)
Beispiel #12
0
    def changeDestinationContact(self):
        ''' change emergency contact name '''
        input_dest = input('Destination ID: ').upper()
        dest = LL_API().getOneDestination(input_dest)

        if dest == None:
            print("Not a valid destination")
        else:
            new_name_emergencycontact = input(
                'New emergency contact: ').title()

            updatedDestination = Model_Destinations(
                dest.Id, dest.destination, dest.flighttime, dest.distance,
                new_name_emergencycontact, dest.number_emergencycontact)
            LL_API().change_destination(updatedDestination)

            print("\n:: Information on {} has been updated ::".format(
                updatedDestination.destination))
Beispiel #13
0
 def listByName(self):
     '''prints all employees by name '''
     name_input = input("Full name: ").title()
     usersWithName = LL_API().getOneEmployeeName(name_input)
     if len(usersWithName) == 0:
         print("no user with that name")
     else:
         for elem in usersWithName:
             print("\n\tName: {} \n\tSsn: {} \n\tRole: {} \n\tRank: {} \n\tLicense: {} \n\tAddress: {} \n\tPhone number: {} \n\tEmail: {}".format(elem.name, elem.ssn, elem.role, elem.rank, elem.license, elem.address, elem.phonenumber, elem.email))
Beispiel #14
0
    def SetPilot(self):
        ''' set new pilot '''
        ssn = input('Social security number: ')
        valid_ssn = LL_API().checkIfValidssn(ssn)
        aircraftType_list = LL_API().get_aircraftType_list()
        if valid_ssn == None:
            print(":: Not a valid social security number ::")
        else:
            ssn = valid_ssn
            name = input('Full name: ').title()
            firstname = name.split()
            role = 'Pilot'   

            print("\n{:^44}".format('Captain or Copilot?'))
            print("."*44) 
            print("1: Captain")
            print("2: Copilot")
            print("_"*44)
            rank_input = int(input('Rank: '))   
            if rank_input == 1:
                rank = "Captain"
            elif rank_input == 2:
                rank = "Copilot"

            print("\n{:^44}".format('Choose aircraft license'))
            print("."*44) 
            for num, elem in enumerate(aircraftType_list):
                print('{}: {}'.format(num+1, elem.planeTypeId))
            print("_"*44)
            pilotlicense_inp = int(input('Pilot license: '))
            plicense = aircraftType_list[pilotlicense_inp-1]
            pilot_license = plicense.planeTypeId
            address = input('\nAddress: ')
            try:
                phone = int(input('Phone: '))
            except ValueError:
                print("\n:: Invalid phone ::\n")
                phone = input('Phone: ')
            email = firstname[0] + "@nan.is"

            employee = Model_Employee(ssn, name, role, rank, pilot_license, address, phone, email)
            LL_API().createEmployee(employee)

            print("\n:: {} has been added as a Pilot ::".format(name))
Beispiel #15
0
    def setAircraftTypes(self):
        ''' set new aircraft type '''
        manufacturer = input('Manufacturer: ').capitalize()
        model = input('Model: ')
        planeTypeId = "NA" + manufacturer + model
        try:
            capacity = int(input('Capacity: '))
        except ValueError:
            print("\n:: Invalid, enter a integer ::\n")
            capacity = int(input('Capacity: '))
        try:
            emptyWeight = int(input('Empty Weight: '))
        except ValueError:
            print("\n:: Invalid, enter a integer ::\n")
            emptyWeight = int(input('Empty Weight: '))
        try:
            maxTakeoffWeight = int(input('Max Takeoff Weight: '))
        except ValueError:
            print("\n:: Invalid, enter a integer ::\n")
            maxTakeoffWeight = int(input('Max Takeoff Weight: '))
        try:
            unitThrust = float(input('Unit Thrust: '))
        except ValueError:
            print("\n:: Invalid, enter a integer ::\n")
            unitThrust = float(input('Unit Thrust: '))
        try:
            serviceCeiling = int(input('Service Ceiling: '))
        except ValueError:
            print("\n:: Invalid, enter a integer ::\n")
            serviceCeiling = int(input('Service Ceiling: '))
        try:
            length = int(input('Length: '))
        except ValueError:
            print("\n:: Invalid, enter a integer ::\n")
            length = int(input('Length: '))
        try:
            height = int(input('Height: '))
        except ValueError:
            print("\n:: Invalid, enter a integer ::\n")
            height = int(input('Height: '))
        try:
            wingspan = int(input('Wingspan: '))
        except ValueError:
            print("\n:: Invalid, enter a integer ::\n")
            wingspan = int(input('Wingspan: '))
        name = input('Name: ').title()

        aircraftType = Model_AircraftType(planeTypeId, manufacturer, model,
                                          capacity, emptyWeight,
                                          maxTakeoffWeight, unitThrust,
                                          serviceCeiling, length, height,
                                          wingspan, name)
        LL_API().set_aircraftType(aircraftType)
        self.setAircraft(planeTypeId)

        print('\n:: {} has been added as a aircraft ::'.format(planeTypeId))
Beispiel #16
0
 def listByLicense(self):
     '''prints all employees by license '''
     license_input = input("Pilot License: ").upper()
     usersWithLicense = LL_API().getOneEmployeeLicense(license_input)
     if len(usersWithLicense) == 0:
         print("Not a valid license")
     else:
         print()
         for elem in usersWithLicense:
             print('\t', elem.name, '-', elem.rank)
Beispiel #17
0
    def changeCabincrewInfo(self):
        ''' change cabincrew information '''
        print("\n{:^44}".format('Fill in the information below'))
        print("."*44) 
        input_name = input('\nFull name: ').title()
        emp_info_list = LL_API().getOneEmployeeName(input_name)

        if len(emp_info_list) == 0:
            print(":: No user with that name ::")
        
        else:
            for elem in emp_info_list:
                if elem.role == "Cabincrew":
                    ssn = elem.ssn
                    name = input_name
                    firstname = name.split()
                    role = 'Cabincrew'
                    print("\n{:^44}".format('Choose rank'))
                    print("."*44) 
                    print("1: Flight Attendant")
                    print("2: Flight Service Manager")
                    print("_"*44)
                    rank_input = int(input('Rank: '))   
                    if rank_input == 1:
                        rank = "Flight Attendant"
                    elif rank_input == 2:
                        rank = "Flight Service Manager"
                    pilot_license = 'N/A'
                    address = input('\nAddress: ')
                    try:
                        phone = int(input('Phone: '))
                    except ValueError:
                        print("\n:: Invalid phone ::\n")
                        phone = input('Phone: ')
                    email = firstname[0] + "@nan.is"

                    employee = Model_Employee(ssn, name, role, rank, pilot_license, address, phone, email)
                    LL_API().change_Employee(employee)
                    print("\n:: Information on {} has been updated ::".format(input_name))

                else:
                    print("\n:: Employee not in Cabin crew ::")
Beispiel #18
0
    def listAllEmployeesNotWorkingOnSpecificDay(self):
        ''' prints a list of people not working on specific day '''
        year_input = input("Year: ")
        year = LL_API().checkIfValidDate(year_input)
        if year == None:
            print("\n:: Not a valid year ::")
        else:
            month_input = input("Month: ")
            month = LL_API().checkIfValidDate(month_input)
            if month == None:
                print("\n:: Not a valid month ::")
            else:
                day_input = input("Day: ")
                day = LL_API().checkIfValidDate(day_input)
                if day == None:
                    print("\n:: Not a valid day ::")
                else:
                    print()
                    start_time = datetime.datetime(year, month, day, 0, 0, 0).isoformat()
                    result_employees = LL_API().EmployeesNotWorking(start_time)

                    print('{:^44}'.format('Pilots'))
                    print('.'*44)
                    print()
                    for crewMember in result_employees:
                        if crewMember.rank == 'Captain':
                            print(crewMember.name, '-',crewMember.rank)
                        elif crewMember.rank == 'Copilot':
                            print(crewMember.name, '-',crewMember.rank)

                    print('\n{:^44}'.format('Cabin crew'))
                    print('.'*44)
                    print()
                    for crewMember in result_employees:
                        if crewMember.rank == 'Flight Service Manager':
                            print(crewMember.name, '-',crewMember.rank)
                        elif crewMember.rank == 'Flight Attendant':
                            print(crewMember.name, '-',crewMember.rank)
Beispiel #19
0
    def changeDestinationPhone(self):
        ''' change emergency contact phone number '''
        input_dest = input('Destination ID: ').upper()
        dest = LL_API().getOneDestination(input_dest)

        if dest == None:
            print("Not a valid destination")
        else:
            try:
                new_number_emergencycontact = int(
                    input('New emergency contact phone number: '))
            except ValueError:
                print("\n:: Invalid, enter a integer ::\n")
                new_number_emergencycontact = int(
                    input('New emergency contact phone number: '))

            updatedDestination = Model_Destinations(
                dest.Id, dest.destination, dest.flighttime, dest.distance,
                dest.name_emergencycontact, new_number_emergencycontact)
            LL_API().change_destination(updatedDestination)

            print("\n:: Information on {} has been updated ::".format(
                updatedDestination.destination))
Beispiel #20
0
 def listDestinations(self):
     ''' prints all destinations '''
     result = LL_API().get_dest_list()
     print()
     print('{:^44}'.format("All destinations:"))
     print('.' * 44)
     print()
     for dest in result:
         print('{} - {}'.format(dest.Id, dest.destination))
         print(
             '\tFlight time: {} \n\tDistance: {} \n\tEmergency contact name: {} \n\tEmergency contact phone number: {}\n'
             .format(dest.flighttime, dest.distance,
                     dest.name_emergencycontact,
                     dest.number_emergencycontact))
Beispiel #21
0
    def check_worktrip_date(self, date):
        '''
        Checks date of departure\n
        date='YYYY-MM-DD HH:MM"
        '''
        worktrips = LL_API()
        worktrip_list = worktrips.get_list('worktrip')
        worktrip_list.pop(0)

        start_date = datetime.datetime.strptime(
            date, '%Y-%m-%d %H:%M') - datetime.timedelta(minutes=10)
        end_date = datetime.datetime.strptime(
            date, '%Y-%m-%d %H:%M') + datetime.timedelta(minutes=10)

        for line in worktrip_list:
            if len(line[5]) < 17:
                line[5] += ':00'

            if datetime.datetime.strptime(
                    line[5], '%Y-%m-%d %H:%M:%S'
            ) > start_date and datetime.datetime.strptime(
                    line[5], '%Y-%m-%d %H:%M:%S') < end_date:
                return False  # Found a worktrip within allowed time
        return True
Beispiel #22
0
    def listAllEmployeesWorkingOnSpecificDay(self):
        ''' prints a list of people working on specific day '''
        year_input = input("Year: ")
        year = LL_API().checkIfValidDate(year_input)
        if year == None:
            print("Not a valid year")
        else:
            month_input = input("Month: ")
            month = LL_API().checkIfValidDate(month_input)
            if month == None:
                print("Not a valid month")
            else:
                day_input = input("Day: ")
                day = LL_API().checkIfValidDate(day_input)
                if day == None:
                    print("Not a valid day")
                else:
                    print()
                    start_time = datetime.datetime(year, month, day, 0, 0, 0).isoformat()
                    employee_dict = LL_API().EmployeesWorking(start_time)

                    print('\n{:^44}'.format('Pilots'))
                    print('.'*44)
                    for crewMember, voyage in employee_dict.items():
                        if crewMember.role == 'Pilot':
                            print('\n{} - {}\n'.format(crewMember.name, crewMember.rank))
                            print('\t {} - {}'.format(voyage.flightOut.departingFrom, voyage.flightOut.arrivingAt))
                            print('\t {} - {}'.format(voyage.flightBack.departingFrom, voyage.flightBack.arrivingAt))
                            print()
                    
                    print('\n{:^44}'.format('Cabin crew'))
                    print('.'*44)
                    for crewMember, voyage in employee_dict.items():
                        if crewMember.role == 'Cabincrew':
                            print('\n{} - {}\n'.format(crewMember.name, crewMember.rank))
                            print('\t {} - {}'.format(voyage.flightOut.departingFrom, voyage.flightOut.arrivingAt))
                            print('\t {} - {}'.format(voyage.flightBack.departingFrom, voyage.flightBack.arrivingAt))
                            print()
Beispiel #23
0
    def listAircraftTypes(self):
        ''' prints all aircraft types '''
        aircraftType_list = LL_API().get_aircraftType_list()
        aircraft_list = LL_API().get_aircrafts_list()
        voyage = self.AircraftStatus(aircraft_list)
        pilot_count = LL_API().get_pilot_count()

        print()
        for aircraftType in aircraftType_list:
            print("{:^44}".format(aircraftType.planeTypeId))
            print("." * 44)
            print(
                "\nName: {} \nManufacturer: {} \nModel: {} \nCapacity: {} \nEmpty weight: {} \nMax takeoff weight: {} \nUnit thrust: {} \nService ceiling: {} \nLength: {} \nHeight: {} \nWingspan: {}"
                .format(aircraftType.name, aircraftType.manufacturer,
                        aircraftType.model, aircraftType.capacity,
                        aircraftType.emptyWeight,
                        aircraftType.maxTakeoffWeight, aircraftType.unitThrust,
                        aircraftType.serviceCeiling, aircraftType.length,
                        aircraftType.height, aircraftType.wingspan))
            if aircraftType.planeTypeId in pilot_count.keys():
                for planeID, count in pilot_count.items():
                    if planeID == aircraftType.planeTypeId:
                        print('Pilots with license: {}'.format(count))
            else:
                print('Pilots with license: {}'.format('0'))

            for line in aircraft_list:
                if line.planeTypeId.strip() == aircraftType.planeTypeId:
                    for elem in voyage:
                        if elem.flightOut.aircraftID == line.planeInsignia:
                            print()
                            print("{:^44}".format("Aircraft is active"))
                            print()
                            print("Flight number:",
                                  elem.flightOut.flightNumber)
                            print("Destination:", elem.flightOut.arrivingAt)
                            print('Next available time:',
                                  elem.flightBack.arrival)
            print()
Beispiel #24
0
 def listAircrafts(self):
     ''' prints all aircrafts '''
     result = LL_API().get_aircrafts_list()
     for aircrafts in result:
         print(aircrafts)
Beispiel #25
0
    def listByWeekFilter(self):
        ''' prints all voyages in a specific week '''

        print("From")
        print("----")
        from_year_input = input("Year: ")
        from_year = LL_API().checkIfValidDate(from_year_input)
        if from_year == None:
            print("\n:: Not a valid year ::")
        else:
            from_month_input = input("Month: ")
            from_month = LL_API().checkIfValidDate(from_month_input)
            if from_month == None:
                print("\n:: Not a valid month ::")
            else:
                from_day_input = input("Day: ")
                from_day = LL_API().checkIfValidDate(from_day_input)
                if from_day == None:
                    print("\n:: Not a valid day ::")
                else:
                    print("\nTo")
                    print("----")
                    to_year_input = input("Year: ")
                    to_year = LL_API().checkIfValidDate(to_year_input)
                    if to_year == None:
                        print("\n:: Not a valid year ::")
                    else:
                        to_month_input = input("Month: ")
                        to_month = LL_API().checkIfValidDate(to_month_input)
                        if to_month == None:
                            print("\n:: Not a valid month ::")
                        else:
                            to_day_input = input("Day: ")
                            to_day = LL_API().checkIfValidDate(to_day_input)
                            if to_day == None:
                                print("\n:: Not a valid day ::")
                            else:
                                print()
                                from_date = datetime.datetime(
                                    from_year, from_month, from_day, 0, 0,
                                    0).isoformat()
                                to_date = datetime.datetime(
                                    to_year, to_month, to_day + 1, 0, 0,
                                    0).isoformat()
                                result = LL_API().Week_Time(from_date, to_date)
                                print()
                                if len(result) == 0:
                                    print(":: No Voyage on selected date ::")
                                else:
                                    for voyage in result:
                                        status_now = self.VoyageStatusNow(
                                            voyage)
                                        crew_status = self.VoyageCrewStatus(
                                            voyage)
                                        print('{:>22} {} {:<22}'.format(
                                            voyage.flightOut.flightNumber, '-',
                                            voyage.flightBack.flightNumber))
                                        print('.' * 44, '\n')
                                        print('{}-{}: \n\t{} \n\t{}'.format(
                                            voyage.flightOut.departingFrom,
                                            voyage.flightOut.arrivingAt,
                                            voyage.flightOut.departure,
                                            voyage.flightOut.arrival))
                                        print()
                                        print('{}-{}: \n\t{} \n\t{}'.format(
                                            voyage.flightBack.departingFrom,
                                            voyage.flightBack.arrivingAt,
                                            voyage.flightBack.departure,
                                            voyage.flightBack.arrival))
                                        if crew_status == True:
                                            print(
                                                'Crew: \n\tCaptain: {} \n\tCopilot: {} \n\tfsm: {} \n\tfa1: {} \n\tfa2: {}'
                                                .format(
                                                    voyage.captain,
                                                    voyage.copilot, voyage.fsm,
                                                    voyage.fa1, voyage.fa2))
                                        else:
                                            print()
                                            print(crew_status)
                                        print('\nStatus: \n\t{}'.format(
                                            status_now))
                                        print()
Beispiel #26
0
    def create_voyage(self):
        '''Gets all necessary input to create a new Voyage'''
        flightNumber = input('Enter flight number fx "NA0000" : ')
        update = LL_API().checkIfValidFlightNumber(flightNumber)

        if update == False:
            print("\n:: Invalid flight number ::")
        else:
            dest_list = LL_API().get_dest_id_list()
            print("\n{:^44}".format("List of Destiantions"))
            print("." * 44)
            for num, elem in enumerate(dest_list):
                print('{}: {}'.format(num + 1, elem))

            print("_" * 44)
            voyage_destiantion = int(input('Choose Destination: '))
            arrivingAt = dest_list[voyage_destiantion - 1]

            try:
                year = int(input("Enter Year of departure: "))

            except ValueError:
                print("\n:: Not a valid year ::\n")
                year = int(input("Enter Year of departure: "))

            try:
                month = int(input("Enter Month of departure: "))
            except ValueError:
                print("\n:: Not a valid month ::\n")
                month = int(input("Enter Month of departure: "))

            try:
                day = int(input("Enter Day of departure: "))
            except ValueError:
                print("\n:: Not a valid day ::\n")
                day = int(input("Enter Day of departure: "))

            try:
                hour = int(input("Enter Hour of departure: "))
            except ValueError:
                print("\n:: Not a valid hour ::\n")
                hour = int(input("Enter Hour of departure: "))

            try:
                minute = int(input("Enter Minute of departure: "))
            except ValueError:
                print("\n:: Not a valid minute ::")
                minute = int(input("Enter Minute of departure: "))

            date_time = datetime.datetime(year, month, day, hour, minute,
                                          0).isoformat()
            valid_FlightTime = LL_API().checkIfValidFlightTime(date_time)
            if valid_FlightTime == False:
                print("\n:: Invalid flight time ::")

            else:
                aricraft_plainInsignia = LL_API().availableAircrafts(date_time)
                print("\n{:^44}".format("List of available Aircrafts"))
                print("." * 44)

                for num, elem in enumerate(aricraft_plainInsignia):
                    print('{}: {}'.format(num + 1, elem.planeInsignia))

                print("_" * 44)
                voyage_aircraft = int(input('Choose Aircraft: '))
                aircraftID = aricraft_plainInsignia[voyage_aircraft - 1]

                date_time_ofDeparture = datetime.datetime(
                    year, month, day, hour, minute, 0)
                LL_API().create_flight(flightNumber, arrivingAt,
                                       date_time_ofDeparture,
                                       aircraftID.planeInsignia)

                print('\n:: Voyage to {} has been added ::'.format(arrivingAt))
Beispiel #27
0
 def VoyageStatusNow(self, voyage):
     ''' Prints out the status of a voyage now '''
     check_status = LL_API().checkVoyageStatus(voyage)
     return check_status
Beispiel #28
0
 def VoyageCrewStatus(self, voyage):
     ''' Prints out the status of the crew now'''
     check_status = LL_API().checkVoyageCrewStatus(voyage)
     return check_status
Beispiel #29
0
    def add_crew_to_voyage(self):
        '''Adds crew members to already existing voyage'''
        voyage_To_update = input("Enter flight number: ")

        update = LL_API().update_voyage_list(voyage_To_update)
        voyage_list = LL_API().get_upcomingFlight_list()

        if update:
            for elem in voyage_list:
                if elem.flightOut.flightNumber == voyage_To_update or elem.flightBack.flightNumber == voyage_To_update:

                    captain_list = LL_API().CaptainNotWorking(
                        elem.flightOut.departure)
                    cap_with_lisence = LL_API().PilotWithLisence(
                        captain_list, elem.flightOut.aircraftID)
                    print("\n{:^44}".format(
                        "List of available licensed Captains"))
                    print("." * 44)

                    for num, emp in enumerate(cap_with_lisence):
                        print('{}: {} - {}'.format(num + 1, emp.name,
                                                   emp.rank))

                    print("_" * 44)
                    voyage_captain = int(input("Captain: "))
                    captain = cap_with_lisence[voyage_captain - 1]

                    copilot_list = LL_API().CopilotNotWorking(
                        elem.flightOut.departure, captain)
                    copi_with_lisence = LL_API().PilotWithLisence(
                        copilot_list, elem.flightOut.aircraftID)
                    print("\n{:^44}".format(
                        "List of available licensed Copilots"))
                    print("." * 44)

                    for num, emp in enumerate(copi_with_lisence):
                        print('{}: {} - {}'.format(num + 1, emp.name,
                                                   emp.rank))

                    print("_" * 44)
                    voyage_copilot = int(input("Copilot: "))
                    copilot = copi_with_lisence[voyage_copilot - 1]

                    fsm_list = LL_API().FsmNotWorking(elem.flightOut.departure)
                    print("\n{:^44}".format("List of Flight Service Managers"))
                    print("." * 44)

                    for num, emp in enumerate(fsm_list):
                        print('{}: {} - {}'.format(num + 1, emp.name,
                                                   emp.rank))

                    print("_" * 44)
                    voyage_fsm = int(input("Flight Service Manager: "))
                    fsm = fsm_list[voyage_fsm - 1]

                    fa_list = LL_API().FaNotWorking(elem.flightOut.departure)
                    print("\n{:^44}".format("List of Flight Attendants"))
                    print("." * 44)

                    for num, emp in enumerate(fa_list):
                        print('{}: {} - {}'.format(num + 1, emp.name,
                                                   emp.rank))

                    print("_" * 44)
                    voyage_fa1 = int(input("Flight Attendant 1: "))
                    voyage_fa2 = int(input("Flight Attendant 2: "))

                    fa1 = fa_list[voyage_fa1 - 1]
                    fa2 = fa_list[voyage_fa2 - 1]

                    voyage_WithCrew = Model_Voyage(elem.flightOut,
                                                   elem.flightBack,
                                                   captain.ssn, copilot.ssn,
                                                   fsm.ssn, fa1.ssn, fa2.ssn)
                    LL_API().change_voyage(voyage_WithCrew)

                    print("\n:: Crew has been added to voyage {} ::".format(
                        voyage_To_update))

        else:
            print(
                "\n:: Not a valid flight number or crew has \nalready been added to voyage {} ::"
                .format(voyage_To_update))
Beispiel #30
0
def main():

    #-----------------------------KEYRSLUTEST------------------------------"

    new_instance = LL_API()

    #CREATE

    # """Destination"""
    # return_value = new_instance.create("destination", ('','Test', 'Canada','6:30:10','2.100','John Philips','0219933884','BC_airport'))

    # return_value = new_instance.create("employee",('','5665552222','Eyþór Óli','Irmagata 31','0934958','*****@*****.**','Pilot','Copilot','Airmax'))
    # return_value = new_instance.create("destination", ('','Toronto', 'Canada','6:30:10','2.100','John Philips','0219933884','BC_airport'))
    #return_value = new_instance.create("airplane", ('',"TF-Eythor","NANTES146","Fokker","555","Skvis"))
    #return_value = new_instance.create("worktrip",('','','','Reykjavik','Manchester','2019-12-20 06:45:00','5','1','2','3','4','5','Staffed','')) # dest_id, departure_time, airplane_id
    #return_msg(return_value, f"creating a new object, code:{return_value}")
    #return_value = new_instance.create("worktrip",('1','2019-12-19 11:45','5'))

    #CHANGE
    # return_value = new_instance.change("destination",('16','Milano', 'Italy','6:30:10','2.100','John Philips','0219933884','BC_airport','2019-12-08 13:41:20.362544'))
    # return_value = new_instance.change("employee",('23','2001933874', 'Gömul Lára','Bústaðarvegi 6','8922773','*****@*****.**','Pilot','Captain','F1Fighters','2019-12-08 12:46:12.455312'))
    # return_value = new_instance.change("airplane",('73','TF-breytt', 'NAbreytt','Fokker','F800','Breytt','13:25:38.975230'))
    # return_value = new_instance.change("worktrip",('13','Milano', 'Italy','6:30:10','2.100','John Philips','0219933884','BC_airport','2019-12-07 21:39:33.300255'))
    # return_msg(return_value, f"changing, code:{return_value}")
    #return_value = new_instance.change("worktrip",('14','NA2275','NA3525','Keflavik','súðavík','2019-12-30 06:21:00','2019-12-19 22:00:00','3','13','12','13','14','15','Mönnuð','2019-12-05 20:45:18.095017'))

    #GET_LIST

    #new_list = new_instance.get_list('employee')
    #new_list = new_instance.get_list('airplane')
    # new_list = new_instance.get_list('destination')
    # new_list = new_instance.get_list('worktrip')
    # new_list = new_instance.get_list('destination',"destination_id","Vancouver")
    # new_list = new_instance.get_list('airplane','plane_licences')
    #new_list = new_instance.get_list('worktrip', 'work_schedule', '2019-12-25', '23')

    #Working and Available employees
    #new_list = new_instance.get_list('worktrip',"working_employees",'2019-12-19')
    #new_list  = new_instance.get_list("worktrip", "available_employees", "2019-12-12", role='', rank='', a_license='Fokker232')
    #new_list  = new_instance.get_list("worktrip", "available_employees", "2020-12-19")

    #Work Schedule:
    #new_list = new_instance.get_list('worktrip', 'work_schedule', '2019-12-28', '', days=1) #fær öll flug fyrir einn dag ákveðna dagsetningu
    #new_list = new_instance.get_list('worktrip', 'work_schedule', '2019-12-19') #fær flug fyrir öll flug áveðna viku
    #   new_list = new_instance.get_list('worktrip', 'work_schedule', '2019-12-18', _id='28') #fær flug fyrir ákveðinn starfsmann ákveðna viku

    #Worktrip translator:
    #new_list = new_instance.get_list(list_type='worktrip_readable', searchparam=("15",'NA156','NA157','Keflavík','15','2019-12-20 11:50:00','2019-12-20 21:45:00','5','3','2','7','11','15','staffed','2019-12-11 01:51:02.065347'))

    #Find pilot with license
    #new_list = new_instance.get_list ('employee', "pilot_licences", a_license='BOEING747')

    #new_list = new_instance.get_list("destination","destination_name", "10")
    # get_list(self,keyword='',list_type="",searchparam = "", _id='', role='',rank='', a_license='', days=7):
    new_list = new_instance.get_list("worktrip",
                                     "available_employees",
                                     "2019-12-19",
                                     rank='Captain',
                                     a_license='Fokker232')
    # new_list = new_instance.get_list('airplane','plane_licences')
    #new_list = new_instance.get_list('worktrip', 'workschedule', '2020-12-19', '14')
    # new_list  = new_instance.get_list("worktrip", "available_employees", "2019-12-20", role='Pilot', rank='', a_license='Fokker232')
    print(new_list)

    # new_list = new_instance.get_list('employee')
    #new_list = new_instance.get_list('airplane')
    # new_list = new_instance.get_list('destination')
    # new_list = new_instance.get_list('worktrip')
    #new_list = new_instance.get_list('worktrip',"available_employees",'2019-12-19', '1')
    #new_list = new_instance.get_list(keyword='worktrip', list_type= 'workschedule', searchparam='2019-12-11', _id='14')
    #new_list = new_instance.get_list('airplane','plane_licences')
    #print(new_list)

    #print('not working ', new_list)

    # new_instance = EmployeeLL()
    # new_list = new_instance.working_employees([['Köben','1','2','3','4','5'],['Stockholm','6','7','8','9','10']])
    # print(new_list)

    return None