trackbert/trackbert.py

36 lines
1.1 KiB
Python
Raw Normal View History

2023-08-17 10:50:49 +00:00
from pykeydelivery import KeyDelivery
from pathlib import Path
2023-08-17 10:50:49 +00:00
import json
import time
import subprocess
import argparse
import logging
from typing import Tuple, Never, Optional
from classes.database import Database
from classes.tracker import Tracker
2023-08-17 10:50:49 +00:00
if __name__ == "__main__":
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)
parser.add_argument("--timeout", "-t", type=int, required=False, default=30, help="Notification timeout in seconds")
args = parser.parse_args()
tracker = Tracker()
if args.tracking_number is not None and args.carrier is not None:
db = Database('sqlite:///trackbert.db')
db.create_shipment(args.tracking_number, args.carrier, args.description)
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)
tracker.start()