2023-08-17 10:50:49 +00:00
|
|
|
from pykeydelivery import KeyDelivery
|
2023-08-24 11:31:07 +00:00
|
|
|
from pathlib import Path
|
2023-08-17 10:50:49 +00:00
|
|
|
import json
|
|
|
|
import time
|
|
|
|
import subprocess
|
2023-08-18 06:33:32 +00:00
|
|
|
import argparse
|
2023-08-18 07:13:10 +00:00
|
|
|
import logging
|
2023-08-21 10:33:04 +00:00
|
|
|
from typing import Tuple, Never, Optional
|
2023-08-18 07:38:18 +00:00
|
|
|
|
2023-08-24 11:31:07 +00:00
|
|
|
from classes.database import Database
|
|
|
|
from classes.tracker import Tracker
|
2023-08-17 10:50:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2023-08-18 06:33:32 +00:00
|
|
|
parser = argparse.ArgumentParser()
|
|
|
|
parser.add_argument("--tracking-number", "-n", type=str, required=False)
|
|
|
|
parser.add_argument("--carrier", "-c", type=str, required=False)
|
|
|
|
parser.add_argument("--description", "-d", type=str, required=False)
|
2023-08-21 10:33:04 +00:00
|
|
|
parser.add_argument("--timeout", "-t", type=int, required=False, default=30, help="Notification timeout in seconds")
|
2023-08-21 07:14:25 +00:00
|
|
|
|
2023-08-18 06:33:32 +00:00
|
|
|
args = parser.parse_args()
|
|
|
|
|
2023-08-24 11:31:07 +00:00
|
|
|
tracker = Tracker()
|
2023-08-18 07:38:18 +00:00
|
|
|
|
2023-08-18 06:33:32 +00:00
|
|
|
if args.tracking_number is not None and args.carrier is not None:
|
2023-08-24 11:31:07 +00:00
|
|
|
db = Database('sqlite:///trackbert.db')
|
|
|
|
db.create_shipment(args.tracking_number, args.carrier, args.description)
|
2023-08-18 06:33:32 +00:00
|
|
|
print(f"Created shipment for {args.tracking_number} with carrier {args.carrier}")
|
|
|
|
exit(0)
|
|
|
|
|
|
|
|
if args.tracking_number is not None:
|
|
|
|
print("You must specify a carrier with -c")
|
|
|
|
exit(1)
|
|
|
|
|
2023-08-24 11:31:07 +00:00
|
|
|
tracker.start()
|