Recently I was debugging something painfully and this feature made my life much easier:
https://stackoverflow.com/questions/10588644/how-can-i-see-the-entire-http-request-thats-being-sent-by-my-python-application
I made a function log_debug, which, when used to enable logging, shows nicely all the requests DEBUG logs.
Without:
Failed to connect to the server
Traceback (most recent call last):
File "~/cranc.py", line 134, in create_pr
branch_from=branch_from)
File "~libpagure.py", line 617, in create_pull_request
return_value = self._call_api(request_url, method="POST", data=payload)
File "~/libpagure.py", line 98, in _call_api
raise APIError(output["error"])
libpagure.exceptions.APIError: Invalid or expired token. Please visit https://pagure.io/settings#api-keys to get or renew your API token.
With :
send: b'POST /api/0/fork/lenkaseg/carrot/pull-request/new HTTP/1.1\r\nHost: pagure.io\r\nAccept-Encoding: identity\r\nAuthorization: token [blah blah]\r\nContent-Length: 49\r\nContent-Type: application/x-www-form-urlencoded\r\n\r\n'
send: b'title=veggies&branch_to=master&branch_from=readme'
reply: 'HTTP/1.1 401 UNAUTHORIZED\r\n'
header: Date: Thu, 14 Mar 2019 15:10:10 GMT
header: Server: Apache/2.4.6 (Red Hat Enterprise Linux) OpenSSL/1.0.2k-fips mod_wsgi/3.4 Python/2.7.5
header: Set-Cookie: pagure=[blah blah]; Expires=Sun, 14-Apr-2019 when it gets warm; Secure; HttpOnly; Path=/
header: X-Frame-Options: ALLOW-FROM https://pagure.io/
header: X-Xss-Protection: 1; mode=block
header: X-Content-Type-Options: nosniff
header: Referrer-Policy: same-origin
header: Content-Security-Policy: default-src 'self' https:; script-src 'self' 'unsafe-eval' 'unsafe-inline' https://apps.fedoraproject.org; style-src 'self' 'unsafe-inline' https://apps.fedoraproject.org
header: Strict-Transport-Security: max-age=3543665; includeSubDomains; preload
header: Content-Length: 154
header: Content-Type: application/json
Failed to connect to the server
Traceback (most recent call last):
File "~/cranc.py", line 134, in create_pr
branch_from=branch_from)
File ~/libpagure.py", line 617, in create_pull_request
return_value = self._call_api(request_url, method="POST", data=payload)
File "~/libpagure.py", line 98, in _call_api
raise APIError(output["error"])
libpagure.exceptions.APIError: Invalid or expired token. Please visit https://pagure.io/settings#api-keys to get or renew your API token.
Recently I was debugging something painfully and this feature made my life much easier:
https://stackoverflow.com/questions/10588644/how-can-i-see-the-entire-http-request-thats-being-sent-by-my-python-application
I made a function
log_debug, which, when used to enable logging, shows nicely all the requests DEBUG logs.Without:
Failed to connect to the server
Traceback (most recent call last):
File "~/cranc.py", line 134, in create_pr
branch_from=branch_from)
File "~libpagure.py", line 617, in create_pull_request
return_value = self._call_api(request_url, method="POST", data=payload)
File "~/libpagure.py", line 98, in _call_api
raise APIError(output["error"])
libpagure.exceptions.APIError: Invalid or expired token. Please visit https://pagure.io/settings#api-keys to get or renew your API token.
With :
send: b'POST /api/0/fork/lenkaseg/carrot/pull-request/new HTTP/1.1\r\nHost: pagure.io\r\nAccept-Encoding: identity\r\nAuthorization: token [blah blah]\r\nContent-Length: 49\r\nContent-Type: application/x-www-form-urlencoded\r\n\r\n'
send: b'title=veggies&branch_to=master&branch_from=readme'
reply: 'HTTP/1.1 401 UNAUTHORIZED\r\n'
header: Date: Thu, 14 Mar 2019 15:10:10 GMT
header: Server: Apache/2.4.6 (Red Hat Enterprise Linux) OpenSSL/1.0.2k-fips mod_wsgi/3.4 Python/2.7.5
header: Set-Cookie: pagure=[blah blah]; Expires=Sun, 14-Apr-2019 when it gets warm; Secure; HttpOnly; Path=/
header: X-Frame-Options: ALLOW-FROM https://pagure.io/
header: X-Xss-Protection: 1; mode=block
header: X-Content-Type-Options: nosniff
header: Referrer-Policy: same-origin
header: Content-Security-Policy: default-src 'self' https:; script-src 'self' 'unsafe-eval' 'unsafe-inline' https://apps.fedoraproject.org; style-src 'self' 'unsafe-inline' https://apps.fedoraproject.org
header: Strict-Transport-Security: max-age=3543665; includeSubDomains; preload
header: Content-Length: 154
header: Content-Type: application/json
Failed to connect to the server
Traceback (most recent call last):
File "~/cranc.py", line 134, in create_pr
branch_from=branch_from)
File ~/libpagure.py", line 617, in create_pull_request
return_value = self._call_api(request_url, method="POST", data=payload)
File "~/libpagure.py", line 98, in _call_api
raise APIError(output["error"])
libpagure.exceptions.APIError: Invalid or expired token. Please visit https://pagure.io/settings#api-keys to get or renew your API token.