From 50810e5bd9c9c78fbb125f2157578d499ca40375 Mon Sep 17 00:00:00 2001 From: Jakub Roztocil Date: Sat, 18 Aug 2012 04:37:22 +0200 Subject: [PATCH] Include data directory location with --debug. --- httpie/cli.py | 3 ++- httpie/core.py | 19 ++++++++++++++----- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/httpie/cli.py b/httpie/cli.py index 638120e2..dad4b1ed 100644 --- a/httpie/cli.py +++ b/httpie/cli.py @@ -240,7 +240,8 @@ parser.add_argument( '--debug', action='store_true', default=False, help=_(''' Prints exception traceback should one occur, and also other - information useful for debugging HTTPie itself and bug reports. + information that is useful for debugging HTTPie itself and + for bug reports. ''') ) diff --git a/httpie/core.py b/httpie/core.py index e658ad5d..82fdfc54 100644 --- a/httpie/core.py +++ b/httpie/core.py @@ -23,10 +23,10 @@ from .cli import parser from .client import get_response from .models import Environment from .output import output_stream, write, write_with_colors_win_p3k +from .config import CONFIG_DIR from . import EXIT - def get_exist_status(code, allow_redirects=False): """Translate HTTP status code to exit status.""" if 300 <= code <= 399 and not allow_redirects: @@ -42,6 +42,16 @@ def get_exist_status(code, allow_redirects=False): return EXIT.OK +def print_debug_info(): + sys.stderr.writelines([ + 'HTTPie %s\n' % httpie_version, + 'HTTPie data: %s\n' % CONFIG_DIR, + 'Requests %s\n' % requests_version, + 'Pygments %s\n' % pygments_version, + 'Python %s %s\n' % (sys.version, sys.platform) + ]) + + def main(args=sys.argv[1:], env=Environment()): """Run the main program and write the output to ``env.stdout``. @@ -58,10 +68,9 @@ def main(args=sys.argv[1:], env=Environment()): status = EXIT.OK if debug: - sys.stderr.write('HTTPie %s\n' % httpie_version) - sys.stderr.write('Requests %s\n' % requests_version) - sys.stderr.write('Pygments %s\n' % pygments_version) - sys.stderr.write('Python %s %s\n' % (sys.version, sys.platform)) + print_debug_info() + if args == ['--debug']: + sys.exit(EXIT.OK) try: args = parser.parse_args(args=args, env=env)