Created
September 26, 2011 18:18
-
-
Save kra3/1242925 to your computer and use it in GitHub Desktop.
bpython_to_web2py.patch
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
# HG changeset patch | |
# User Arun K Rajeevan <the1.arun@gmail.com> | |
# Date 1302552098 -19800 | |
# Node ID fa92d22264a58dd6b232c28b1dd4c78f8ee62c4f | |
# Parent d3dc0e7da9aac20f5bab6f2d61afcb78b2444a47 | |
added bpython support | |
diff -r d3dc0e7da9aa -r fa92d22264a5 gluon/shell.py | |
--- a/gluon/shell.py Mon Apr 11 09:13:22 2011 -0500 | |
+++ b/gluon/shell.py Tue Apr 12 01:31:38 2011 +0530 | |
@@ -144,6 +144,7 @@ | |
plain=False, | |
import_models=False, | |
startfile=None, | |
+ bpython=False | |
): | |
""" | |
Start interactive shell or run Python script (startfile) in web2py | |
@@ -203,6 +204,15 @@ | |
print e.traceback | |
else: | |
if not plain: | |
+ if bpython: | |
+ try: | |
+ import bpython | |
+ bpython.embed(locals_=_env) | |
+ return | |
+ except: | |
+ logger.warning( | |
+ 'import bpython error; trying ipython...') | |
+ | |
try: | |
import IPython | |
# following 2 lines fix a problem with IPython; thanks Michael Toomim | |
@@ -332,6 +342,17 @@ | |
parser.add_option('-S', '--shell', dest='shell', metavar='APPNAME', | |
help='run web2py in interactive shell or IPython(if installed) ' + \ | |
'with specified appname') | |
+ msg = 'run web2py in interactive shell or bpython (if installed) with' | |
+ msg += ' specified appname (if app does not exist it will be created).' | |
+ msg += '\n Use combined with --shell' | |
+ parser.add_option( | |
+ '-B', | |
+ '--bpython', | |
+ action='store_true', | |
+ default=False, | |
+ dest='bpython', | |
+ help=msg, | |
+ ) | |
parser.add_option( | |
'-P', | |
'--plain', | |
@@ -369,7 +390,7 @@ | |
startfile = args[0] | |
else: | |
startfile = '' | |
- run(options.shell, options.plain, startfile=startfile) | |
+ run(options.shell, options.plain, startfile=startfile, bpython=options.bpython) | |
if __name__ == '__main__': | |
diff -r d3dc0e7da9aa -r fa92d22264a5 gluon/widget.py | |
--- a/gluon/widget.py Mon Apr 11 09:13:22 2011 -0500 | |
+++ b/gluon/widget.py Tue Apr 12 01:31:38 2011 +0530 | |
@@ -585,6 +585,16 @@ | |
metavar='APPNAME', | |
help=msg) | |
+ msg = 'run web2py in interactive shell or bpython (if installed) with' | |
+ msg += ' specified appname (if app does not exist it will be created).' | |
+ msg += '\n Use combined with --shell' | |
+ parser.add_option('-B', | |
+ '--bpython', | |
+ action='store_true', | |
+ default=False, | |
+ dest='bpython', | |
+ help=msg) | |
+ | |
msg = 'only use plain python shell; should be used with --shell option' | |
parser.add_option('-P', | |
'--plain', | |
@@ -790,7 +800,7 @@ | |
if options.shell: | |
if options.args!=None: | |
sys.argv[:] = options.args | |
- run(options.shell, plain=options.plain, | |
+ run(options.shell, plain=options.plain, bpython=options.bpython, | |
import_models=options.import_models, startfile=options.run) | |
return | |
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
146a147 | |
> bpython=False | |
205a207,215 | |
> if bpython: | |
> try: | |
> import bpython | |
> bpython.embed(locals_=_env) | |
> return | |
> except: | |
> logger.warning( | |
> 'import bpython error; trying ipython...') | |
> | |
334a345,355 | |
> msg = 'run web2py in interactive shell or bpython (if installed) with' | |
> msg += ' specified appname (if app does not exist it will be created).' | |
> msg += '\n Use combined with --shell' | |
> parser.add_option( | |
> '-B', | |
> '--bpython', | |
> action='store_true', | |
> default=False, | |
> dest='bpython', | |
> help=msg, | |
> ) | |
372c393 | |
< run(options.shell, options.plain, startfile=startfile) | |
--- | |
> run(options.shell, options.plain, startfile=startfile, bpython=options.bpython) |
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
587a588,597 | |
> msg = 'run web2py in interactive shell or bpython (if installed) with' | |
> msg += ' specified appname (if app does not exist it will be created).' | |
> msg += '\n Use combined with --shell' | |
> parser.add_option('-B', | |
> '--bpython', | |
> action='store_true', | |
> default=False, | |
> dest='bpython', | |
> help=msg) | |
> | |
793c803 | |
< run(options.shell, plain=options.plain, | |
--- | |
> run(options.shell, plain=options.plain, bpython=options.bpython, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment