python Google App Engine交互式python shell

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python Google App Engine交互式python shell相关的知识,希望对你有一定的参考价值。

"""
Opens a python shell with an active app engine environment which allows 
querying the local datastore.

Usage:
    python -i appengine_shell.py [path-to-datastore-file]
"""

import sys
import os

sys.path.append(os.path.expanduser('~/bin/google_appengine'))
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), 'src/')))


def main(datastore_file_path):
    from google.appengine.ext import testbed
    tb = testbed.Testbed()
    tb.activate()
    tb.init_datastore_v3_stub(datastore_file=datastore_file_path, use_sqlite=True)
    tb.init_memcache_stub()


if __name__ == '__main__':
    run = len(sys.argv) == 2

    if len(sys.argv) < 2:
        print 'Not enough arguments. Specify the path to the datastore file.'
    elif len(sys.argv) > 2:
        print 'To many arguments. Only specify the path to the datastore file.'

    if run:
        main(sys.argv[1])
    else:
        exit()

以上是关于python Google App Engine交互式python shell的主要内容,如果未能解决你的问题,请参考以下文章

python 将Google App Engine SDK添加到Python virtualenv

python Google App Engine:将CSV导入数据存储区

google-app-engine:google api python客户端hello world中的ImportError httplib2

Google App Engine 标准 Python 云构建

Google App Engine - 大查询 - Python 找不到库 google.cloud

Python 2.5 Google App Engine [关闭]