コード例 #1
0
ファイル: tests.py プロジェクト: alekzvik/flask-script
 def test_run_with_default_command(self):
     manager = Manager(self.app)
     manager.add_command('simple', SimpleCommand())
     try:
         manager.run(default_command='simple')
     except SystemExit, e:
         assert e.code==0
コード例 #2
0
ファイル: test_script.py プロジェクト: olt/flask-assets
    def test_call(self):
        # Setup the webassets.script with a mock main() function,
        # so we can check whether our call via Flask-Script actually
        # goes through.
        def dummy_main(argv, *a, **kw):
            self.last_script_call = argv
            return 0
        from webassets import script
        old_main = script.main
        script.main = dummy_main

        try:
            mgmt = Manager(self.app)
            mgmt.add_command('assets', ManageAssets(self.env))

            try:
                # -h is a great test as that is something Flask-Script might
                # want to claim for itself.
                sys.argv = ['./manage.py', 'assets', '-h']
                mgmt.run()
            except SystemExit:
                # Always raised, regardless of success or failure of command
                pass
            assert self.last_script_call == ['-h']
        finally:
            script.main = old_main
コード例 #3
0
ファイル: tests.py プロジェクト: alekzvik/flask-script
 def test_run_catch_all(self):
     manager = Manager(self.app)
     manager.add_command("catch", CommandWithCatchAll())
     sys.argv = ["manage.py", "catch", "pos1", "--foo", "pos2", "--bar"]
     try:
         manager.run()
     except SystemExit, e:
         assert e.code == 0
コード例 #4
0
ファイル: tests.py プロジェクト: alekzvik/flask-script
    def test_get_usage_with_specified_usage(self):

        manager = Manager(self.app, usage="hello")
        manager.add_command("simple", SimpleCommand())

        usage = manager.get_usage()
        assert "simple     simple command" in usage
        assert "hello" in usage
コード例 #5
0
ファイル: tests.py プロジェクト: sbook/flask-script
 def test_command_with_custom_handle_method(self):
     manager = Manager(self.app)
     manager.add_command("handle", CommandWithCustomHandle())
     sys.argv = ["manage.py", "handle", "pos1", "pos2", "--bar"]
     try:
         manager.run()
     except SystemExit, e:
         assert e.code == 0
コード例 #6
0
ファイル: tests.py プロジェクト: alekzvik/flask-script
    def test_run_dynamic_options(self):

        manager = Manager(self.app)
        manager.add_command("simple", CommandWithDynamicOptions('Fred'))
        sys.argv = ["manage.py", "simple"]
        try:
            manager.run()
        except SystemExit, e:
            assert e.code == 0
コード例 #7
0
ファイル: tests.py プロジェクト: alekzvik/flask-script
    def test_run_good_options(self):

        manager = Manager(self.app)
        manager.add_command("simple", CommandWithOptions())
        sys.argv = ["manage.py", "simple", "--name=Joe"]
        try:
            manager.run()
        except SystemExit, e:
            assert e.code == 0
コード例 #8
0
ファイル: tests.py プロジェクト: alekzvik/flask-script
    def test_run_existing(self):

        manager = Manager(self.app)
        manager.add_command("simple", SimpleCommand())
        sys.argv = ["manage.py", "simple"]
        try:
            manager.run()
        except SystemExit, e:
            assert e.code == 0
コード例 #9
0
ファイル: tests.py プロジェクト: alekzvik/flask-script
    def test_run_bad_options(self):

        manager = Manager(self.app)
        manager.add_command("simple", CommandWithOptions())
        sys.argv = ["manage.py", "simple", "--foo=bar"]
        try:
            sys_stderr_orig = sys.stderr
            sys.stderr = StringIO.StringIO()
            manager.run()
        except SystemExit, e:
            assert e.code == 2
