简体   繁体   English

如何从命令行访问Google App Engine的开发服务器数据

[英]How to access Google App Engine's dev server data from the command line

I regularly download my Google App Engine production data locally (using a custom script that basically calls appcfg.py download_data ) and upload it to the development server so that the data in my development environment matches production. 我会定期在本地下载Google App Engine生产数据(使用一个自定义脚本,该脚本基本上调用appcfg.py download_data )并将其上传到开发服务器,以使开发环境中的数据与生产匹配。 You can find the scripts on Launchpad: 您可以在启动板上找到脚本:

This is what the launcher script does: 这是启动器脚本的作用:

  • Start the dev server (flushing the database) 启动开发服务器(刷新数据库)
  • Load the previously downloaded models to the local database 将先前下载的模型加载到本地数据库
  • Change the passwords of all normal and admin users so that we can log in with a password of "toto" for any user in the development environment. 更改所有普通用户和管理员用户的密码,以便我们可以为开发环境中的任何用户使用“ toto”密码登录。 This is done with a script that accesses the freshly-loaded datastore data directly. 这可以通过脚本直接访问新加载的数据存储区数据来完成。

Everything was working fine until GAE 1.5.2. 一切正常,直到GAE 1.5.2。 At that point the development server changed to prefix dev~ , so I added --default_partition='' to launch the dev server. 在这一点上开发服务器更改为前缀dev~ ,所以我加了--default_partition=''启动开发服务器。 However now the password-changing script seems to not access the loaded data, it always returns 0 entities for normal or admin users. 但是,现在更改密码的脚本似乎无法访问已加载的数据,对于普通用户或管理员用户,它始终返回0个实体。 I'm wondering how to access the data from the command line, so explicitely not from an url to prevent this from ever happening on the production server. 我想知道如何从命令行访问数据,因此明确地不是从url访问数据,以防止在生产服务器上发生这种情况。 The scripts in ./extra are not uploaded to GAE, they can thus not be executed from there. ./extra中的脚本不会上载到GAE,因此无法从那里执行。

To give you an idea (but look at the script for more context), this is what the script used to do (and was working until GAE <= 1.5.1): 为了给您一个主意(但请查看脚本以获取更多上下文),这是该脚本曾经做过的事情(一直有效到GAE <= 1.5.1为止):

args, option_dict = ParseArguments(['', colCasaBasePath])
config, matcher = LoadAppConfig(colCasaBasePath, {})
SetupStubs(config.application, **option_dict)

The the application's models can be accessed just normally: 可以正常访问应用程序的模型:

from src.models import WebUser, ScyllaUser
for tipo in (WebUser, ScyllaUser):
    usuarios = tipo.all()
    # Now len(usuarios) == 0

What has been changed (after GAE 1.5.1) that breaks my GAE data-accessing script? (在GAE 1.5.1之后)更改了哪些内容,从而破坏了我的GAE数据访问脚本? How would you perform such a workflow? 您将如何执行这样的工作流程?

The trick is to add the --default_partition= argument to the ParseArguments() call in the script that accesses the GAE data: 诀窍是在访问GAE数据的脚本中将--default_partition=参数添加到ParseArguments()调用中:

args, option_dict = ParseArguments(['', colCasaBasePath, "--default_partition="])

Note that there is nothing after the = , that's what put me off. 请注意, =之后没有任何内容,这就是让我失望的原因。 I first tried adding "--default_partition=''" , but that didn't have any effect (but also didn't result in errors). 我首先尝试添加"--default_partition=''" ,但这没有任何效果(但也没有导致错误)。

After adding that call the script is again able to loop over all the users that have been loaded in the dev datastore. 添加该调用之后,脚本再次能够遍历已在dev数据存储区中加载的所有用户。 You can see the changes I had to make on Launchpad . 您可以在Launchpad上看到我必须进行的更改。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从谷歌应用引擎开发应用服务器批量下载 - How to bulk download from google app engine dev app server Google App Engine尝试访问开发数据 - Google App Engine trying to access dev data 如何从命令行监控谷歌应用引擎? - How to monitor google app engine from command line? 如何从App Engine的Python Dev_server解码持久日志文件 - How to decode the persisted log files from App Engine's Python Dev_server 在Google App Engine开发服务器上访问BigQuery - Accessing BigQuery on Google App Engine dev server 从命令行Java应用程序上传到Google App Engine中的BlobStore - Uploading to BlobStore in Google App Engine from a Command Line Java Application 如何在 Eclipse 中或从命令行运行 Google App Engine 的 Python 代码覆盖率测试 - How to run Python code coverage tests for Google App Engine in Eclipse or from command line Google App Engine开发服务器删除了virtualenv的网站程序包 - Google App Engine dev server drops virtualenv's site-packages 删除由Google App Engine的dev_appserver.py生成的本地数据 - Delete local data generated by Google App Engine's dev_appserver.py 安装第三方库以在Google App Engine开发服务器内外均可使用 - Install third party libs to be available from within and without the Google App Engine dev server
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM