mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-04-13 07:47:14 +03:00
Contributing: Document --debug-send ...
code and usage
This commit is contained in:
parent
ca87c061a1
commit
c398be9b5c
@ -225,7 +225,39 @@ Adding `--trace` to a `pytest` invocation causes it to drop into a
|
||||
[`pdb`](https://docs.python.org/3/library/pdb.html) prompt for each test,
|
||||
handy if you want to step through the testing code to be sure of anything.
|
||||
|
||||
Otherwise, see the [pytest documentation](https://docs.pytest.org/en/stable/contents.html).
|
||||
Otherwise, see the [pytest documentation](https://docs.pytest.org/en/stable/contents.html).
|
||||
|
||||
---
|
||||
## Debugging network sends
|
||||
|
||||
Rather than risk sending bad data to a remote service, even if only through
|
||||
repeatedly sending the same data you can cause such code to instead send
|
||||
through a local web server and thence to a log file.
|
||||
|
||||
1. This utilises the `--debug-sender ...` command-line argument. The argument
|
||||
to this is free-form, so there's nothing to edit in EDMarketConnector.py
|
||||
in order to support a new target for this.
|
||||
2. The debug web server is set up globally in EDMarketConnector.py.
|
||||
3. In code where you want to utilise this you will need at least something
|
||||
like this (taken from some plugins/edsm.py code):
|
||||
|
||||
```python
|
||||
from config import debug_senders
|
||||
from edmc_data import DEBUG_WEBSERVER_HOST, DEBUG_WEBSERVER_PORT
|
||||
|
||||
TARGET_URL = 'https://www.edsm.net/api-journal-v1'
|
||||
if 'edsm' in debug_senders:
|
||||
TARGET_URL = f'http://{DEBUG_WEBSERVER_HOST}:{DEBUG_WEBSERVER_PORT}/edsm'
|
||||
|
||||
...
|
||||
r = this.session.post(TARGET_URL, data=data, timeout=_TIMEOUT)
|
||||
```
|
||||
|
||||
Be sure to set a URL path in the `TARGET_URL` that denotes where the data
|
||||
would normally be sent to.
|
||||
4. The output will go into a file in `%TEMP%\EDMarketConnector\http_debug`
|
||||
whose name is based on the path component of the URL. In the code example
|
||||
above it will come out as `edsm.log` due to how `TARGET_URL` is set.
|
||||
|
||||
---
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user