Code Monkey home page Code Monkey logo

flask-shellplus's Introduction

Flask-ShellPlus

Flask shell command based on Flask-Script to enhance its shell.

It will automatically use your favorite Python REPL shell instead of the default one. The order is BPython to ptiPython to IPython to ptPython to Python.

Deprecated!!!

原因:《初探 Flask 命令行接口》

Since Flask 0.11 released with builtin CLI, you should use it instead, and it is also very easy.

eg. You want to use IPython>=5.0 to provide a friendly REPL, just add a command:

import os
import click
from flask import Flask

app = Flask(__name__)

@app.cli.command()
def shell_plus():
    from IPython import embed
    embed(user_ns={'app': app, os: 'os'})

Then run flask shell_plus as the document leads, you'll get a REPL with app and os already imported.

Installation

pip is suggested:

pip install flask_shellplus

Usage

Use it with Flask-Script:

from flask_shellplus import Shell

def make_context():
    return dict(app=app, db=db, models=models)

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

Run this in your shell:

python manage.py shell

Flask-ShellPlus will find the first available one in BPython, ptiPython, IPython, ptPython, and Python.

Or you can manually define the preferred shell with flag --plain, --bpython, --ptipython, --ipython or --ptpython just like shell_plus in DjangoExtensions.

Enjoy it!

Links

flask-shellplus's People

Contributors

kxxoling avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

flask-shellplus's Issues

Autoimporting on setup.py makes pip install fail

This line in setup.py

from flask_shellplus import __version__ as version, __doc__ as description

finally tries to import six and flask which are requirements.

This fails when you are trying to install a new env with a requirements file (but also fails even when trying to install this single package while not having six and flask installed despite of they are in its requirements):
Pip makes two passes through requirements: first it downloads all packages and runs each one's setup.py to get its metadata, and then it installs them all in a second pass.

So, flask_shellplus is trying to import six and flask in its setup.py (because of autoimport's imports), but when pip first runs flask_shellplus setup.py, it has not yet installed either.

This is also why you don't see this error when you install the packages one by one: if you install them one at a time, six and flask will be fully installed in your environment before you pip install flask_shellplus.

Solution could be maintain the version in init and setup.py and write a short description just for setup.py

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.