コード例 #10
0
def create_script():
    
    manager = Manager(create_app, with_default_commands=True)
    manager.add_option('-d', '--database', dest='database', required=False)
    manager.add_command('populate', PopulateDB())
    
    @manager.shell
    def _make_context():
        return dict(app=_request_ctx_stack.top.app, db=db, WTF=WTF)
    
    return manager
コード例 #11
0
    def test_call_auto_env(self):
        """Regression test: Passing the environment to the ManageAssets command
        is optional, it can be auto-detected."""
        mgmt = Manager(self.app)
        mgmt.add_command('assets', ManageAssets())

        try:
            # Used to raise an error due to the env not being properly set.
            sys.argv = ['./manage.py', 'assets', 'build']
            mgmt.run()
        except SystemExit:
            # Always raised, regardless of success or failure of command
            pass
コード例 #12
0
ファイル: test_script.py プロジェクト: aisipos/flask-assets
    def test_call_auto_env(self):
        """Regression test: Passing the environment to the ManageAssets command
        is optional, it can be auto-detected."""
        mgmt = Manager(self.app)
        mgmt.add_command('assets', ManageAssets())

        try:
            # Used to raise an error due to the env not being properly set.
            sys.argv = ['./manage.py', 'assets', 'rebuild']
            mgmt.run()
        except SystemExit:
            # Always raised, regardless of success or failure of command
            pass
コード例 #13
0
    def test_parse_templates(self):
        """Test the --parse-templates option.
        """
        # Create a file in the app's templates directory
        self.app.template_folder = self.path('templates')
        self.create_files({
            'templates/template.html': """
            {% assets "in", output="output" %}
                {{ ASSET_URL }}
            {% endassets %}
            """,
            'in': "foo"
        })

        # Run the build command with --parse-templates, which should pick
        # up the bundle we defined in above template.
        mgmt = Manager(self.app)
        mgmt.add_command('assets', ManageAssets(log=stdout_log))
        mgmt.handle('test', 'assets', ['--parse-templates', 'build'])

        assert self.exists('output')
コード例 #14
0
ファイル: test_script.py プロジェクト: 0x1997/flask-assets
    def test_parse_templates(self):
        """Test the --parse-templates option.
        """
        # Create a file in the app's templates directory
        self.app.template_folder = self.path('templates')
        self.create_files({
            'templates/template.html': """
            {% assets "in", output="output" %}
                {{ ASSET_URL }}
            {% endassets %}
            """,
            'in': "foo"
        })

        # Run the build command with --parse-templates, which should pick
        # up the bundle we defined in above template.
        mgmt = Manager(self.app)
        mgmt.add_command('assets', ManageAssets(log=stdout_log))
        mgmt.handle('test', 'assets', ['--parse-templates', 'build'])

        assert self.exists('output')
コード例 #15
0
ファイル: test_script.py プロジェクト: aisipos/flask-assets
    def test_call(self):
        # Setup the webassets.script with a mock main() function,
        # so we can check whether our call via Flask-Script actually
        # goes through.
        test_inst = self
        class DummyArgparseImplementation(GenericArgparseImplementation):
            def run_with_argv(self, argv):
                test_inst.last_script_call = argv
                return 0

        mgmt = Manager(self.app)
        mgmt.add_command('assets',
                ManageAssets(self.env, impl=DummyArgparseImplementation))

        try:
            # -h is a great test as that is something Flask-Script might
            # want to claim for itself.
            sys.argv = ['./manage.py', 'assets', '-h']
            mgmt.run()
        except SystemExit:
            # Always raised, regardless of success or failure of command
            pass
        assert self.last_script_call == ['-h']
コード例 #16
0
    def test_call(self):
        # Setup the webassets.script with a mock main() function,
        # so we can check whether our call via Flask-Script actually
        # goes through.
        test_inst = self

        class DummyArgparseImplementation(GenericArgparseImplementation):
            def run_with_argv(self, argv):
                test_inst.last_script_call = argv
                return 0

        mgmt = Manager(self.app)
        mgmt.add_command(
            'assets', ManageAssets(self.env, impl=DummyArgparseImplementation))

        try:
            # -h is a great test as that is something Flask-Script might
            # want to claim for itself.
            sys.argv = ['./manage.py', 'assets', '-h']
            mgmt.run()
        except SystemExit:
            # Always raised, regardless of success or failure of command
            pass
        assert self.last_script_call == ['-h']
