-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconvertVirtualHubsToRealHubs.py
More file actions
60 lines (40 loc) · 1.4 KB
/
convertVirtualHubsToRealHubs.py
File metadata and controls
60 lines (40 loc) · 1.4 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
60
import concurrent.futures
import requests
from utils import utils
from utils import utils
real_hubs = []
def get_real_hub(env, orgId, virtualHub):
"""
Retrieves the real hub information based on the provided parameters.
Parameters:
- env (str): The environment code used to construct the request URL.
- orgId (str): The organization ID associated with the hub.
- virtualHub (str): The virtual hub for which the real hub information is requested.
Returns:
None
"""
url = f"http://tesseract.{utils.convert_env(env)}.milezero.com/Tesseract-war/api/config/hub/{orgId}?countryCode=USA&companyBrandCode=01&posInstanceNumber={virtualHub}"
response = requests.get(url=url, timeout=5).json()
try:
real_hubs.append(response["hubName"])
print(f"{virtualHub} -> {response['hubName']}")
except Exception:
print(f"{virtualHub}")
def main():
"""
Main function to retrieve real hub information for multiple virtual hubs.
Parameters:
None
Returns:
None
"""
env = utils.select_env()
orgId = utils.select_org(env)
virtual_hubs = []
virtual_hubs = list(set(virtual_hubs))
with concurrent.futures.ThreadPoolExecutor() as pool:
for vhub in virtual_hubs:
pool.submit(get_real_hub, env, orgId, vhub)
pool.shutdown(wait=True)
print(f"{len(virtual_hubs)} in, {len(real_hubs)} out")
main()