Skip to content

Commit 514842d

Browse files
committed
barebones structure with asynctasks and db
1 parent 77d3b9b commit 514842d

18 files changed

+308
-0
lines changed

MANIFEST.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
recursive-include recastfrontend/templates *
2+
recursive-include recastfrontend/static *
3+
recursive-include recastfrontend/resources *

recastfrontend/__init__.py

Whitespace-only changes.

recastfrontend/admincli.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import click
2+
import IPython
3+
import os
4+
5+
@click.group()
6+
def admincli():
7+
pass
8+
9+
@admincli.command()
10+
@click.option('--config','-c')
11+
def dbshell(config):
12+
if config:
13+
os.environ['RECASTCONTROLCENTER_CONFIG'] = config
14+
from recastfrontend.server import app
15+
with app.app_context():
16+
from recastfrontend.server import db
17+
import recastfrontend.models as models
18+
print "models and db modules are available"
19+
IPython.embed()
20+
21+
@admincli.command()
22+
@click.option('--config','-c')
23+
def create_db(config):
24+
if config:
25+
os.environ['RECASTCONTROLCENTER_CONFIG'] = config
26+
from recastfrontend.server import app
27+
with app.app_context():
28+
from recastfrontend.server import db
29+
db.create_all()
30+
click.secho('created database at: {}'.format(db.engine.url), fg = 'green')

recastfrontend/asynctasks.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from celery import shared_task
2+
3+
@shared_task
4+
def hello_world():
5+
print "hello world"

recastfrontend/celeryapp.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from celery import Celery
2+
app = Celery('frontendcelery')
3+
app.config_from_object('recastfrontend.celeryconfig')

recastfrontend/celeryconfig.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from recastfrontend.frontendconfig import config as frontendconf
2+
3+
BROKER_URL = 'redis://' + frontendconf['HOSTNAME']
4+
CELERY_RESULT_BACKEND = "redis"
5+
CELERY_REDIS_HOST = frontendconf['HOSTNAME']
6+
CELERY_REDIS_PORT = 6379
7+
CELERY_REDIS_DB = 0
8+
CELERY_TRACK_STARTED = True

recastfrontend/database.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
from flask.ext.sqlalchemy import SQLAlchemy
2+
db = SQLAlchemy()

recastfrontend/flaskconfig.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from recastfrontend.frontendconfig import config as frontendconf
2+
3+
DEBUG = True
4+
SECRET_KEY = 'some_secret'
5+
SQLALCHEMY_DATABASE_URI = 'sqlite:///'+frontendconf['DBPATH']

recastfrontend/frontendcli.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import click
2+
import os
3+
4+
@click.group()
5+
def frontendcli():
6+
pass
7+
8+
@frontendcli.command()
9+
@click.option('--config','-c')
10+
def server(config):
11+
if config:
12+
os.environ['RECASTCONTROLCENTER_CONFIG'] = config
13+
from server import app
14+
app.run(host='0.0.0.0',port = 5000)

recastfrontend/frontendconfig.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import os
2+
import pkg_resources
3+
import yaml
4+
5+
def default_config():
6+
return yaml.load(open(pkg_resources.resource_filename('recastfrontend','resources/defaultconfig.yaml')))
7+
8+
9+
def mk_config():
10+
the_config = default_config()
11+
if os.environ.has_key('RECASTCONTROLCENTER_CONFIG'):
12+
custom_config = yaml.load(open(os.environ['RECASTCONTROLCENTER_CONFIG']))
13+
the_config.update(**custom_config)
14+
return the_config
15+
16+
config = mk_config()

0 commit comments

Comments
 (0)