上传 Google App Engine 应用程序时出错

Posted

技术标签:

【中文标题】上传 Google App Engine 应用程序时出错【英文标题】:Error uploading Google App Engine Application 【发布时间】:2014-03-11 20:02:11 【问题描述】:

我正在使用普通命令在 Google App Engine 中上传我的应用程序(Python 2.7,SDK 1.8.9):

appcfg.py --oauth2 update .

但在我的项目中重构后,app.yaml (here is the code) 的正则表达式出现错误

错误是:

02:00 AM Application: sandengine; version: dev
02:00 AM Host: appengine.google.com
02:00 AM Starting update of app: sandengine, version: dev
02:00 AM Getting current resource limits.
02:00 AM Scanning files on local disk.
Traceback (most recent call last):
  File "/usr/local/bin/appcfg.py", line 199, in <module>
    run_file(__file__, globals())
  File "/usr/local/bin/appcfg.py", line 195, in run_file
    execfile(script_path, globals_)
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/appcfg.py", line 4933, in <module>
main(sys.argv)
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/appcfg.py", line 4924, in main
result = AppCfgApp(argv).Run()
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/appcfg.py", line 2648, in Run
self.action(self)
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/appcfg.py", line 4604, in __call__
return method()
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/appcfg.py", line 3419, in Update
self._UpdateWithParsedAppYaml(appyaml, self.basepath)
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/appcfg.py", line 3466, in _UpdateWithParsedAppYaml
self.UpdateVersion(rpcserver, basepath, appyaml, APP_YAML_FILENAME)
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/appcfg.py", line 3357, in UpdateVersion
return appversion.DoUpload(paths, openfunc)
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/appcfg.py", line 2143, in DoUpload
self._AddFilesThatAreSmallEnough(paths, openfunc)
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/appcfg.py", line 2211, in _AddFilesThatAreSmallEnough
file_classification = FileClassification(self.config, path)
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/appcfg.py", line 257, in __init__
self.__static_mime_type = self.__GetMimeTypeIfStaticFile(config, filename)
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/appcfg.py", line 287, in __GetMimeTypeIfStaticFile
if re.match(regex, filename):
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/re.py", line 137, in match
return _compile(pattern, flags).match(string)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/re.py", line 242, in _compile
raise error, v # invalid expression
sre_constants.error: bogus escape: '\\1'

【问题讨论】:

【参考方案1】:

通过在此处打印,很容易找出 app.yaml 的哪个文件存在问题。

/home/nburn42/Apps/google_appengine/google/appengine/tools/appcfg.py

第 315 行

这可能有点矫枉过正,但它肯定会让你摆脱困境。

【讨论】:

【参考方案2】:

dev 是保留关键字。更改版本,而不是 dev 使用数字或小写字符串。

它对我有用

【讨论】:

【参考方案3】:

这是一个正则表达式错误,在上传中:你不能使用\1或\2

这里是修复:https://github.com/coto/gae-boilerplate/commit/7fbcba2cb217f8ccd8ced7bfe634b4aceaf616c6

【讨论】:

【参考方案4】:

不要用“dev”作为版本号,试着输入一个实际的数字:)

【讨论】:

以上是关于上传 Google App Engine 应用程序时出错的主要内容,如果未能解决你的问题,请参考以下文章

与 Google App Engine 一起上传图片

上传属性 Google App Engine - app.yaml

Google App Engine 大文件上传

将大型视频文件上传到 Google App Engine

GWT与Google App Engine-上传文件

Google App Engine 和 Amazon S3 文件上传