aap-utils 0.1__tar.gz
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-0.1/PKG-INFO +10 -0
- aap_utils-0.1/README.md +16 -0
- aap_utils-0.1/aap_utils/__init__.py +1 -0
- aap_utils-0.1/aap_utils/register.py +29 -0
- aap_utils-0.1/aap_utils.egg-info/PKG-INFO +10 -0
- aap_utils-0.1/aap_utils.egg-info/SOURCES.txt +10 -0
- aap_utils-0.1/aap_utils.egg-info/dependency_links.txt +1 -0
- aap_utils-0.1/aap_utils.egg-info/requires.txt +1 -0
- aap_utils-0.1/aap_utils.egg-info/top_level.txt +1 -0
- aap_utils-0.1/pyproject.toml +3 -0
- aap_utils-0.1/setup.cfg +4 -0
- aap_utils-0.1/setup.py +18 -0
aap_utils-0.1/PKG-INFO
ADDED
@@ -0,0 +1,10 @@
|
|
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
|
aap_utils-0.1/README.md
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# AAP
|
2
|
+
|
3
|
+
A Python library for registering an IP address on a specific server.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
To install AAP lib from PyPI, run: pip install pmcd_aap
|
8
|
+
|
9
|
+
|
10
|
+
## Usage
|
11
|
+
|
12
|
+
```python
|
13
|
+
from aap import register_demo
|
14
|
+
|
15
|
+
register_demo(debug=True)
|
16
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
from .register import register_demo
|
@@ -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,10 @@
|
|
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
|
@@ -0,0 +1 @@
|
|
1
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
requests
|
@@ -0,0 +1 @@
|
|
1
|
+
aap_utils
|
aap_utils-0.1/setup.cfg
ADDED
aap_utils-0.1/setup.py
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
from setuptools import setup, find_packages
|
2
|
+
|
3
|
+
setup(
|
4
|
+
name="aap_utils", # The name of your library
|
5
|
+
version="0.1",
|
6
|
+
description="A Python library for registering an IP address for AAP",
|
7
|
+
author="Minh Dang",
|
8
|
+
author_email="danghoangminh86@gmail.com",
|
9
|
+
packages=find_packages(), # Auto-find packages in the directory
|
10
|
+
install_requires=[
|
11
|
+
"requests", # Any external dependencies (e.g., 'requests')
|
12
|
+
],
|
13
|
+
classifiers=[
|
14
|
+
"Programming Language :: Python :: 3",
|
15
|
+
"License :: OSI Approved :: MIT License",
|
16
|
+
"Operating System :: OS Independent",
|
17
|
+
],
|
18
|
+
)
|