Commit graph

69 commits

Author SHA1 Message Date
bf30e323f1
feat(core): Add shipment management and notifier handlers
Introduced methods to add and remove shipments in the Core class
and enhanced the notifier system with handlers for various shipment
events. This improvement facilitates better shipment tracking and
notification capabilities, allowing dynamic shipment management
through the notifier interface. Minor code cleanup in `__main__.py`.
2024-07-02 11:02:33 +02:00
ea1fe9fbde
fix(core): handle missing entry point groups gracefully
Refactored the handling of entry points for notifiers and providers
to avoid potential errors when their groups are missing. Simplifies
and improves the robustness of the logic by directly iterating over
all entry points and filtering by group instead of relying on
potentially absent group keys.
2024-07-02 08:25:52 +02:00
d0cb2906c6
refactor: standardize constructor signatures for notifiers
Updated constructors in BaseNotifier, Matrix, and NotifySend classes
to consistently use kwargs for initialization. Simplifies the
BaseNotifier class and reduces the need for extra positional
arguments in derived classes, leading to clearer and more flexible
instantiation.
2024-07-02 08:25:39 +02:00
76b77c17ba
refactor: improve code readability and structure
Enhanced readability and consistency by reformatting `pyproject.toml` and other Python files. Removed unnecessary imports and ensured consistent styling across the codebase. These changes boost maintainability and reduce potential errors.
2024-07-02 08:21:34 +02:00
b4f0da0d1c
feat: enhance Matrix notifier with JSON encoding
Improved the Matrix notifier's message delivery by converting data payloads to JSON format before sending. This change includes encoding the message data as UTF-8 and setting the appropriate `Content-Type` header in the request. This adjustment ensures better compatibility with the Matrix API and potentially reduces issues related to content formatting and data interpretation on the receiving end.

