Include data directory location with --debug.

This commit is contained in:
Jakub Roztocil 2012-08-18 04:37:22 +02:00
parent 9b586b953b
commit 50810e5bd9
2 changed files with 16 additions and 6 deletions

View File

@ -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.
''')
)

View File

@ -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)