Kumi
1ae1a88975
This commit adds a new method called `write_event` to the `Database` class in `database.py`. The method takes an `Event` object as a parameter and adds it to the session before committing the changes to the database. This change simplifies the code in the `create_event` method by making use of the new `write_event` method. The `write_event` method is used in the `Tracker` class in `tracker.py` to replace the call to `create_event`. This change improves the clarity and readability of the code. Additionally, in the `Tracker` class, the `api` object is no longer created using `KeyDelivery.from_config`, as the `api` object is no longer referenced in the code. This change is made to remove unused code and improve code quality. This commit also adds some new import statements to the `Tracker` class in `tracker.py` to support the new changes. Lastly, two new tracker classes `KeyDelivery` and `PostAT` are added under the `trackers` directory. These new classes inherit from the `BaseTracker` class and implement the `get_status` method. The `KeyDelivery` class makes use of the `pykeydelivery.KeyDelivery` API to fetch tracking events, while the `PostAT` class uses the `postat.classes.api.PostAPI` API to fetch tracking events. The new tracker classes also define the supported carriers and their priorities. Overall, these changes improve the functionality and structure of the codebase. |
||
---|---|---|
assets | ||
classes | ||
trackers | ||
.gitignore | ||
config.dist.ini | ||
LICENSE | ||
README.md | ||
requirements.txt | ||
trackbert.py |
Trackbert
A simple Python script for tracking shipments through KeyDelivery.
If your system provides notify-send
, you will get a desktop notification when the status of your shipment changes.
Status information is stored in a SQLite database.
Requirements
The script was developed and tested on Arch Linux using Python 3.11. The "Never" type hint is used, so I suppose it will not work on older Python versions. It should work on any Linux distribution. You can technically run it on Windows and macOS as well, but you will not get desktop notifications.
In order to get desktop notifications, you need to have notify-send
installed. On Arch Linux, this is provided by the libnotify
package. If your desktop environment does not provide a notification server, you have to install one yourself. How to do this is beyond the scope of this README.
Installation
git clone https://kumig.it/kumitterer/trackbert.git
cd trackbert
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
Then copy config.dist.ini
to config.ini
and fill in your KeyDelivery API details, which you can find in your KeyDelivery API management. You can find your API key in your KeyDelivery account settings.
Usage
To add a new shipment, run python trackbert.py --tracking-number <tracking-number> --carrier <carrier-id>
. Find the required carrier ID in the KeyDelivery API management.
To run the main loop, run python trackbert.py
. This will check the status of all shipments every 5 minutes, and print the status to the console. If the status of a shipment changes, you will get a desktop notification.
License
This project is licensed under the MIT License. See the LICENSE file for details.