Search code examples
pythonloggingmechanizetwill

Environment variables


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.


Solution

  • 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.