Commit graph

18 commits

Author SHA1 Message Date
a8a7522ff0
Refactor shipment_id assignment in Tracker and trackers/keydelivery.py
The shipment_id assignment has been refactored in the Tracker class and in the keydelivery.py file to set the value as 0 instead of using the tracking_number. This change ensures consistency in assigning the shipment_id across different trackers.
2023-08-24 15:33:09 +02:00
e71a30630d
Refactor event sorting and logging in Tracker class
- Sort events in descending order based on event time.
- Update debug logging message to include event description and time.
2023-08-24 14:48:21 +02:00
1ae1a88975
feat: Add write_event method to Database class
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.
2023-08-24 14:46:54 +02:00
fdc6af1059
Add classes for database and tracker
This commit adds new files for database and tracker classes. The database class includes methods for creating shipments, getting shipments, creating events, and getting shipment events. The tracker class includes methods for sending notifications, starting the tracking loop, and initializing the database and API.
2023-08-24 13:31:07 +02:00
ebcb3ef6aa
Fix latest known event logging
- The code now checks if there is a latest known event before logging it. If there is no latest known event, it logs "No known events for {tracking_number}".

- The logging for the latest known event now includes the event description and name.

- This change improves the logging output for the latest known event, making it more informative.
2023-08-23 12:09:47 +02:00
d09daaa0cc
Update shipment tracking logic and debugging output
- Adjusted shipment tracking logic in `start_loop` function.
- Added logging output for the number of events retrieved for a tracking number.
2023-08-23 10:43:34 +02:00
1a8d5608a0
Set urgency to critical for latest event 2023-08-21 12:33:04 +02:00
3a36b18d65
feat: Add desktop notification functionality with icon
Adds functionality to send desktop notifications with an icon. The `notify()` function now accepts an optional `urgency` parameter and a `timeout` parameter. The notification is sent using the `notify-send` command and includes an icon. The icon used is the "parcel-delivery-icon.webp" file located in the assets folder.
2023-08-21 09:14:25 +02:00
69e5023994
Refactor event loop for trackbert.py
- Improve conditional check for latest known event timestamp in the event loop.
- Update the index of the `latest_known_event` timestamp from position 3 to position 2 for accurate comparison.
- This ensures that only events with a more recent timestamp are considered.
2023-08-21 09:02:30 +02:00
053ae780e1
Update debug logs with latest known and upstream events
Updated debug logs in the `start_loop` function to include the latest known event for a tracking number and the latest upstream event with their respective timestamps. This provides more detailed information for debugging purposes.
2023-08-21 09:01:32 +02:00
33721e4939
Use sort to get latest events 2023-08-21 09:00:01 +02:00
c12572430f
Add new files and update existing files with configuration details.
- Added LICENSE file with MIT license details.
- Added README.md file with information on how to use the script.
- Added config.dist.ini file with KeyDelivery API configuration details.
2023-08-18 09:59:40 +02:00
1c2f41587b
chore: Add docstrings to all functions
chore: Add missing type hints
2023-08-18 09:38:18 +02:00
018cccb6a1
chore: Update logging format and add debug messages
- Changed the logging format in `trackbert.py` to include date, time, and message level.
- Added debug messages to show the number of events retrieved for a tracking number.
2023-08-18 09:17:05 +02:00
9802e28454
feat: Add logging and error handling for notifications
In this commit, logging and error handling have been added to the `notify` function in order to provide more visibility into notification sending. If the `notify-send` command is not found, a warning message is logged instead of sending a notification. Additionally, logging statements have been added to various functions throughout the script to provide visibility into the execution flow.
2023-08-18 09:13:10 +02:00
44d854653f
Catch error in realtime tracking
Output time with event
2023-08-18 08:42:12 +02:00
c2963ef041
Quick implementation of adding shipment to db 2023-08-18 08:33:32 +02:00
ab325de5a6
Current status 2023-08-17 12:50:49 +02:00