环境变量
我使用模块 mechanize
来登录网站。当我导入 twill.commands
而没有任何其他明显用途时,会显示一些调试消息 [0] [1]。当我删除它时,这些消息就会消失。
我怎样才能看到环境中发生了什么变化,以便模拟它并消除这种依赖性?
[0] 使用日志记录模块。 [1] 更具体地说,我对 Following HTTP-EQUIV=REFRESH
消息感兴趣。
更新:事实证明,twill.commands 中存在一个错误,在尝试遵循 HTTP-EQUIV=REFRESH
标头时会产生错误。删除 import twill.commands 及其周围丑陋的工作后,一切都顺利进行。
I use the module mechanize
in order to log in a site. When I import twill.commands
without any other apparent use, some debug messages [0] are displayed [1]. When I delete it, these messages disappear.
How can I see what is changed in the environment in order to emulate it and remove this dependency?
[0] Using the logging module.
[1] More specifically, I am interested in a Following HTTP-EQUIV=REFRESH
message.
UPDATE: It turned out that there is a bug in twill.commands which was creating an error when trying to follow the HTTP-EQUIV=REFRESH
header. After removing the import twill.commands
and the ugly work around it, everything works smoothly.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我的猜测 - 无需深入研究库 - twill 正在实例化记录器,而 mechanize 正在执行 对于库来说是正确的事情,如果日志记录已打开则记录,如果未打开则不记录。
要启用
mechanize
的日志记录,请配置 logging.basicConfig root 在您的应用程序代码中。My guess - without digging in the libraries - is that twill is instantiating a logger, and mechanize is doing the Right Thing for a library, logging if logging has been turned on, not if not.
To enable the logging of
mechanize
configure a logging.basicConfig root in your application code.twill
内部使用mechanize
,您可以直接使用twill
登录网站。要遵循
http-equiv
重定向,只需使用go
命令。要调试
http-equiv
重定向,请启用相关的调试级别。twill
usesmechanize
internally, you can log into a web site directly withtwill
.To follow
http-equiv
redirection, just use thego
command.To debug
http-equiv
redirects, enable the relevant debug level.