text: #!/usr/bin/env python
  import os
  import subprocess
  from config import Config
  
  from flask_migrate import Migrate, MigrateCommand
  from flask_script import Manager, Shell
  from redis import Redis
  from rq import Connection, Queue, Worker
  
  from app import create_app, db
  # from app.models import User
  
  app = create_app(os.getenv('FLASK_CONFIG') or 'default')
  manager = Manager(app)
  migrate = Migrate(app, db)
  
  manager.add_command('db', MigrateCommand)
  
  @manager.command
  def recreate_db():
      """
      Recreates a local database. You probably should not use this on
      production.
      """
      db.drop_all()
      db.create_all()
      db.session.commit()
  
  
  @manager.command
  def run_worker():
      """Initializes a slim rq task queue."""
      listen = ['default']
      conn = Redis(
          host=app.config['RQ_DEFAULT_HOST'],
          port=app.config['RQ_DEFAULT_PORT'],
          db=0,
          password=app.config['RQ_DEFAULT_PASSWORD'])
  
      with Connection(conn):
          worker = Worker(map(Queue, listen))
          worker.work()
  
  
  @manager.command
  def format():
      """Runs the yapf and isort formatters over the project."""
      isort = 'isort -rc *.py app/'
      yapf = 'yapf -r -i *.py app/'
  
      print('Running {}'.format(isort))
      subprocess.call(isort, shell=True)
  
      print('Running {}'.format(yapf))
      subprocess.call(yapf, shell=True)
  
  
  if __name__ == '__main__':
      manager.run()
  