Optional global argument to save responses

By adding -S or --save-responses to an application's arguments, every
response will be saved in /tmp/weboob. This is best used with the
-d/--debug option.
It might be interesting to add the headers to the saved response.
This commit is contained in:
Laurent Bachelier 2010-09-30 23:18:24 +02:00
commit da55da0d9d
2 changed files with 25 additions and 0 deletions

View file

@ -138,6 +138,7 @@ class BaseApplication(object):
logging_options.add_option('-d', '--debug', action='store_true', help='display debug messages')
logging_options.add_option('-q', '--quiet', action='store_true', help='display only error messages')
logging_options.add_option('-v', '--verbose', action='store_true', help='display info messages')
logging_options.add_option('-S', '--save-responses', action='store_true', help='save every response')
self._parser.add_option_group(logging_options)
self._parser.add_option('--shell-completion', action='store_true', help=optparse.SUPPRESS_HELP)
@ -290,6 +291,10 @@ class BaseApplication(object):
print ' '.join(items)
sys.exit(0)
if app.options.save_responses:
from weboob.tools.browser import BaseBrowser
BaseBrowser.SAVE_RESPONSES = True
if app.options.debug:
level = logging.DEBUG
elif app.options.verbose: