-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Every manage-<example>.py file used werkzeug.script a deprecated (and now definitely removed) module. The new cli are powered by click [1] [1]: https://github.com/pallets/click Signed-off-by: Antonio Ossa <aaossa@uc.cl>
- Loading branch information
Showing
9 changed files
with
386 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,69 @@ | ||
#!/usr/bin/env python | ||
from werkzeug import script | ||
import click | ||
from werkzeug.serving import run_simple | ||
|
||
|
||
def make_app(): | ||
from couchy.application import Couchy | ||
return Couchy('http://localhost:5984') | ||
|
||
|
||
def make_shell(): | ||
from couchy import models, utils | ||
application = make_app() | ||
return locals() | ||
|
||
action_runserver = script.make_runserver(make_app, use_reloader=True) | ||
action_shell = script.make_shell(make_shell) | ||
action_initdb = lambda: make_app().init_database() | ||
|
||
script.run() | ||
@click.group() | ||
def cli(): | ||
pass | ||
|
||
|
||
@cli.command() | ||
def initdb(): | ||
from couchy.application import Couchy | ||
Couchy('http://localhost:5984').init_database() | ||
|
||
|
||
@cli.command() | ||
@click.option('-h', '--hostname', type=str, default='localhost', help="localhost") | ||
@click.option('-p', '--port', type=int, default=5000, help="5000") | ||
@click.option('--no-reloader', is_flag=True, default=False) | ||
@click.option('--debugger', is_flag=True) | ||
@click.option('--no-evalex', is_flag=True, default=False) | ||
@click.option('--threaded', is_flag=True) | ||
@click.option('--processes', type=int, default=1, help="1") | ||
def runserver(hostname, port, no_reloader, debugger, no_evalex, threaded, processes): | ||
"""Start a new development server.""" | ||
app = make_app() | ||
reloader = not no_reloader | ||
evalex = not no_evalex | ||
run_simple(hostname, port, app, | ||
use_reloader=reloader, use_debugger=debugger, | ||
use_evalex=evalex, threaded=threaded, processes=processes) | ||
|
||
|
||
@cli.command() | ||
@click.option('--no-ipython', is_flag=True, default=False) | ||
def shell(no_ipython): | ||
"""Start a new interactive python session.""" | ||
banner = 'Interactive Werkzeug Shell' | ||
namespace = make_shell() | ||
if not no_ipython: | ||
try: | ||
try: | ||
from IPython.frontend.terminal.embed import InteractiveShellEmbed | ||
sh = InteractiveShellEmbed.instance(banner1=banner) | ||
except ImportError: | ||
from IPython.Shell import IPShellEmbed | ||
sh = IPShellEmbed(banner=banner) | ||
except ImportError: | ||
pass | ||
else: | ||
sh(local_ns=namespace) | ||
return | ||
from code import interact | ||
interact(banner, local=namespace) | ||
|
||
if __name__ == '__main__': | ||
cli() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.