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
def main(default_command='moin', wiki_config=None): """ console_script entry point """ from MoinMoin.app import create_app from flaskext.script import Manager, Server manager = Manager(create_app) manager.add_option('-c', '--config', dest='config', required=False, default=wiki_config) manager.add_option('-i', '--index-create', action='store_true', dest='create_index', required=False, default=False) manager.add_option('-s', '--storage-create', action='store_true', dest='create_storage', required=False, default=False) manager.add_command("moin", Server(host='127.0.0.1', port=8080)) from MoinMoin.script.maint import index manager.add_command("index-create", index.IndexCreate()) manager.add_command("index-build", index.IndexBuild()) manager.add_command("index-update", index.IndexUpdate()) manager.add_command("index-destroy", index.IndexDestroy()) manager.add_command("index-move", index.IndexMove()) manager.add_command("index-optimize", index.IndexOptimize()) manager.add_command("index-dump", index.IndexDump()) from MoinMoin.script.maint import serialization manager.add_command("save", serialization.Serialize()) manager.add_command("load", serialization.Deserialize()) from MoinMoin.script.account.create import Create_User manager.add_command("account_create", Create_User()) from MoinMoin.script.account.disable import Disable_User manager.add_command("account_disable", Disable_User()) from MoinMoin.script.account.resetpw import Set_Password manager.add_command("account_password", Set_Password()) from MoinMoin.script.maint.reduce_revisions import Reduce_Revisions manager.add_command("maint_reduce_revisions", Reduce_Revisions()) from MoinMoin.script.maint.set_meta import Set_Meta manager.add_command("maint_set_meta", Set_Meta()) from MoinMoin.script.maint import modify_item manager.add_command("item-get", modify_item.GetItem()) manager.add_command("item-put", modify_item.PutItem()) from MoinMoin.script.maint.modified_systemitems import Modified_SystemItems manager.add_command("maint_modified_systemitems", Modified_SystemItems()) from MoinMoin.script.migration.moin19.import19 import ImportMoin19 manager.add_command("import19", ImportMoin19()) from MoinMoin.script.maint.moinshell import MoinShell manager.add_command("shell", MoinShell()) return manager.run(default_command=default_command)
import os from flask import current_app from flaskext.script import Manager from frontend import create_app, models from frontend.emailForwarder.emailReader import EmailForwardService, EmailKeyReader, PostulacionGetEmailByEmailKeyQuery, EmailRepository, ForwardEmailBuilder from frontend.extensions import db manager = Manager(create_app) manager.add_option('-c', '--config', dest='config', required=False) @manager.command def run(): port = int(os.environ.get('PORT', 5000)) current_app.run(host='0.0.0.0', port=port) @manager.command def reset(): db.drop_all() db.create_all() from frontend.models import Macanudo @manager.command def runEmailForward(): forwardService = EmailForwardService(EmailRepository(),PostulacionGetEmailByEmailKeyQuery(), EmailKeyReader, ForwardEmailBuilder) forwardService.forwardAll()
from coqd.runner import main as coqd_main from cockerel.webapp import app from cockerel.utilities import new_app from cockerel.models import db, schema from cockerel.auth import principals def _make_context(): return dict(app=new_app(app), db=db, models=schema) manager = Manager(partial(new_app, app)) manager.add_command("shell", Shell(make_context=_make_context)) manager.add_command("runserver", Server()) manager.add_option('--serialize', action="store_true", default=False, help="Serialize output to JSON") @manager.command def initdb(): # A request_context is required to use these helper functions with new_app(app).request_context(create_environ()): db.drop_all() db.create_all() readaction = schema.Action("read") insertaction = schema.Action("insert") deleteaction = schema.Action("delete") editaction = schema.Action("edit") db.session.add(readaction) db.session.add(insertaction) db.session.add(deleteaction)
from_address = prompt("From", default="*****@*****.**") if prompt_bool("Are you sure ? Email will be sent to everyone!"): with mail.connect() as conn: for user in User.query: message = Message(subject=subject, body=message, sender=from_address, recipients=[user.email]) conn.send(message) @manager.shell def make_shell_context(): return dict(app=current_app, db=db, Post=Post, User=User, Tag=Tag, Comment=Comment) manager.add_option('-c', '--config', dest="config", required=False, help="config file") if __name__ == "__main__": manager.run()
message = prompt("Message") from_address = prompt("From", default="*****@*****.**") if prompt_bool("Are you sure ? Email will be sent to everyone!"): with mail.connect() as conn: for user in User.query: message = Message(subject=subject, body=message, sender=from_address, recipients=[user.email]) conn.send(message) @manager.shell def make_shell_context(): return dict(app=current_app, db=db, Post=Post, User=User, Tag=Tag, Comment=Comment) manager.add_option('-c', '--config', dest="config", required=False, help="config file") if __name__ == "__main__": manager.run()
role = prompt_choices("role", choices=choices, default="member") print "ROLE:", role @manager.command def getrole(): choices = ( (1, "member"), (2, "moderator"), (3, "admin"), ) role = prompt_choices("role", choices=choices, resolve=int, default=1) print "ROLE:", role @manager.option('-n', '--name', dest='name', help="your name") @manager.option('-u', '--url', dest='url', help="your url") def optional(name, url): "print name and url" print name, url manager.add_option("-c", "--config", dest="config", help="config file", required=False) manager.add_command("runservernoreload", Server(use_reloader=False)) if __name__ == "__main__": manager.run()
from flaskext.babel import Babel from flaskext.cache import Cache from flaskext.mail import Mail from flaskext.script import Manager from flask_collect import Collect from .app import create_app babel = Babel() cache = Cache() db = SQLAlchemy() main = Mail() manager = Manager(create_app) manager.add_option("-c", "--config", dest="config", required=False) collect = Collect() collect.init_script(manager) def config_extensions(app): " Init application with extensions. " cache.init_app(app) db.init_app(app) main.init_app(app) collect.init_app(app) config_babel(app)
os.path.remove(torrent_file_path) return True 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
from __future__ import unicode_literals import os from flask import current_app from flaskext.script import Manager, Server from stutuz import create_app class Serve(Server): description = 'Run the development server.' manager = Manager(create_app, with_default_commands=False) manager.add_option('-c', '--config', dest='config', default='stutuz.configs.development') manager.add_command('serve', Serve()) @manager.option('-r', '--reporter', metavar='NAME') @manager.option('args', nargs='*') def test(reporter, args): """Run all stutuz tests.""" from attest import get_reporter_by_name from tests import all all.run(get_reporter_by_name(reporter)(*args)) @manager.command def shell(): """Interactive stutuz console."""
# -*- coding: utf-8 -*- """ myapp.manager ============= This contains commands for the management script. :copyright: (C) 2011, Matthew Frazier :license: MIT/X11, see LICENSE for details """ from flask import current_app from flaskext.script import Manager from .application import create_app manager = Manager(create_app) manager.add_option('-c', '--config', dest='config', required=False)
if os.path.isfile(cfg_path): cfg = open(cfg_path).read() cfg = yaml.load(cfg) app.config.update(cfg) cfg_static_folder = os.path.join(app.config["SOURCE"], "_static") if os.path.isdir(cfg_static_folder): app.static_folder = cfg_static_folder def create_app(source): app.config["SOURCE"] = source load_yaml_config(app) load_modules(app) return app manager = Manager(create_app) manager.add_option("-s", "--source", dest="source", required=False, \ default=os.getcwd()) @manager.command @manager.option('-b', '--build', dest="build_destination", required=False) def build(build_destination=None): """Create a static version of the site with Frozen-Flask""" from flaskext.frozen import Freezer if build_destination is not None: app.config['FREEZER_DESTINATION'] = build_destination else: app.config['FREEZER_DESTINATION'] = os.path.join(app.config["SOURCE"], "_build") freezer = Freezer(app) freezer.freeze() def main(): manager.run()
torrent_file_path = os.path.join(current_app.instance_path, info_hash + '.torrent') if os.path.isfile(torrent_file_path): os.path.remove(torrent_file_path) return True 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']
from flaskext.script import Manager from concierge import create_app, db manager = Manager(create_app) manager.add_option("-c", "--config", dest="cfg", required=False) @manager.shell def make_shell_context(): from flask import current_app from concierge.auth import User from concierge.services import Service return dict(app=current_app, db=db, User=User, Service=Service) @manager.command def syncdb(): """Creates missing database tables.""" db.create_all() @manager.command def resetdb(): """Drops and creates the database.""" db.drop_all() db.create_all()