Exemple #1
0
    def handle(self, app_, *args, **kwargs):
        if app_.config['DATABASE'].startswith('sqlite:///'):
            file_path = app_.config['DATABASE'].replace('sqlite:///', '')
            if not os.path.exists(file_path):
                print >> sys.stderr, ("Database not found, "
                                      "you should probably run "
                                      "'python manage.py createdb' first!")
                sys.exit(1)

        if not os.path.exists(app_.config['UPLOAD_TO']):
            print >> sys.stderr, ("Upload directory %r not found. "
                                  "You need to create it first!" %
                                  app_.config['UPLOAD_TO'])
            sys.exit(1)

        if not app_.config['SECRET_KEY']:
            app_.config['SECRET_KEY'] = 'development key'

        Server.handle(self, app_, *args, **kwargs)
Exemple #2
0
    def handle(self, app_, *args, **kwargs):
        if app_.config['DATABASE'].startswith('sqlite:///'):
            file_path = app_.config['DATABASE'].replace('sqlite:///', '')
            if not os.path.exists(file_path):
                print >>sys.stderr, ("Database not found, "
                                     "you should probably run "
                                     "'python manage.py createdb' first!")
                sys.exit(1)

        if not os.path.exists(app_.config['UPLOAD_TO']):
            print >>sys.stderr, ("Upload directory %r not found. "
                                    "You need to create it first!"
                                    % app_.config['UPLOAD_TO'])
            sys.exit(1)


        if not app_.config['SECRET_KEY']:
            app_.config['SECRET_KEY'] = 'development key'

        Server.handle(self, app_, *args, **kwargs)
Exemple #3
0
#!/usr/bin/env python
# coding: utf-8

from jzsadmin import create_app
from jzsadmin.models import User, Entry
from jzsadmin.scripts.crawl_ganji import crawl_ganji

from flaskext.script import Server, Shell, Manager, Command, prompt_bool

manager = Manager(create_app('dev.cfg'))

manager.add_command("runserver", Server('0.0.0.0', port=8080))


@manager.option('-u', '--username', dest='name', type=str)
@manager.option('-p', '--password', dest='passwd', type=str)
@manager.option('-r', '--role', dest='role', default=100, type=int)
def adduser(name, passwd, role):
    user = User(name=name, password=passwd, role=role)
    user.save()
    print 'Created'


@manager.option('-u', '--username', dest='name', type=str)
def deluser(name):
    user = User.query.filter_by(name=name).first()
    user.remove()
    print 'Del.'


@manager.option('-c', '--city', dest='city', type=str)
Exemple #4
0
 def get_options(self):
     return (Option('site'),) + BaseServer.get_options(self)
Exemple #5
0
import memcache
import sys, os, signal
import subprocess
import time

from subprocess import call, Popen, PIPE
from flask import Flask, current_app as app
from flask import Config
from flaskext.script import Server, Shell, Manager, Command, prompt_bool
from memcached_stats import MemcachedStats

from boardhood import create_app
from boardhood.helpers.os import children_pid

manager = Manager(create_app('development'))
manager.add_command("runserver", Server('127.0.0.1',port=5000))

sql_files_91 = [
        '/usr/share/postgresql/9.1/contrib/postgis-1.5/postgis.sql',
        '/usr/share/postgresql/9.1/contrib/postgis-1.5/spatial_ref_sys.sql',
        '/usr/share/postgresql/9.1/contrib/postgis_comments.sql',
        'db/schema.sql',
        'db/extras.sql',
        'db/functions.sql',
        'db/sample.sql'
]

