-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmovePackagesToRoute.py
More file actions
59 lines (41 loc) · 1.7 KB
/
movePackagesToRoute.py
File metadata and controls
59 lines (41 loc) · 1.7 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
from datetime import datetime
from utils import files, packages, routes, utils
def route_found(desired_route_name, route):
"""
Compares the route names (1st param) with the route id and route name.
Parameters:
desired_route_name (str): the route name from the user input
route (dict): the route metadata from alamo's GET /routes/search/orgId/{orgId}
Returns:
True: if desired_route_name is present either in the route's name or id
False: otherwise
"""
route_name = str(route["routeName"]).strip().lower()
route_id = str(route["routeId"]).strip().lower()
return desired_route_name in route_name or desired_route_name in route_id
def main():
"""
The main function that retrieves package IDs from a file, prompts for user input, searches for a route, and moves the packages to the specified route.
Returns:
None
"""
fileName = "pids"
print(f"Reading package ids from file '{fileName}'")
packageIdsList = files.get_data_from_file(fileName)
# supportMember = input("What is your name?\n> ").strip()
env = utils.select_env()
orgId = utils.select_org(env)
hubName = input("Type in the route's hub name\n> ")
newRoute = input("Type in the new route name\n> ").strip().upper()
cpt = datetime.strptime(
input("Type in the route date (yyyy-mm-dd)\n> ").strip(), "%Y-%m-%d"
)
cpt = cpt.strftime("%Y-%m-%d")
route = routes.find_route(env, orgId, newRoute, hubName, cpt)
if route is None:
print("No Route Found")
else:
routeId = route["routeId"]
print(f"Route Found: {routeId}")
packages.move_packages_to_route(env, orgId, routeId, packageIdsList)
main()