-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmanage.py
executable file
·51 lines (36 loc) · 1.16 KB
/
manage.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os
from dotenv import load_dotenv
# import local environment
if os.path.exists('.env'):
print('Import environment from .env ...')
load_dotenv(verbose=True)
from app import create_app, db
from app.models import User, Post, Comment, Tag
import click
from flask_migrate import Migrate
app = create_app(os.getenv('FTOWN_CONFIG') or 'default')
migrate = Migrate(app, db)
@app.shell_context_processor
def _make_context():
return dict(app=app, db=db, User=User, Post=Post, Comment=Comment,
Tag=Tag)
@app.cli.command()
@click.option('--pattern', default=None, help='test files that match pattern will be loaded.')
def test(pattern):
""" project unit test """
import unittest
if pattern:
tests = unittest.TestLoader().discover('tests', pattern)
else:
tests = unittest.TestLoader().discover('tests')
unittest.TextTestRunner(verbosity=2).run(tests)
@app.cli.command("search-reindex")
def search_reindex():
""" reindex Posts searching use elasticsearch"""
Post.reindex()
@app.cli.command("deploy")
def deploy():
""" deloply project"""
db.create_all()