Example #1
0
    def update_flights_list(self):
        '''
            Met à jour la liste des avions par rapport aux fichiers contenu
            dans le dossier flightslog
        '''
        self.flights_list.clear()
        flights_path = []

        for flight_file in glob.glob('{}*{}'.format(config.flightslog_folder,
                                                    config.flights_ext)):
            flights_path.append(flight_file)

        for flight_doc in flights_path:
            flight = Flight()
            plane = Plane()

            flight.import_flight(flight_doc)

            total_hours = flight.calc_total_hours()

            # On vérifie que l'avion existe bien (bug remonté par WinXaito)
            if os.path.isfile(flight.plane):
                plane.import_plane(flight.plane)
                self.flights_list.append([flight.date, plane.matriculation,
                                         flight.type, total_hours])
            else:
                self.flights_list.append([flight.date, 'UKNOWN',
                                         flight.type, total_hours])