Esempio n. 1
0
    def run(self, force, date_from, date_to, ids):
        current_app.add_celery()

        if force:
            # invalidate all results
            Flight.query().update({'needs_analysis': True})

        if ids:
            for flight_id in ids:
                self.do(flight_id)
        elif date_from and date_to:
            print date_from
            try:
                date_from = datetime.strptime(date_from, "%Y-%m-%d")
                date_to = datetime.strptime(date_to, "%Y-%m-%d")
            except:
                print "Cannot parse date."
                quit()

            q = db.session.query(Flight)
            q = q.filter(Flight.takeoff_time >= date_from) \
                 .filter(Flight.takeoff_time <= date_to)

            for flight in q:
                self.do(flight.id)
        else:
            for flight in Flight.query(needs_analysis=True):
                self.do(flight.id)
Esempio n. 2
0
    def run(self, force, date_from, date_to, ids):
        current_app.add_celery()

        if force:
            # invalidate all results
            Flight.query().update({'needs_analysis': True})

        if ids:
            for flight_id in ids:
                self.do(flight_id)
        elif date_from and date_to:
            print date_from
            try:
                date_from = datetime.strptime(date_from, "%Y-%m-%d")
                date_to = datetime.strptime(date_to, "%Y-%m-%d")
            except:
                print "Cannot parse date."
                quit()

            q = db.session.query(Flight)
            q = q.filter(Flight.takeoff_time >= date_from) \
                 .filter(Flight.takeoff_time <= date_to)

            for flight in q:
                self.do(flight.id)
        else:
            for flight in Flight.query(needs_analysis=True):
                self.do(flight.id)
Esempio n. 3
0
    def run(self, force, ids):
        current_app.add_celery()

        if force:
            # invalidate all results
            Flight.query().update({'needs_analysis': True})

        if ids:
            for flight_id in ids:
                self.do(flight_id)
        else:
            for flight in Flight.query(needs_analysis=True):
                self.do(flight.id)
Esempio n. 4
0
    def run(self, force, ids):
        current_app.add_celery()

        if force:
            # invalidate all results
            Flight.query().update({'needs_analysis': True})

        if ids:
            for flight_id in ids:
                self.do(flight_id)
        else:
            for flight in Flight.query(needs_analysis=True):
                self.do(flight.id)
Esempio n. 5
0
class FindMeetings(Command):
    """ Find meetings points between flights """

    option_list = selector_options + (
        Option('--force',
               action='store_true',
               help='re-analyse all flights, not just the scheduled ones'),
        Option('--async',
               action='store_true',
               help='put flights in celery queue'),
    )

    def run(self, force, async, **kwargs):
        q = db.session.query(Flight)
        q = q.order_by(Flight.id)

        q = select(q, **kwargs)

        if not q:
            quit()

        if not force:
            q = q.filter(Flight.needs_analysis == True)

        if async:
            current_app.add_celery()

        self.incremental(lambda f: self.do(f, async=async), q)
Esempio n. 6
0
    def run(self, force, _async, **kwargs):
        q = db.session.query(Flight)
        q = q.order_by(Flight.id)

        q = select(q, **kwargs)

        if not q:
            quit()

        if not force:
            q = q.filter(Flight.needs_analysis == True)

        if _async:
            current_app.add_celery()

        self.incremental(lambda f: self.do(f, _async=_async), q)
Esempio n. 7
0
    def run(self, force, **kwargs):
        current_app.add_celery()

        q = db.session.query(Flight)
        q = q.options(joinedload(Flight.igc_file))
        q = q.order_by(Flight.id)

        q = select(q, **kwargs)

        if not q:
            quit()

        if not force:
            q = q.filter(Flight.needs_analysis == True)

        for flight in q:
            self.do(flight.id)
Esempio n. 8
0
    def run(self, force, **kwargs):
        current_app.add_celery()

        q = db.session.query(Flight)
        q = q.options(joinedload(Flight.igc_file))
        q = q.order_by(Flight.id)

        q = select(q, **kwargs)

        if not q:
            quit()

        if not force:
            q = q.filter(Flight.needs_analysis == True)

        for flight in q:
            self.do(flight.id)