-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
13 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,71 +1,16 @@ | ||
#!/usr/bin/env python | ||
|
||
from flask_script import Manager, Server, Option, prompt_bool | ||
from flask_script.commands import Clean, ShowUrls | ||
from flask_alembic import ManageMigrations, FlaskAlembicConfig | ||
from alembic import command | ||
from coaster.manage import init_manager | ||
|
||
from hasmail import app | ||
from hasmail import models | ||
import hasmail | ||
import hasmail.models as models | ||
import hasmail.forms as forms | ||
import hasmail.views as views | ||
from hasmail.models import db | ||
from hasmail import app | ||
|
||
|
||
manager = Manager(app) | ||
database = Manager(usage="Perform database operations") | ||
|
||
|
||
class InitedServer(Server): | ||
def get_options(self): | ||
return super(InitedServer, self).get_options() + ( | ||
Option('-e', dest='env', default='dev', help="run server for this environment [default 'dev']"), | ||
) | ||
|
||
def handle(self, *args, **kwargs): | ||
super(InitedServer, self).handle(*args, **kwargs) | ||
|
||
|
||
class InitedMigrations(ManageMigrations): | ||
def run(self, args): | ||
super(InitedMigrations, self).run(args[1:]) | ||
|
||
|
||
@manager.shell | ||
def _make_context(): | ||
return dict(app=app, db=db, models=models) | ||
|
||
|
||
@database.option('-e', '--env', default='dev', help="runtime environment [default 'dev']") | ||
def drop(env): | ||
"Drops database tables" | ||
if prompt_bool("Are you sure you want to lose all your data?"): | ||
db.drop_all() | ||
|
||
|
||
@database.option('-e', '--env', default='dev', help="runtime environment [default 'dev']") | ||
def create(env): | ||
"Creates database tables from sqlalchemy models" | ||
db.create_all() | ||
config = FlaskAlembicConfig("alembic.ini") | ||
command.stamp(config, "head") | ||
|
||
|
||
@database.option('-e', '--env', default='dev', help="runtime environment [default 'dev']") | ||
def setversion(env): | ||
''' | ||
Manually set the alembic version of the | ||
database to the provided value. | ||
''' | ||
config = FlaskAlembicConfig("alembic.ini") | ||
version = raw_input("Enter the alembic version to be set:") | ||
command.stamp(config, version) | ||
|
||
|
||
manager.add_command("db", database) | ||
manager.add_command("runserver", InitedServer()) | ||
manager.add_command("clean", Clean()) | ||
manager.add_command("showurls", ShowUrls()) | ||
manager.add_command("migrate", InitedMigrations()) | ||
|
||
|
||
if __name__ == "__main__": | ||
if __name__ == '__main__': | ||
db.init_app(app) | ||
manager = init_manager(app, db, hasmail=hasmail, models=models, forms=forms, views=views) | ||
manager.run() |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/sh | ||
export FLASK_ENV="TESTING" | ||
coverage run `which nosetests` | ||
coverage report |