-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeliverPackageWithCustomMessage.py
More file actions
42 lines (28 loc) · 1.2 KB
/
deliverPackageWithCustomMessage.py
File metadata and controls
42 lines (28 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from concurrent.futures import ThreadPoolExecutor
from utils import packages, utils
def main(env: str, org_id: str, key_type: str, key: str, notes: str | None):
pkgs = []
pkgs = packages.get_package_details(env, org_id, key_type, key)
if len(pkgs) == 0:
print("> NO PACKAGES FOUND <\n")
print(f"\n{'':=<50}")
print(f"Found {len(pkgs)} packages, Applying filters")
with ThreadPoolExecutor() as pool:
for package in pkgs:
status = package["packageStatuses"]["status"]
package_id = package["packageId"]
if status == "DELIVERED":
print(f"--> Package {package_id} already delivered")
continue
pool.submit(
packages.mark_package_as_delivered, env, org_id, package_id, notes
)
if __name__ == "__main__":
env = utils.select_env()
org_id = utils.select_org(env)
key = input(
"Type in the package number (e.g. 0510220444761000002, 00000009370592381919): "
)
key_type = input("Type in the package number type (e.g. bc, ori, pi, etc): ")
notes = input("Type in the notes (optional): ")
main(env, org_id, key_type, key, notes if notes else None)