Previously, when loading notifier classes in the Core class, any error that occurred would simply log an error message without providing any details. This commit improves error handling by catching exceptions and logging the specific error message when loading a notifier class fails. This allows for better debugging and troubleshooting in the future.
This commit adds a new column named "disabled" to the Shipment table in the database, allowing shipments to be disabled. The default value for this column is false. As part of this change, a new migration script has been added to update the database schema. Additionally, when retrieving shipments in the Database class, the get_shipments method now has an optional ignore_disabled parameter, which filters out disabled shipments if set to True. In the Tracker class, a database timeout handling has been added, and the database connection is disposed upon encountering a timeout.
The previous code did not handle errors while processing shipments, which could lead to unexpected behavior. This commit adds error handling to the shipment processing loops to log and handle various types of exceptions. Now, exceptions such as database timeouts and keyboard interrupts are caught and logged appropriately.
- Update pykeydelivery dependency to version >= 0.9.1 in pyproject.toml
- Refactor the supported_carriers method in keydelivery.py to use self.api.list_carriers() instead of making an HTTPRequest to "https://app.kd100.com/console/utils/kdbm"
- Change version in pyproject.toml to 0.2.2
- Add DHL tracking provider to README.md
- Update README.md with instructions for generating a config file
- Improve config file generation in __main__.py
- Load config file in Tracker class
- Update start and start_async methods in Tracker class to accept an optional config file path
This commit adds the DHL configuration and implementation to the project.
- Added DHL configuration to the config file.
- Updated the project version to 0.2.1 in the pyproject.toml file.
- Created a new file for the DHL tracker implementation.
- Implemented the DHL tracker functionality to get shipment events.
- Added DHL to the list of supported carriers.
The commit also includes changes to add Alembic configuration file, add migration scripts for initial migration, and modify the database class to include functions for running migrations and creating new migrations.
- Add FedEx configuration to config.ini
- Add FedEx tracking module to dependencies
- Implement FedEx tracking functionality
- Add FedEx as a supported carrier in the tracker
- Add GLS to list of tracking providers
- Update installation instructions to include creating `config.ini` file with KeyDelivery API details
- Mention that without creating `config.ini` file, only tracking shipments from Austrian Post and GLS is possible.
- Increase version to 0.1.1 in pyproject.toml to show updated version
- Add "glsapi" as a new dependency in pyproject.toml for package
- Add GLS tracker module
- Create GLS class and methods to get status and supported carriers
- Update loop_interval to 60 seconds
- Add loop_timeout to Tracker class with a value of 30 seconds
- Wrap process_shipment calls in asyncio.wait_for with timeout set to loop_timeout value
- Add try-except block to handle TimeoutError and log a warning message
- Code changes aim to improve the handling of long-running shipments processing with a timeout mechanism in place
This commit adds support for asynchronous tracking of shipments in the `Tracker` class. The `start_loop_async` method uses asyncio to run the `process_shipment` method concurrently for each shipment, improving performance. The `start_async` method is called from the main entry point, `trackbert.py`, to start the asynchronous tracking loop.
The commit updates the icon path used in the notify-send command inside the Tracker class. The path to the parcel delivery icon is modified to correctly locate the image file.
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.
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.
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.
- 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.
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.
- 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.
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.
- 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.
- 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.
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.