Commit graph

57 commits

Author SHA1 Message Date
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
0e0b24daba
Update icon path in Tracker class for notify-send command
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.
2023-08-24 15:35:06 +02:00
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