pam-python 0.1.24__tar.gz → 0.1.26__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.
- {pam_python-0.1.24/pam_python.egg-info → pam_python-0.1.26}/PKG-INFO +1 -1
- {pam_python-0.1.24 → pam_python-0.1.26}/pam/cli.py +22 -13
- pam_python-0.1.26/pam/templates/docker/Dockerfile +21 -0
- pam_python-0.1.26/pam/templates/init/run_unit_test.bat +10 -0
- pam_python-0.1.26/pam/templates/init/run_unit_test.ps1 +11 -0
- pam_python-0.1.24/pam/templates/init/run_test.sh → pam_python-0.1.26/pam/templates/init/run_unit_test.sh +1 -0
- {pam_python-0.1.24 → pam_python-0.1.26/pam_python.egg-info}/PKG-INFO +1 -1
- {pam_python-0.1.24 → pam_python-0.1.26}/pam_python.egg-info/SOURCES.txt +3 -1
- {pam_python-0.1.24 → pam_python-0.1.26}/setup.py +1 -1
- pam_python-0.1.24/pam/templates/docker/Dockerfile +0 -18
- {pam_python-0.1.24 → pam_python-0.1.26}/LICENSE.txt +0 -0
- {pam_python-0.1.24 → pam_python-0.1.26}/README.md +0 -0
- {pam_python-0.1.24 → pam_python-0.1.26}/pam/__init__.py +0 -0
- {pam_python-0.1.24 → pam_python-0.1.26}/pam/api.py +0 -0
- {pam_python-0.1.24 → pam_python-0.1.26}/pam/interface_task_manager.py +0 -0
- {pam_python-0.1.24 → pam_python-0.1.26}/pam/models/__init__.py +0 -0
- {pam_python-0.1.24 → pam_python-0.1.26}/pam/models/request_command.py +0 -0
- {pam_python-0.1.24 → pam_python-0.1.26}/pam/server.py +0 -0
- {pam_python-0.1.24 → pam_python-0.1.26}/pam/service.py +0 -0
- {pam_python-0.1.24 → pam_python-0.1.26}/pam/sqlite.py +0 -0
- {pam_python-0.1.24 → pam_python-0.1.26}/pam/task_manager.py +0 -0
- {pam_python-0.1.24 → pam_python-0.1.26}/pam/temp_file_utils.py +0 -0
- {pam_python-0.1.24 → pam_python-0.1.26}/pam/templates/buildcmd/pamb +0 -0
- {pam_python-0.1.24 → pam_python-0.1.26}/pam/templates/buildcmd/pamb-base.sh +0 -0
- {pam_python-0.1.24 → pam_python-0.1.26}/pam/templates/init/dockerignore.tmpl +0 -0
- {pam_python-0.1.24 → pam_python-0.1.26}/pam/templates/init/gitignore.tmpl +0 -0
- {pam_python-0.1.24 → pam_python-0.1.26}/pam/templates/init/main.tmpl +0 -0
- {pam_python-0.1.24 → pam_python-0.1.26}/pam/templates/init/pylintrc.tmpl +0 -0
- {pam_python-0.1.24 → pam_python-0.1.26}/pam/templates/service/functions.tmpl +0 -0
- {pam_python-0.1.24 → pam_python-0.1.26}/pam/templates/service/service.test.tmpl +0 -0
- {pam_python-0.1.24 → pam_python-0.1.26}/pam/templates/service/service.yaml +0 -0
- {pam_python-0.1.24 → pam_python-0.1.26}/pam/templates/service/service_class.tmpl +0 -0
- {pam_python-0.1.24 → pam_python-0.1.26}/pam/tester_task.py +0 -0
- {pam_python-0.1.24 → pam_python-0.1.26}/pam/utils.py +0 -0
- {pam_python-0.1.24 → pam_python-0.1.26}/pam_python.egg-info/dependency_links.txt +0 -0
- {pam_python-0.1.24 → pam_python-0.1.26}/pam_python.egg-info/entry_points.txt +0 -0
- {pam_python-0.1.24 → pam_python-0.1.26}/pam_python.egg-info/requires.txt +0 -0
- {pam_python-0.1.24 → pam_python-0.1.26}/pam_python.egg-info/top_level.txt +0 -0
- {pam_python-0.1.24 → pam_python-0.1.26}/setup.cfg +0 -0
|
@@ -3,14 +3,15 @@ import sys
|
|
|
3
3
|
import re
|
|
4
4
|
import shutil
|
|
5
5
|
import subprocess
|
|
6
|
-
import pkg_resources
|
|
6
|
+
import pkg_resources
|
|
7
|
+
|
|
7
8
|
|
|
8
9
|
def main():
|
|
9
10
|
args = sys.argv[1:]
|
|
10
11
|
if len(args) == 0:
|
|
11
12
|
print("Usage: pam <command> [args]")
|
|
12
13
|
return
|
|
13
|
-
|
|
14
|
+
|
|
14
15
|
cmd = args[0]
|
|
15
16
|
|
|
16
17
|
if cmd == "init":
|
|
@@ -23,6 +24,7 @@ def main():
|
|
|
23
24
|
else:
|
|
24
25
|
print(f"Unknown command: {args.command}")
|
|
25
26
|
|
|
27
|
+
|
|
26
28
|
def to_pascal_case(input_string: str) -> str:
|
|
27
29
|
"""
|
|
28
30
|
Convert a string to PascalCase.
|
|
@@ -32,7 +34,7 @@ def to_pascal_case(input_string: str) -> str:
|
|
|
32
34
|
"""
|
|
33
35
|
# Split the string into words using non-alphanumeric characters as delimiters
|
|
34
36
|
words = re.split(r'\W+', input_string)
|
|
35
|
-
|
|
37
|
+
|
|
36
38
|
# Capitalize each word and join them
|
|
37
39
|
pascal_case = ''.join(word.capitalize() for word in words if word)
|
|
38
40
|
|
|
@@ -44,6 +46,7 @@ def cpy(src, dest):
|
|
|
44
46
|
src_file = os.path.join(template_dir, src)
|
|
45
47
|
shutil.copy(src_file, dest)
|
|
46
48
|
|
|
49
|
+
|
|
47
50
|
def replace_template_content(service_name, class_name, file_name):
|
|
48
51
|
file_path = os.path.join(service_name, file_name)
|
|
49
52
|
with open(file_path, 'r+', encoding='utf-8') as file:
|
|
@@ -54,9 +57,11 @@ def replace_template_content(service_name, class_name, file_name):
|
|
|
54
57
|
file.write(updated_data)
|
|
55
58
|
file.truncate() # Remove any leftover content after the replacement
|
|
56
59
|
|
|
60
|
+
|
|
57
61
|
def create_service(name):
|
|
58
62
|
if os.path.exists(name):
|
|
59
|
-
response = input(
|
|
63
|
+
response = input(
|
|
64
|
+
f"Service {name} already exists. Do you want to overwrite it? (y/N): ").strip().lower()
|
|
60
65
|
if response == 'y':
|
|
61
66
|
shutil.rmtree(name)
|
|
62
67
|
else:
|
|
@@ -66,15 +71,18 @@ def create_service(name):
|
|
|
66
71
|
os.mkdir(name)
|
|
67
72
|
open(os.path.join(name, "__init__.py"), 'a', encoding='utf-8').close()
|
|
68
73
|
|
|
69
|
-
cpy("service/service_class.tmpl",
|
|
74
|
+
cpy("service/service_class.tmpl",
|
|
75
|
+
os.path.join(name, to_pascal_case(name)+"Svc.py"))
|
|
70
76
|
|
|
71
|
-
cpy("service/service.yaml", os.path.join(name, "service.yaml")
|
|
72
|
-
cpy("service/functions.tmpl", os.path.join(name, "functions.py")
|
|
73
|
-
cpy("service/service.test.tmpl", os.path.join(name, f"test_{name}.py")
|
|
77
|
+
cpy("service/service.yaml", os.path.join(name, "service.yaml"))
|
|
78
|
+
cpy("service/functions.tmpl", os.path.join(name, "functions.py"))
|
|
79
|
+
cpy("service/service.test.tmpl", os.path.join(name, f"test_{name}.py"))
|
|
74
80
|
|
|
75
|
-
replace_template_content(name, to_pascal_case(
|
|
81
|
+
replace_template_content(name, to_pascal_case(
|
|
82
|
+
name)+"Svc", to_pascal_case(name)+"Svc.py")
|
|
76
83
|
replace_template_content(name, to_pascal_case(name)+"Svc", "service.yaml")
|
|
77
|
-
replace_template_content(
|
|
84
|
+
replace_template_content(
|
|
85
|
+
name, to_pascal_case(name)+"Svc", f"test_{name}.py")
|
|
78
86
|
|
|
79
87
|
print(f"Service {name} created.")
|
|
80
88
|
print(f"Run `pam test {name}` to run tests for the service.")
|
|
@@ -88,12 +96,13 @@ def init_project():
|
|
|
88
96
|
cpy("init/pylintrc.tmpl", ".pylintrc")
|
|
89
97
|
cpy("init/gitignore.tmpl", ".gitignore")
|
|
90
98
|
cpy("init/dockerignore.tmpl", ".dockerignore")
|
|
91
|
-
cpy("init/
|
|
99
|
+
cpy("init/run_unit_test.sh", "run_unit_test.sh")
|
|
100
|
+
cpy("init/run_unit_test.bat", "run_unit_test.bat")
|
|
101
|
+
cpy("init/run_unit_test.ps1", "run_unit_test.ps1")
|
|
92
102
|
|
|
93
|
-
|
|
94
103
|
if not os.path.exists("requirements.txt"):
|
|
95
104
|
open("requirements.txt", 'a', encoding='utf-8').close()
|
|
96
|
-
|
|
105
|
+
|
|
97
106
|
with open("requirements.txt", "w", encoding='utf-8') as f:
|
|
98
107
|
subprocess.run(["pip", "freeze"], stdout=f, check=True)
|
|
99
108
|
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
FROM python:3.13-alpine
|
|
2
|
+
|
|
3
|
+
COPY . /app
|
|
4
|
+
|
|
5
|
+
WORKDIR /app
|
|
6
|
+
|
|
7
|
+
ENV DATA_FOLDER=/app/data
|
|
8
|
+
RUN mkdir -p $DATA_FOLDER
|
|
9
|
+
|
|
10
|
+
RUN pip install --upgrade pip
|
|
11
|
+
RUN pip cache purge
|
|
12
|
+
RUN pip install -r requirements.txt
|
|
13
|
+
|
|
14
|
+
EXPOSE 8000
|
|
15
|
+
|
|
16
|
+
ENV PYTHONUNBUFFERED=1
|
|
17
|
+
|
|
18
|
+
# ห้ามแก้ -w เป็นอย่างอื่น นอกจาก 1
|
|
19
|
+
# เพราะว่า service start เท่านั้นถึงจะรับ on_data ได้
|
|
20
|
+
# แต่ถ้ามีหลาย replica มีโอกาสที่ on_data จะเข้า ตัวที่ไม่ได้ Start
|
|
21
|
+
CMD ["gunicorn", "-w", "1", "-b", "0.0.0.0:8000", "main:app"]
|
|
@@ -21,7 +21,9 @@ pam/templates/init/dockerignore.tmpl
|
|
|
21
21
|
pam/templates/init/gitignore.tmpl
|
|
22
22
|
pam/templates/init/main.tmpl
|
|
23
23
|
pam/templates/init/pylintrc.tmpl
|
|
24
|
-
pam/templates/init/
|
|
24
|
+
pam/templates/init/run_unit_test.bat
|
|
25
|
+
pam/templates/init/run_unit_test.ps1
|
|
26
|
+
pam/templates/init/run_unit_test.sh
|
|
25
27
|
pam/templates/service/functions.tmpl
|
|
26
28
|
pam/templates/service/service.test.tmpl
|
|
27
29
|
pam/templates/service/service.yaml
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
FROM python:3.13-alpine
|
|
2
|
-
|
|
3
|
-
COPY . /app
|
|
4
|
-
|
|
5
|
-
WORKDIR /app
|
|
6
|
-
|
|
7
|
-
ENV DATA_FOLDER=/app/data
|
|
8
|
-
RUN mkdir -p $DATA_FOLDER
|
|
9
|
-
|
|
10
|
-
RUN pip install --upgrade pip
|
|
11
|
-
RUN pip cache purge
|
|
12
|
-
RUN pip install -r requirements.txt
|
|
13
|
-
|
|
14
|
-
EXPOSE 8000
|
|
15
|
-
|
|
16
|
-
ENV PYTHONUNBUFFERED=1
|
|
17
|
-
|
|
18
|
-
CMD ["gunicorn", "-w", "4", "-b", "0.0.0.0:8000", "main:app"]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|