Skip to content

Commit

Permalink
create shell task
Browse files Browse the repository at this point in the history
  • Loading branch information
dternyak committed Sep 30, 2018
1 parent 1f6d159 commit 256e26b
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 4 deletions.
33 changes: 33 additions & 0 deletions scripts/interpreter
100644 → 100755
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env python
"""isort:skip_file
"""
import os
import sys; sys.path.append(os.path.join(os.path.abspath(os.path.dirname(__file__)), "..")) # noqa

import readline
from code import InteractiveConsole

from molten.contrib.sqlalchemy import Session

from index import create_app

app = create_app()
resolver = app.injector.get_resolver()


@resolver.resolve
def get_session(session: Session):
return session


helpers = {
"app": app,
"resolver": resolver,
"session": get_session(),
}

readline.parse_and_bind("tab: complete")
interpreter = InteractiveConsole(helpers)
interpreter.interact(f"""\
Instances in scope: {", ".join(helpers)}.
""", "")
14 changes: 10 additions & 4 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,17 @@ def test(c, cov=False, verbose=False):
pytest_command += ' --cov=api'
if verbose:
pytest_command += ' -s '
c.run(pytest_command)
c.run(pytest_command, pty=True)


@task
def start(c, log_level='info'):
gunicorn_command = 'export ENVIRONMENT=common && gunicorn --reload app:app'
def start(c, log_level='info', port=5000):
gunicorn_command = 'export ENVIRONMENT=common && export PORT={} && gunicorn --reload app:app'.format(port)
gunicorn_command += ' --log-level={}'.format(log_level)
c.run(gunicorn_command)
c.run(gunicorn_command, pty=True)


@task
def shell(c):
command = 'export ENVIRONMENT="common" && ./scripts/interpreter'
c.run(command, pty=True)

0 comments on commit 256e26b

Please sign in to comment.