コード例 #17
0
ファイル: manager.py プロジェクト: py-prj-code/jzsadmin
#!/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)
コード例 #18
0
#!/usr/bin/env python
"""
     Distrivia Test Runner
    ~~~~~~~~~~~~~~~~~~~~~~~
    A cool test runner for the unit tests.

    :copyright: (c) 2011 by Brian Gianforcaro, Steven Glazer, Sam Milton.
"""


from flaskext.script import Manager
from flaskext.zen import Test, ZenTest
from distrivia import app

manager = Manager(app)

manager.add_command( 'test', Test() )
manager.add_command( 'zen', ZenTest() )

if __name__ == '__main__':
    manager.run()
コード例 #19
0
ファイル: manage.py プロジェクト: so-called-quant/RTA
            try:
                from IPython.frontend.terminal.embed import InteractiveShellEmbed
                sh = InteractiveShellEmbed(banner1=self.banner)
                sh(global_ns=dict(), local_ns=context)
                return
            except ImportError:
                pass
        from code import interact
        interact(banner=self.banner, local=context)


class Test(Command):
    """
    Runs the application's unit tests.
    """
    def run(self):
        import os
        from unittest import TestLoader, TextTestRunner
        cur_dir = os.path.dirname(os.path.abspath(__file__))
        loader = TestLoader()
        test_suite = loader.discover(cur_dir)
        runner = TextTestRunner(verbosity=2)
        runner.run(test_suite)


del manager._commands['shell']
manager.add_command('shell', FixedShell())
manager.add_command('syncdb', SyncDB())
manager.add_command('test', Test())
manager.run()
コード例 #20
0
ファイル: manage.py プロジェクト: ralfonso/trombone
manager = Manager(app)

class DevServer(Server):
    description = "Run the local dev server"
    def handle(self, *args, **kwargs):
        super(DevServer, self).handle(*args, **kwargs)

class IShell(Shell):
    def run(self, no_ipython):
        """
        Runs the shell. Unless no_ipython is True or use_python is False
        then runs IPython shell if that is installed.
        """

        context = self.get_context()
        if not no_ipython:
            from IPython.frontend.terminal.embed import InteractiveShellEmbed
            sh = InteractiveShellEmbed(banner2=self.banner)
            sh(global_ns=dict(), local_ns=context)
            return

        code.interact(self.banner, local=context)

dev_server = DevServer(host='0.0.0.0', port=5001, use_debugger=True, use_reloader=True)
manager.add_command('rundev', dev_server)
manager.add_command('shell', IShell())

if __name__ == "__main__":
    manager.run()
コード例 #21
0
ファイル: manage.py プロジェクト: wangd/flacker

def _read_torrent_file(torrent_file_path):
    with open(torrent_file_path, 'rb') as f:
        info_dict = bdecode(f.read())['info']
        info_hash = sha1(bencode(info_dict)).hexdigest()
    return info_hash, info_dict


manager = Manager(create_app)
manager.add_option('-c',
                   '--config',
                   dest='config',
                   help='config file for flacker',
                   required='FLACKER_CONFIG' not in os.environ)
manager.add_command("shell", Shell(make_context=_make_context))
manager.add_command("runserver", Server())


@manager.option('-n', '--name', help='Torrent name')
@manager.option('-i', '--info-hash', help='Info hash of torrent')
@manager.option('-f', '--file', help='Torrent file', dest='torrent_file_path')
def add_torrent(name, info_hash, torrent_file_path):
    if torrent_file_path:
        torrent_file_path = os.path.join(os.getcwd(), torrent_file_path)
        if not os.path.isfile(torrent_file_path):
            print "The file %s does not exist." % torrent_file_path
            return
        info_hash, info_dict = _read_torrent_file(torrent_file_path)
        name = info_dict['name']
        if _add_torrent(name, info_hash, torrent_file_path):
