aap-utils 0.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
aap_utils/__init__.py ADDED
@@ -0,0 +1 @@
1
+ from .register import register_demo
aap_utils/register.py ADDED
@@ -0,0 +1,29 @@
1
+ import socket
2
+ import requests
3
+ import time
4
+
5
+ def register_demo(debug=False):
6
+ for attempt in range(10):
7
+ try:
8
+ local_ip = socket.gethostbyname(socket.gethostname())
9
+ response = requests.post(
10
+ "http://hocmay-svc/aiplatform-api/demo/register/",
11
+ json={"demo_ip": local_ip},
12
+ headers={"Content-Type": "application/json"}
13
+ )
14
+ if response.ok:
15
+ if debug:
16
+ print("IP registered successfully.")
17
+ return True
18
+ else:
19
+ if debug:
20
+ print(f"Attempt {attempt + 1}: Failed: {response.text}")
21
+ except (socket.error, requests.exceptions.RequestException) as e:
22
+ if debug: # Print errors only if debug is True
23
+ print(f"Attempt {attempt + 1}: Error: {e}")
24
+
25
+ time.sleep(2) # Wait for 2 seconds before retrying
26
+
27
+ if debug:
28
+ print("Failed to register IP after 10 attempts.")
29
+ return False
@@ -0,0 +1,11 @@
1
+ Metadata-Version: 2.1
2
+ Name: aap_utils
3
+ Version: 0.1
4
+ Summary: A Python library for registering an IP address for AAP
5
+ Author: Minh Dang
6
+ Author-email: danghoangminh86@gmail.com
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: License :: OSI Approved :: MIT License
9
+ Classifier: Operating System :: OS Independent
10
+ Requires-Dist: requests
11
+
@@ -0,0 +1,6 @@
1
+ aap_utils/__init__.py,sha256=OALCpHMgWzr-3Lu7eKwalsw5GNCwWWkETUPHOqfGXsg,36
2
+ aap_utils/register.py,sha256=Tv9252qK85Arbl-iZbtu8F2wz7oU7E-EgrH1I2fsqz4,1023
3
+ aap_utils-0.1.dist-info/METADATA,sha256=36CrDww90sppXrnXQg56bIO7OQbJhtjpvrmDsl_fmPk,344
4
+ aap_utils-0.1.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
5
+ aap_utils-0.1.dist-info/top_level.txt,sha256=Qt5xmL8_0_jhMl9uA3lg-xnvs4nCEyVj1tBE4vnp36M,10
6
+ aap_utils-0.1.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: bdist_wheel (0.43.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1 @@
1
+ aap_utils