コード例 #1
0
ファイル: flight.py プロジェクト: citterio/Skylines
    def analysis(self, **kwargs):
        """Hidden method that restarts flight analysis."""

        analyse_flight(self.flight)
        DBSession.flush()

        return redirect('.')
コード例 #2
0
ファイル: upload.py プロジェクト: dkm/skylines
    def do(self, file, pilot):
        user = request.identity['user']

        pilot_id = None
        club_id = user.club_id
        if pilot:
            pilot = DBSession.query(User).get(int(pilot))
            if pilot:
                pilot_id = pilot.id
                club_id = pilot.club_id

        flights = []
        success = False

        for name, f in IterateUploadFiles(file):
            filename = files.sanitise_filename(name)
            filename = files.add_file(filename, f)

            # check if the file already exists
            with files.open_file(filename) as f:
                md5 = file_md5(f)
                other = Flight.by_md5(md5)
                if other:
                    files.delete_file(filename)
                    flights.append((name, other, _('Duplicate file')))
                    continue

            igc_file = IGCFile()
            igc_file.owner = user
            igc_file.filename = filename
            igc_file.md5 = md5
            igc_file.update_igc_headers()

            if igc_file.date_utc is None:
                files.delete_file(filename)
                flights.append((name, None, _('Date missing in IGC file')))
                continue

            flight = Flight()
            flight.pilot_id = pilot_id
            flight.club_id = club_id
            flight.igc_file = igc_file

            flight.model_id = igc_file.guess_model()

            if igc_file.registration:
                flight.registration = igc_file.registration
            else:
                flight.registration = igc_file.guess_registration()

            flight.competition_id = igc_file.competition_id

            if not analyse_flight(flight):
                files.delete_file(filename)
                flights.append((name, None, _('Failed to parse file')))
                continue

            if not flight.takeoff_time or not flight.landing_time:
                files.delete_file(filename)
                flights.append((name, None, _('No flight found in file')))
                continue

            if not flight.update_flight_path():
                files.delete_file(filename)
                flights.append((name, None, _('No flight found in file')))
                continue

            flights.append((name, flight, None))
            DBSession.add(igc_file)
            DBSession.add(flight)

            create_flight_notifications(flight)

            success = True

        DBSession.flush()

        return dict(flights=flights, success=success,
                    ModelSelectField=aircraft_model.SelectField)
コード例 #3
0
ファイル: analyse.py プロジェクト: dkm/skylines
def do(flight):
    print flight.id
    return analyse_flight(flight)
コード例 #4
0
ファイル: flight.py プロジェクト: citterio/Skylines
 def __reanalyse_if_needed(self, flight):
     if flight.needs_analysis:
         log.info("Reanalysing flight %s" % flight.id)
         analyse_flight(flight)