我经历了一个非常奇怪的问题,无法解决这个问题.即使谷歌团队正在努力,但到目前为止无法解决.
我有一个CSS文件,这个文件很长一段时间以来从未改变过去的1 – 2年.现在我想在一个地方改变.我将max-width更改为max-height并保存.现在我正在部署代码,但它抛出异常:
11:12 AM Scanned 1500 files.
11:12 AM Scanned 2000 files.
11:12 AM Scanned 2500 files.
11:12 AM Scanned 3000 files.
11:12 AM Scanned 3500 files.
11:12 AM Scanned 4000 files.
11:12 AM Scanned 4500 files.
11:12 AM Scanned 5000 files.
11:12 AM Scanned 5500 files.
11:12 AM Cloning 2639 static files.
11:12 AM Cloned 2000 files.
11:12 AM Cloning 2916 application files.
11:12 AM Cloned 2000 files.
11:12 AM Uploading 1 files and blobs.
2014-07-29 11:12:36,450 ERROR appcfg.py:2559 An unexpected error occurred. Abort
ing.
Traceback (most recent call last):
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\ap
pcfg.py", line 2400, in DoUpload
self._UploadMissingFiles(missing_files, openfunc)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\ap
pcfg.py", line 2538, in _UploadMissingFiles
self.blob_batcher.Flush()
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\ap
pcfg.py", line 1442, in Flush
self.SendBatch()
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\ap
pcfg.py", line 1401, in SendBatch
payload,
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 1934: ordin
al not in range(128)
11:12 AM Rolling back the update.
Traceback (most recent call last):
File "C:\Program Files (x86)\Google\google_appengine\appcfg.py", line 126, in
<module>
run_file(__file__, globals())
File "C:\Program Files (x86)\Google\google_appengine\appcfg.py", line 122, in
run_file
execfile(_PATHS.script_file(script_name), globals_)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\ap
pcfg.py", line 5334, in <module>
main(sys.argv)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\ap
pcfg.py", line 5325, in main
result = AppCfgApp(argv).Run()
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\ap
pcfg.py", line 2963, in Run
self.action(self)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\ap
pcfg.py", line 4991, in __call__
return method()
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\ap
pcfg.py", line 3762, in Update
self._UpdateWithParsedAppYaml(appyaml, self.basepath)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\ap
pcfg.py", line 3815, in _UpdateWithParsedAppYaml
self.UpdateVersion(rpcserver, basepath, appyaml, APP_YAML_FILENAME)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\ap
pcfg.py", line 3698, in UpdateVersion
return appversion.DoUpload(paths, openfunc)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\ap
pcfg.py", line 2400, in DoUpload
self._UploadMissingFiles(missing_files, openfunc)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\ap
pcfg.py", line 2538, in _UploadMissingFiles
self.blob_batcher.Flush()
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\ap
pcfg.py", line 1442, in Flush
self.SendBatch()
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\ap
pcfg.py", line 1401, in SendBatch
payload,
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 1934: ordin
al not in range(128)
我再次将高度改为宽度并正确展开.在两种情况下,文件编码类型都是UTF-8.对此有任何猜测或解决方案?如果您需要任何进一步的信息,我很乐意分享.
解
大多数情况下,即使您将文件编码类型更改为UTF-8,它也无法识别它.最好的办法是强行要求appcfg.py用UTF-8编码格式处理你的文件.您可以通过在app.yaml中更改文件格式的mime_type来实现,如下所示:
- url: /(.*\.(css$))
static_files: \1
upload: (.*\.(css$))
mime_type: text/css; charset=UTF-8
通过这种方式,您的文件将被视为UTF-8,您的部署不会失败.
最佳答案 打开yourfile.css,确保以utf-8编码保存.根据文本编辑器,您可以转到“另存为”,然后选择编码.该错误告诉您ascii编码,并在1934位置找到一个非ascii字符.使用文本编辑器查找第1934个字符,您将看到问题.您是否从网络上复制/粘贴了该行?如果是这样,您很可能使用非ascii连字符,冒号,分号或引号.