コード例 #22
0
ファイル: tests.py プロジェクト: alekzvik/flask-script
    def test_get_usage(self):

        manager = Manager(self.app)
        manager.add_command("simple", SimpleCommand())

        assert "simple     simple command" in manager.get_usage()
コード例 #23
0
ファイル: manage.py プロジェクト: Genieliu/job-hunter
#!/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()

if __name__ == '__main__':
    manager.run()
コード例 #24
0
ファイル: tests.py プロジェクト: alekzvik/flask-script
    def test_run_existing_command(self):

        manager = Manager(self.app)
        manager.add_command("simple", SimpleCommand())
        manager.handle("manage.py", "simple")
        assert 'OK' in sys.stdout.getvalue()
コード例 #25
0
    """Works with iPython >= 0.12"""

    def run(self, no_ipython):
        context = self.get_context()
        if not no_ipython:
            try:
                from IPython.frontend.terminal.embed import InteractiveShellEmbed
                ipython_shell = InteractiveShellEmbed()
                return ipython_shell(global_ns=dict(), local_ns=context)
            except ImportError:
                pass

        code.interact(self.banner, local=context)


class Blueprint(Command):
    """Creates new blueprint package with the specified name"""

    def get_options(self):
        return [Option('-n', '--name', dest='name', required=True)]

    def run(self, name):
        BlueprintPackageFactory(name).build()


manager.add_command("shell", iShell())
manager.add_command("createblueprint", Blueprint())

if __name__ == "__main__":
    manager.run()
コード例 #26
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()

コード例 #27
0
ファイル: manage.py プロジェクト: staaas/widgets
from flask import Flask
from flaskext.babel import Babel
from flaskext.script import Manager

from fbgroup import facebook_group_widget
from fbgroup.management.update import UpdateCommand

app = Flask(__name__)
app.register_blueprint(facebook_group_widget, url_prefix='/fbgroup')

app.config.from_pyfile('settings.cfg')
app.config.from_envvar('WIDGETS_SETTINGS')

# i18n
babel = Babel(app)

# command-line management
manager = Manager(app)
manager.add_command('update', UpdateCommand())

if __name__ == "__main__":
    manager.run()

コード例 #28
0
ファイル: manage.py プロジェクト: mdeous/Bookmark-v2
from bookmark import app
from flaskext.script import Manager, Command
from bookmark.init import reset_all


manager = Manager(app)


class SyncDB(Command):
    def run(self):
        reset_all('sample.json')


manager.add_command('syncdb', SyncDB())
manager.run()
コード例 #29
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()
コード例 #30
0
ファイル: manager.py プロジェクト: kamoti01/tip
#!/usr/bin/env python
from flaskext.script import Manager, Shell, Server
from example import app

manager = Manager(app)
manager.add_command("runserver", Server())
manager.add_command("shell", Shell())
@manager.command
def createdb():
    from example.models import db
    db.create_all()
manager.run()
コード例 #31
0
ファイル: utils.py プロジェクト: HughePaul/Website
    def run(self):
        query = text("""select distinct "user".id from "user", ticket 
                        where ticket.user_id = "user".id and ticket.paid = true""")

        for row in db.engine.execute(query):
            user = User.query.filter_by(id=row[0]).one()
            msg = Message("Your Electromagnetic Field Ticket",
                          sender=app.config.get('TICKETS_EMAIL'),
                          recipients=[user.email]
                         )
            user.create_receipt()
            msg.body = render_template("ticket.txt", user = user)
            print "Sending to", user.email, "..."
            print msg.body