Refactored import statements for clarity and consistency within the module.
2024-04-16 12:42:55 +02:00
62e7bc7e7b
feat: migrate from setuptools to importlib.metadata
Replaced the usage of setuptools.metadata with importlib.metadata to handle package metadata operations. This change aligns with modern Python practices, offering a more standardized and potentially more efficient way of accessing package metadata. The shift also reduces the dependency on the external setuptools package, which can simplify deployment and reduce potential conflicts.
2024-04-16 10:48:38 +02:00
d985235393
feat(notifiers): Add Matrix notifier support
Introduced a new notifier for Matrix to allow messages to be sent to specified rooms on a Matrix server. This extends the application's notification system, enabling it to interact with Matrix homeservers using room IDs and access tokens defined in the configuration. The added `Matrix` class supports basic notification functionality, including determining if the notifier is enabled and sending messages. This enhancement caters to users within the Matrix ecosystem, providing a more integrated experience for alert and notification management.
2024-04-16 10:47:07 +02:00
cc7230e8aa
feat: Implement external notifiers and providers discovery
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.
2024-04-16 09:29:37 +02:00
fd297a612f
feat: Add badges and update URLs for Trackbert project
- 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.
2024-04-16 09:28:57 +02:00
074ddd1edb
Refactor notification urgency handling in notify_event method
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.
2023-09-13 09:30:31 +02:00
2eca302234
Refactor PostAT.get_status() to handle exceptions when fetching shipment status.
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.
2023-09-12 09:16:15 +02:00
f7e9c76f64
Add handling for existing shipments and improve update functionality in __main__.py
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.
2023-09-12 08:35:10 +02:00
ecc540ab6e
Update shipment validation and error message handling 2023-09-12 08:23:40 +02:00
9a79d06544
Create shipment if it doesn't exist; exit with error if update flag not set.
- 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.
2023-09-12 08:22:29 +02:00
e9c7ed12d3
Update shipment with carrier for a given tracking number
- 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
2023-09-12 08:20:15 +02:00
dafce82106
Refactor carrier selection logic in __main__.py
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.
2023-09-12 07:48:33 +02:00
4cddd70254
Refactor carriers selection logic for clarity and readability.
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.
2023-09-12 07:47:06 +02:00
81dbed9ca2
Refactor Core class to find and include external notifiers and providers
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.
2023-09-06 13:47:21 +02:00
28f1374233
Add missing import 2023-09-06 13:42:31 +02:00
f3435f581f
Add missing import 2023-09-06 13:41:25 +02:00
62227ec644
Fix error handling in Core class when loading notifier classes
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.
2023-09-06 13:38:35 +02:00
e53a723188
Major refactoring 2023-09-06 13:36:46 +02:00
66cee293ec
Bump version to 0.3.0-dev, replace Tracker class with Core class. 2023-09-06 12:51:07 +02:00
98e610a2a1
Bump version to 0.2.6
Updated the version number in pyproject.toml from 0.2.5 to 0.2.6. This is a minor version bump.
2023-09-06 12:04:42 +02:00
74883d15bd
feat: Add shipment disabled flag to database
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.
2023-09-06 12:03:54 +02:00
c3633450bb
Update error handling and exiting 2023-09-06 08:16:47 +02:00
22d2c06f60
feat: Add error handling to shipment processing loops
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.
2023-09-06 08:13:37 +02:00
f2ca2e0748
Update pyproject.toml & keydelivery.py
- 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"
2023-08-31 09:01:04 +02:00
bcbd2989eb
Fix logging level for shipment without carrier
The logging level for shipments without a carrier has been changed from "warning" to "info" to improve readability and avoid unnecessary warnings.
2023-08-30 12:51:20 +02:00
e5d85d80d1
Add DPD to README.md 2023-08-30 12:48:40 +02:00
ca16a01dda
Version bump to 0.2.5 and added a new function for handling database sessions 2023-08-30 12:30:21 +02:00
b12a7f71c5
Bump version to 0.2.4, add DPD tracker, and fix sorting of events. 2023-08-30 12:14:38 +02:00
ad44b1e1cc
Update trackbert version to 0.2.3, add tabulate to dependencies, and refactor main function arguments in __main__.py. Also, introduce HTTPRequest class for handling HTTP requests. 2023-08-30 10:59:13 +02:00
751a7ad9e5
Update version to 0.2.2, add DHL tracking provider, and improve config file generation and loading
- 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
2023-08-29 18:58:32 +02:00
44fe6a28a2
feat: Add DHL configuration and implementation
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.
2023-08-29 10:47:52 +02:00
23407f031e
Bump version to 0.2.0 and add alembic as a dependency.
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.
2023-08-29 10:30:45 +02:00
eb87e38507
Update README.md and pyproject.toml
- Add FedEx as a new tracking provider in README.md
- Update version number to 0.1.3 in pyproject.toml
2023-08-27 10:38:11 +02:00
01a0d1dc35
Add FedEx tracking functionality and configuration to the code
- 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
2023-08-27 10:36:30 +02:00
07619ff4a8
Fix logging error when getting events for a tracking number
Previously, an error message was printed using print() function. This is now changed to use logging.error() to properly log the error.
2023-08-26 07:42:57 +02:00
edb021536e
Version bump 2023-08-26 07:30:00 +02:00
ebe1eff2f4
Handle case when no events are found for a given tracking number.
- Added handling for case when no events are found for a given tracking number.
2023-08-26 07:29:25 +02:00
e5967c7692
Add GLS as a new tracking provider and update installation instructions
- 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.
2023-08-25 08:33:32 +02:00
ecde311927
Bump version to 0.1.1 in pyproject.toml & add GLS tracker
- 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
2023-08-25 07:54:34 +02:00
e4478d4a42
Update .gitignore 2023-08-25 07:44:22 +02:00
42b60cf56b
Update Usage section in README 2023-08-25 07:39:11 +02:00
619aa99e35
Making trackbert a proper package
Adding .gitlab-ci.yml
2023-08-25 07:37:43 +02:00
1d90de9205
chore: Run black on code 2023-08-24 17:43:23 +02:00
9374b1284e
Update loop_interval in Tracker class and handle timeout while processing shipments
- 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
2023-08-24 17:34:18 +02:00
080b019efc
feat: Add asynchronous support for tracking shipments
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.
2023-08-24 17:27:43 +02:00
208762ec38
classes/database.py: Updated table names and added methods to update and disable shipments
classes/tracker.py: Added handling for disabled shipments and improved logging statements
trackbert.py: Added commands to update and disable shipments
2023-08-24 16:05:46 +02:00