Google App Engine dev_appserver.py:watcher_ignore_re标志“不可JSON序列化”; [英] Google App Engine dev_appserver.py: watcher_ignore_re flag "is not JSON serializable"

查看:111
本文介绍了Google App Engine dev_appserver.py:watcher_ignore_re标志“不可JSON序列化”;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么运行带有选项 watcher_ignore_re dev_appserver.py 时,我收到一条错误消息,提示正则表达式不可JSON序列化

Why I run the dev_appserver.py with the option watcher_ignore_re, I get an error message that the regex is not JSON serializable.

这是开发服务器的错误吗?我使用此命令是否不正确?命令和调用堆栈显示在下面。

Is this a bug with the development server? Am I using this command improperly? The command and callstack is printed below.

C:\Users\mes65\Documents\MyProject>"C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\bin\dev_appserver.py" ^
    --watcher_ignore_re="(.*\.git|.*\.idea|tmp\.py)" ^
    "C:\Users\mes65\Documents\MyProject"
WARNING  2018-06-06 09:28:59,161 appinfo.py:1622] lxml version "2.3" is deprecated, use one of: "3.7.3"
INFO     2018-06-06 09:28:59,187 devappserver2.py:120] Skipping SDK update check.
Traceback (most recent call last):
  File "C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\dev_appserver.py", line 96, in <module>
    _run_file(__file__, globals())
  File "C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\dev_appserver.py", line 90, in _run_file
    execfile(_PATHS.script_file(script_name), globals_)
  File "C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\tools\devappserver2\devappserver2.py", line 454, in <module>
    main()
  File "C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\tools\devappserver2\devappserver2.py", line 442, in main
    dev_server.start(options)
  File "C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\tools\devappserver2\devappserver2.py", line 163, in start
    bool(ssl_certificate_paths), options)
  File "C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\tools\devappserver2\metrics.py", line 166, in Start
    self._cmd_args = json.dumps(vars(cmd_args)) if cmd_args else None
  File "C:\Python27\lib\json\__init__.py", line 244, in dumps
    return _default_encoder.encode(obj)
  File "C:\Python27\lib\json\encoder.py", line 207, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "C:\Python27\lib\json\encoder.py", line 270, in iterencode
    return _iterencode(o, 0)
  File "C:\Python27\lib\json\encoder.py", line 184, in default
    raise TypeError(repr(o) + " is not JSON serializable")
TypeError: <_sre.SRE_Pattern object at 0x00000000063C2188> is not JSON serializable


推荐答案

我也遇到了此可用性问题在Windows上,真的很失望。我试图找到一些解决方法,但没有找到任何合适的方法。

I also faced with this usability problem on Windows and was really disappointed. I tried to find some workarounds but I hadn't found any appropriate way.

最后,我决定自己为Windows实现watcher_ignore_re支持。我在我的Github存储库

In the end, I decided to make my own implementation of support watcher_ignore_re for Windows. I put required changes in my Github repo

如果用几个词形容它们:

If describe them in several words:


  1. 添加 _watcher_ignore_re _skip_files_re 属性及其设置器

  2. 从google.appengine.tools.devappserver2添加导入语句导入watcher_common 并将其用于新创建的 def _path_ginored

  3. 过滤器 additional_changes ,然后将它们添加到观察者已更改的文件中

  1. Add _watcher_ignore_re, _skip_files_re properties and its setters
  2. Add import statement from google.appengine.tools.devappserver2 import watcher_common and use it in newly created def _path_ginored
  3. Filter additional_changes before adding them to watcher changed files

要解决提到的无法序列化正则表达式属性的问题,应将其从序列化的字典。为此的修复是作为后续提交添加的,可以在 metrics.py:185-193 中进行检查。

For resolving mentioned problem with not serializable regex attribute we should drop them from the serialized dictionary. Fix for this is added as consequent commit and can be checked at metrics.py:185-193.

I希望它可以帮助其他人喜欢Windows上的GAE开发:)

I hope it helps other guys enjoy developing on GAE on Windows :)

这篇关于Google App Engine dev_appserver.py:watcher_ignore_re标志“不可JSON序列化”;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