if __name__ == "__main__":
  manager.add_command('reconcile', Reconcile())
  manager.add_command('warnexpire', WarnExpire())
  manager.add_command('expire', Expire())
  manager.add_command('testemails', TestEmails())
  manager.add_command('createtickets', CreateTickets())
  manager.add_command('makeadmin', MakeAdmin())
  manager.add_command('prepayreminder', SendPrepayReminder())
  manager.add_command('addtokens', CreateTicketTokens())
  manager.add_command('createroles', CreateRoles())
  manager.add_command('createshifts', CreateShifts())
  manager.add_command('sendtickets', SendTickets())
  manager.run()
コード例 #32
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
コード例 #33
0
ファイル: tests.py プロジェクト: alekzvik/flask-script
    def test_add_command(self):

        manager = Manager(self.app)
        manager.add_command("simple", SimpleCommand())

        assert isinstance(manager._commands['simple'], SimpleCommand)
コード例 #34
0
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
コード例 #35
0
ファイル: manage.py プロジェクト: demostenes/ranking
app = create_app()


def _mk_shell_ctx():
    from flask import current_app
    rdata = current_app.extensions['ranking']
    return dict(
        app=app,
        db=rdata.model.db,
        tb=rdata.model.tb,
    )


manager = Manager(app)
manager.add_command("runserver", Server(host="0.0.0.0"))
manager.add_command("shell", Shell(make_context=_mk_shell_ctx))


@manager.command
def recreatedb():
    from flask import current_app
    rdata = current_app.extensions['ranking']
    db = rdata.model.db
    print 'Drop all'
    try:
        db.drop_all()
    except:
        pass
    print 'Create all'
    db.create_all()
コード例 #36
0
#!/usr/bin/env python
#coding=utf-8

import uuid

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

from pypress import create_app
from pypress.extensions import db
from pypress.models.users import User, UserCode

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

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

def _make_context():
    return dict(db=db)
manager.add_command("shell", Shell(make_context=_make_context))

@manager.command
def createall():
    "Creates database tables"
    db.create_all()

@manager.command
def dropall():
    "Drops all database tables"
    
    if prompt_bool("Are you sure ? You will lose all your data !"):
        db.drop_all()
コード例 #37
0
ファイル: manager.py プロジェクト: miller-time/pdx-acm
from flaskext.script import Manager, Server, Shell

from pdxacm.webapp import app, db
from pdxacm.models.fixtures import base_fixtures


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


manager = Manager(app)
manager.add_command("shell", Shell(make_context=_make_context))
manager.add_command("runserver", Server())


@manager.command
def initdb():
    db.drop_all()
    db.create_all()

    for fixture in base_fixtures.itervalues():
        db.session.add(fixture)
    db.session.commit()

if __name__ == "__main__":
    manager.run()
コード例 #38
0
ファイル: manage.py プロジェクト: wjiajia123/ScriptFan.com
#-*-coding:utf-8-*-
import os, sys
sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))

import logging
logging.basicConfig(level=logging.INFO)

from flaskext.script import Manager, Shell
from scriptfan import app, db, oid, config_app, dispatch_handlers, dispatch_apps

manager = Manager(app, with_default_commands=False)

def _make_context():
    return dict(app=app, db=db, oid=oid)

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

@manager.option('-c', '--config', dest='config', help='Configuration file name', default='scriptfan.cfg')
def runserver(config):
    config_app(app, config)
    dispatch_handlers(app)
    dispatch_apps(app)
    app.run(host='0.0.0.0')

@manager.option('-c', '--config', dest='config', help='Configuration file name', default='scriptfan.cfg')
def initdb(config='scriptfan.cfg'):
    config_app(app, config)

    try:
        db.drop_all()
        db.create_all()
コード例 #39
0
ファイル: manage.py プロジェクト: benlampert/vendorday
#Set the path
import os, sys
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))

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

manager = Manager(app)

#Turn on debugger by default and reloader
manager.add_command("runserver", Server(
	use_debugger = True,
	use_reloader = True,
	host = '0.0.0.0')
)

if __name__ == "__main__":
	manager.run()
