Added functionality to dynamically discover and load external notifiers and providers through entry points. This enhancement allows for modular extension of the system's capabilities by enabling third-party plugins to register notifiers and tracking providers. By utilizing the `importlib.metadata.entry_points`, the system now searches for any registered plugins under the `trackbert.notifiers` and `trackbert.providers` namespaces, loads them, and if valid, incorporates them into the available notifiers and providers list. This brings improved extensibility and customization possibilities, catering to a wider range of use cases and third-party integrations.
- Introduced support and PyPI version badges in README to enhance visibility and provide quick access to the package version and support options.
- Updated URLs in both README and pyproject.toml, shifting the project's homepage, bug tracker, and source code references to the new git.private.coffee platform. This move supports a more centralized and private management of the project infrastructure.
The inclusion of badges in the README not only improves the aesthetic appeal but also offers essential information at a glance, encouraging user engagement. Transitioning to private.coffee for project URLs signifies a strategic choice towards a more controlled and secure environment for development and community interaction.
Previously, the `notify_event` method had a parameter named `critical` to determine the urgency of the notification. This has been changed to `urgent` for clarity. The method now uses the `urgent` parameter directly in the `self.notify` call instead of converting it to an "urgency" string. This commit refactors the code to improve readability and maintainability.
Previously, an API call was made to get the shipment status using the tracking number. The code now incorporates exception handling to log any errors that occur during the fetching of the status. This change ensures that any potential errors are captured and logged for debugging purposes.
The current code adds handling for existing shipments and improves the update functionality in the `__main__.py` file. The changes include checking if a shipment already exists, updating the shipment with the specified carrier, and printing appropriate messages.
- Create shipment if it doesn't exist, when the shipment and update flag are both not set.
- Print an error message and exit with error code if the "How did you get here?" case is reached.
- Added a check to print a message if the shipment does not exist and the update flag is set
- Added an error message for cases where a shipment cannot be created because it does not exist
This commit refactors the carrier selection logic in the `main` function in `__main__.py`. The code now uses the variable name `provider` instead of `api` for clarity. Additionally, the logic for filtering providers is updated to correctly check for other providers with a higher priority for a given carrier.
Previously, the code used the variable name `apis` to represent the available tracking APIs. This has been changed to `providers` for improved semantic understanding. The condition for selecting carriers has also been updated to use the new variable name, enhancing code comprehension.
The Core class in core.py has been refactored to include a new method find_external_notifiers() which is currently returning an empty list, and find_external_providers() which is also returning an empty list. Both methods are placeholders for future implementation using entry points. The find_notifiers() and find_providers() methods have been updated to include the results of the new methods.
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.