Commit 2b841427 authored by Geoffrey Guéret's avatar Geoffrey Guéret

added trace option, to see requests raw HTTP calls

parent 8dc56014
Pipeline #14647 passed with stages
in 5 minutes and 8 seconds
......@@ -22,7 +22,7 @@ push:
docker push ${DOCKER_IMAGE_NAME}
test:
docker run -v ${CURDIR}:/usr/src/app -e "CI" -e "GITLAB_TOKEN" ${DOCKER_IMAGE_NAME} pytest
docker run -v ${CURDIR}:/usr/src/app -e "CI" ${DOCKER_IMAGE_NAME} pytest
shell:
docker run -v ${CURDIR}:/usr/src/app -ti ${DOCKER_IMAGE_NAME} /bin/bash
docker run -v ${CURDIR}:/usr/src/app -ti -e "GITLAB_TOKEN" -e "REDMINE_TOKEN" ${DOCKER_IMAGE_NAME} /bin/bash
......@@ -36,6 +36,7 @@ setup_requires =
install_requires =
click == 7
python-gitlab == 1.10
requests-toolbelt == 0.9.1
[options.data_files]
ubicli/certs =
......
......@@ -6,9 +6,10 @@ from . import get_version
@click.group(cls=UbiCLI)
@click.option('--trace', type=click.Choice(['all', 'http']), default=None)
@click.option('--debug/--no-debug', default=False, help="Enable debugging globally")
@click.pass_context
def cli(ctx, debug):
def cli(ctx, debug, trace):
"""The UbiCLI entrypoint."""
ctx.ensure_object(dict)
ctx.obj['DEBUG'] = debug
......@@ -17,6 +18,18 @@ def cli(ctx, debug):
CLI_PATH = Path(CLI_PATH) if CLI_PATH else Path(__file__).parents[1]
ctx.obj['CLI_PATH'] = CLI_PATH
if trace in ('all', 'http'):
from requests_toolbelt.utils import dump
from requests.sessions import Session
_send = Session.send
def _wrapped_send(self, request, **kwargs):
response = _send(self, request, **kwargs)
click.echo(dump.dump_response(response).decode('utf-8'), err=True)
return response
Session.send = _wrapped_send
@cli.command()
@click.option('--full', is_flag=True)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment