Пример #1
0
def main():
    app = create_app()
    with app.app_context():

        schedule = generate_schedule(
            date(2016, 10, 1),
            date(2016, 10, 7),
            [("cebupacific", ("PEK", "MNL")), ("airasia", ("PEK", "KUL"))],
            3600
        )

        schedule2 = generate_schedule(
            date(2016, 5, 1),
            date(2016, 5, 8),
            [("airasia", ("KUL", "MEL")), ("airasia", ("KUL", "CMB")), ("airasia", ("PEK", "CMB")), ("airasia", ("PEK", "MEL"))],
            3600,
            days_offset=0,
        )

        for item in schedule2:
            job = {
                "flight_date": item[0],
                "airline": item[1],
                "origin": item[2],
                "destination": item[3],
                "period": item[4],
                "next_run_after": date(2016, 1, 1),
            }
            job_id = CrawlJob.upsert(**job)
            print CrawlJob.get(job_id)
Пример #2
0
#!/usr/bin/python
import os

from werkzeug.utils import import_string
from flask.ext.script import Manager
from flask.ext.script.commands import Clean
from flask.ext.migrate import MigrateCommand, Migrate

from cheapflight.app import create_app
from cheapflight.ext import db

# import for migrating
import cheapflight.models  # noqa

app = create_app()
manager = Manager(app)
migrate = Migrate(app, db)

manager.add_command('db', MigrateCommand)
manager.add_command(Clean())


@manager.command
def runscript(script_path):
    '''
    Run Function. e.g.:
    cheapflight.scripts.rader:main or
    cheapflight/scripts/rader.py with main()
    '''
    if ":" not in script_path:
        script_path = os.path.expanduser(os.path.expandvars(script_path))
Пример #3
0
 def create_app(self):
     return create_app(TestingConfig)