コード例 #40
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()
コード例 #41
0
ファイル: utils.py プロジェクト: dekstop/Website
    
    t = "welcome-email.txt"
    print  "template:", t
    print
    output = render_template(t, user = {"name" : "J R Hartley", "email": "*****@*****.**"})
    print output

  def test(self, template, count, ref):
    cost = 30.00 * count
    basket = { "count" : count, "reference" : ref }
    output = render_template(template, basket=basket, user = {"name" : "J R Hartley"}, payment={"amount" : cost, "bankref": ref})
    print output.encode("utf-8")

class CreateTickets(Command):
    def run(self):
        try:
            prepay = TicketType.query.filter_by(name='Prepay Camp Ticket').one()
        except NoResultFound, e:
            prepay = TicketType('Prepay Camp Ticket', 250, 4, 30.00)
            db.session.add(prepay)
            db.session.commit()

        print 'Tickets created'


if __name__ == "__main__":
  manager.add_command('reconcile', Reconcile())
  manager.add_command('testemails', TestEmails())
  manager.add_command('createtickets', CreateTickets())
  manager.run()
コード例 #42
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',
コード例 #43
0
ファイル: manage.py プロジェクト: titainium/dandelion
#!/usr/bin/env python
#coding=utf-8

"""
file: manage.py
description: This file is used to handle the management of the site from shell, user
             can add shell command here, like 'runserver' etc.
author: Titainium Deng
date: 2011-6-8
"""

from flaskext.script import Server, Manager

from dandelion import create_app

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

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

if __name__ == "__main__":
    manager.run()
コード例 #44
0
ファイル: utils.py プロジェクト: SamLR/Website
    seen = {}
    s = None
    expired = Ticket.query.filter(Ticket.expires <= datetime.utcnow(), Ticket.paid == False).all()
    for t in expired:
      # test that the ticket has a payment... not all do.
      if t.payment:
        if t.payment.id not in seen:
          seen[t.payment.id] = True

    for p in seen:
      p = Payment.query.get(p)
      print "expiring %s payment %d" % (p.provider, p.id)
      p.state = "expired"
      if not s:
        s = db.object_session(p)

      for t in p.tickets:
        print "deleting expired %s ticket %d" % (t.type.name, t.id)
        s.delete(t)

    if s:
      s.commit()

if __name__ == "__main__":
  manager.add_command('reconcile', Reconcile())
  manager.add_command('warnexpire', WarnExpire())
  manager.add_command('expire', Expire())
  manager.add_command('testemails', TestEmails())
  manager.add_command('createtickets', CreateTickets())
  manager.run()
コード例 #45
0
# coding=utf-8

from flaskext.script import Manager, Server, Shell, prompt_bool
from example import app
from example.extensions import db

# 脚本管理
script_manager = Manager(app)
script_manager.add_command('runserver', Server('0.0.0.0', port=5000))

def _make_context():
    return { 'db':db }
script_manager.add_command("shell", Shell(make_context=_make_context))

@script_manager.command
def createall():
    "Creates database tables"
    db.create_all()

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

if __name__ == '__main__':
    script_manager.run()
コード例 #46
0
ファイル: manage.py プロジェクト: mayconbordin/boardhood
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',
コード例 #47
0
                                      "'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)


manager.add_command("runserver", Runserver())


@manager.command
def createdb():
    """Creates the database"""
    print >> sys.stderr, "Creating database...",

    from pdfserver import models, faketask, database
    database.init_db()

    print >> sys.stderr, "done"


if __name__ == "__main__":
    manager.run()
コード例 #48
0
"""
    :copyright: (c) 2011 Local Projects, all rights reserved
    :license: Affero GNU GPL v3, see LEGAL/LICENSE for more details.
"""

import os
os.environ.setdefault('FLAILS_ENV', 'script')

import main
from flaskext.script import Manager
from flaskext.assets import ManageAssets
from script.users import MakeAdmin

manager = Manager(main.app)
manager.add_command("assets", ManageAssets())
manager.add_command("make_admin", MakeAdmin())

if __name__ == "__main__":
    manager.run()