sql_files_84 = [
        '/usr/share/postgresql/8.4/contrib/postgis-1.5/postgis.sql',
        '/usr/share/postgresql/8.4/contrib/postgis-1.5/spatial_ref_sys.sql',
        '/usr/share/postgresql/8.4/contrib/postgis_comments.sql',
Exemple #6
0
from app.extensions import db
from app import create_app
from config import DevConfig, ProdConfig
from app.user import User, UserDetail, ADMIN, USER, ACTIVE

#env = os.environ.get('APP_ENV', 'prod')  # {dev, prod}
#app = create_app(eval('%sConfig' % env.capitalize()))
#manager = Manager(app)

app = create_app()
manager = Manager(app)

#manager = Manager(create_app())
#app = create_app()
manager.add_command("run",
                    Server(host=app.config['HOST'], port=app.config['PORT']))
manager.add_command("shell", Shell())


@manager.command
def initdb():
    """Init/reset database."""

    if not prompt_bool("Are you sure? You will lose all your data!"):
        return

    db.drop_all()
    db.create_all()

    demo = User(
        username=u'demo',
Exemple #7
0
#!/usr/bin/env python2

from flaskext.script import Shell, Server, Manager
from dagcuss import app
from dagcuss import dynagraph
from dagcuss import initialise

manager = Manager(app)


@manager.command
def rundynagraph():
    "Runs the Dynagraph zmq powered DAG layout server."
    dynagraph.server()


@manager.command
def initdb(addtestuser=False, testrepliesnum=0):
    ("Initialises the database with the essential data and optionally some "
     "test data")
    initialise.database(bool(addtestuser), int(testrepliesnum))


manager.add_command("runserver", Server())
manager.add_command("shell", Shell())

if __name__ == "__main__":
    manager.run()
Exemple #8
0
import subprocess

from flaskext.script import Manager, Server
from . import app
from .freezer import freezer

manager = Manager(app, with_default_commands=False)

# I prefer shorter names
manager.add_command('run', Server())


@manager.command
def freeze(serve=False):
    """Freezes the static version of the website."""
    if serve:
        freezer.run(debug=True)
    else:
        urls = freezer.freeze()
        print 'Built %i files.' % len(urls)


@manager.command
def up(destination='hako:http/exyr.org/htdocs/'):
    """Freezes and uploads the website."""
    push = subprocess.Popen(['git', 'push'],
                            stdout=subprocess.PIPE,
                            stderr=subprocess.STDOUT)
    print '### Freezing'
    freeze()
    print '### Uploading to', destination
Exemple #9
0
# coding: utf-8
from flaskext.script import Manager, Server, prompt_bool
from feather import app, db

manager = Manager(app)
server = Server(host='0.0.0.0', port=8888)
manager.add_command("runserver", server)


@manager.command
def createall():
    db.create_all()


@manager.command
def dropall():
    if prompt_bool(u"警告:你将要删除全部的数据!你确定否?"):
        db.drop_all()


if __name__ == "__main__":
    manager.run()
Exemple #10
0
#!/usr/bin/env python
#coding=utf-8

from flask import Flask, current_app
from flaskext.script import Command, Manager, Server, Shell, prompt_bool

from hunt import create_app
from hunt.extensions import db

manager = Manager(create_app('configure.cfg'))
manager.add_command('runserver', Server('127.0.0.1', port=9999))


def _make_context():
    return dict(db=db)


manager.add_command('shell', Shell(make_context=_make_context))


@manager.command
def createall():
    db.create_all()


@manager.command
def dropall():
    if prompt_bool("Are you sure ? You will lose all your data !"):
        db.drop_all()

manager = Manager(app)

#
# Here the manager should only be concerned with things related to managing.
# Leave the act of loading setting to be done within the app itself.
#
# We do use an environment setting to indicate the server should start in
# debug mode.
#
# Also note that virtualenv is required here.
#
if "MYAPP_DEBUG" not in os.environ or os.environ["MYAPP_DEBUG"] == "FALSE":
    print("Starting server in production mode.")
    print("Use 'fab start_dev_server' to start the dev server.")
    
    manager.add_command("runserver", Server(port=8080, use_reloader=False))
else:
    manager.add_command("runserver", Server(port=8080, use_reloader=True))

if __name__ == "__main__":
    if "VIRTUAL_ENV" not in os.environ:
        print("""
        Virtualenv has not been activated.
        
        Please activate it prior to running manage.py.
        This is for development stability.
        
        Typically you should use fabric to interact with manage.py as
        fabric will activate the environment automatically.
        
        If you would like to manually interact with manage.py please