Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/qnimbus/bunq
Bunq utilities
https://github.com/qnimbus/bunq
Last synced: about 1 month ago
JSON representation
Bunq utilities
- Host: GitHub
- URL: https://github.com/qnimbus/bunq
- Owner: QNimbus
- License: other
- Created: 2023-11-05T11:36:49.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2023-12-18T21:22:55.000Z (about 1 year ago)
- Last Synced: 2023-12-19T04:49:30.276Z (about 1 year ago)
- Language: Python
- Size: 226 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Bunq utilities
- [Getting started](#getting-started)
- [Create bunq config](#create-bunq-config)
- [Start server](#start-server)
- [Development](#development)
- [Rules model](#rules-model)## Getting started
### Create bunq config
Using Docker:
`docker run --rm -v conf:/app/conf besquared/bunq:latest python app.py --production --config-file conf/.bunq-.conf create-config --api-key `
or (get the file in the current workdir):
`docker run --rm -v ${PWD}:/app/conf besquared/bunq:latest python app.py --production --config-file conf/.bunq-.conf create-config --api-key `
Using python (inside container)
`python app.py --production --config-file conf/.bunq-.conf create-config --api-key `Using docker compose (when stack _is not_ running)
`docker compose -f docker-compose.yaml run --no-deps --rm bunq python app.py --production --config-file conf/.bunq-.conf create-config --api-key `Using docker compose (when stack _is_ running)
`docker compose -f docker-compose.yaml exec bunq python app.py --production --config-file conf/.bunq-.conf create-config --api-key `### Start server
Using Docker compose:
`docker compose up -d`### Flush Redis database
Using Docker compose:
`docker compose -f docker-compose.yaml exec -it -e PYTHONPATH=/app bunq python /app/libs/redis_wrapper.py flushdb`Or inside the container:
`libs/redis_wrapper.py flushdb`## Development
### Rules model
To generate the rules collection model from the schema, run the following command:
`datamodel-codegen --input-file-type jsonschema --input schema/rules.schema.json --output-model-type pydantic_v2.BaseModel --output schema/rules_model.py --class-name RuleModel --use-title-as-name --disable-appending-item-suffix`
To generate the callback model from the schema, run the following command:
`datamodel-codegen --input-file-type jsonschema --input schema/callback.schema.json --output-model-type pydantic_v2.BaseModel --output schema/callback_model.py --class-name CallbackModel --use-title-as-name --disable-appending-item-suffix`
### Testing
To run the tests, run the following command:
`$ pytest`
To check code coverage of the unit tests, run the following command:
`$ coverage run -m pytest`
To generate a code coverage report, run the following command:
`$ coverage report`
or to generate a HTML report, run the following command:
`$ coverage html`
## Miscelaneous
### Log files
To concatenate all the log files into a single log file, run the following command:
```
# This command will concatenate all the log files into a single log file$ find logs/ -type f -name "*.log" \( ! -name 'all.log' -a ! -name 'mutation.log' -a ! -name 'payment.log' -a ! -name 'request.log' -a ! -name 'misc.log' \) -print0 | xargs -0 cat >> logs/all.log
# This command wille remove the previously concatenated log files
$ find logs/ -type f -name "*.log" \( ! -name 'mutation.log' -a ! -name 'payment.log' -a ! -name 'request.log' -a ! -name 'misc.log' -a ! -name 'all.log' \) -print0 | xargs -0 rm
```These commands will grab all specific log entries into their respective log files:
```
$ grep -h logs/all.log -e "\"category\": \"MUTATION\"" > logs/mutation.log
$ grep -h logs/all.log -e "\"category\": \"PAYMENT\"" > logs/payment.log
$ grep -h logs/all.log -e "\"category\": \"REQUEST\"" > logs/request.log
$ grep -h logs/all.log -e "\"category\": \"CARD_TRANSACTION_SUCCESSFUL\"" -e "" > logs/misc.log
```### Generate passwords
To generate a password, run the following command:
```
$ scripts/hash_password.py my-password
```### Generate random keys for the config file
To generate a random key, run the following command:
```
$ python -c 'import os; print(os.urandom(32))' b'_5#y2L"F4Q8z\n\xec]/'
```