pam-python 0.1.43__tar.gz → 0.1.45__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.43/pam_python.egg-info → pam_python-0.1.45}/PKG-INFO +1 -1
- {pam_python-0.1.43 → pam_python-0.1.45}/pam/temp_file_utils.py +27 -5
- {pam_python-0.1.43 → pam_python-0.1.45}/pam/templates/init/AGENT.md +1 -1
- {pam_python-0.1.43 → pam_python-0.1.45/pam_python.egg-info}/PKG-INFO +1 -1
- {pam_python-0.1.43 → pam_python-0.1.45}/setup.py +1 -1
- {pam_python-0.1.43 → pam_python-0.1.45}/LICENSE.txt +0 -0
- {pam_python-0.1.43 → pam_python-0.1.45}/README.md +0 -0
- {pam_python-0.1.43 → pam_python-0.1.45}/pam/__init__.py +0 -0
- {pam_python-0.1.43 → pam_python-0.1.45}/pam/api.py +0 -0
- {pam_python-0.1.43 → pam_python-0.1.45}/pam/cli.py +0 -0
- {pam_python-0.1.43 → pam_python-0.1.45}/pam/interface_task_manager.py +0 -0
- {pam_python-0.1.43 → pam_python-0.1.45}/pam/logger.py +0 -0
- {pam_python-0.1.43 → pam_python-0.1.45}/pam/models/__init__.py +0 -0
- {pam_python-0.1.43 → pam_python-0.1.45}/pam/models/request_command.py +0 -0
- {pam_python-0.1.43 → pam_python-0.1.45}/pam/request_file_format.py +0 -0
- {pam_python-0.1.43 → pam_python-0.1.45}/pam/server.py +0 -0
- {pam_python-0.1.43 → pam_python-0.1.45}/pam/service.py +0 -0
- {pam_python-0.1.43 → pam_python-0.1.45}/pam/sqlite.py +0 -0
- {pam_python-0.1.43 → pam_python-0.1.45}/pam/task_manager.py +0 -0
- {pam_python-0.1.43 → pam_python-0.1.45}/pam/templates/buildcmd/pamb +0 -0
- {pam_python-0.1.43 → pam_python-0.1.45}/pam/templates/buildcmd/pamb-base.sh +0 -0
- {pam_python-0.1.43 → pam_python-0.1.45}/pam/templates/docker/Dockerfile +0 -0
- {pam_python-0.1.43 → pam_python-0.1.45}/pam/templates/init/dockerignore.tmpl +0 -0
- {pam_python-0.1.43 → pam_python-0.1.45}/pam/templates/init/gitignore.tmpl +0 -0
- {pam_python-0.1.43 → pam_python-0.1.45}/pam/templates/init/main.tmpl +0 -0
- {pam_python-0.1.43 → pam_python-0.1.45}/pam/templates/init/pylintrc.tmpl +0 -0
- {pam_python-0.1.43 → pam_python-0.1.45}/pam/templates/init/requirements.txt +0 -0
- {pam_python-0.1.43 → pam_python-0.1.45}/pam/templates/init/run_unit_test.bat +0 -0
- {pam_python-0.1.43 → pam_python-0.1.45}/pam/templates/init/run_unit_test.ps1 +0 -0
- {pam_python-0.1.43 → pam_python-0.1.45}/pam/templates/init/run_unit_test.sh +0 -0
- {pam_python-0.1.43 → pam_python-0.1.45}/pam/templates/service/functions.tmpl +0 -0
- {pam_python-0.1.43 → pam_python-0.1.45}/pam/templates/service/service.test.tmpl +0 -0
- {pam_python-0.1.43 → pam_python-0.1.45}/pam/templates/service/service.yaml +0 -0
- {pam_python-0.1.43 → pam_python-0.1.45}/pam/templates/service/service_class.tmpl +0 -0
- {pam_python-0.1.43 → pam_python-0.1.45}/pam/tester_task.py +0 -0
- {pam_python-0.1.43 → pam_python-0.1.45}/pam/utils.py +0 -0
- {pam_python-0.1.43 → pam_python-0.1.45}/pam_python.egg-info/SOURCES.txt +0 -0
- {pam_python-0.1.43 → pam_python-0.1.45}/pam_python.egg-info/dependency_links.txt +0 -0
- {pam_python-0.1.43 → pam_python-0.1.45}/pam_python.egg-info/entry_points.txt +0 -0
- {pam_python-0.1.43 → pam_python-0.1.45}/pam_python.egg-info/requires.txt +0 -0
- {pam_python-0.1.43 → pam_python-0.1.45}/pam_python.egg-info/top_level.txt +0 -0
- {pam_python-0.1.43 → pam_python-0.1.45}/setup.cfg +0 -0
|
@@ -9,9 +9,8 @@ from pam.utils import log
|
|
|
9
9
|
def clean_old_folders(days: int, base_folder_path: str):
|
|
10
10
|
"""
|
|
11
11
|
Cleans up folders older than the specified number of days in the base folder.
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
:param base_folder_path: The base folder path to clean.
|
|
12
|
+
- If days >= 0: Retains folders from 'today' up to 'days' ago.
|
|
13
|
+
- If days < 0: Force deletes ALL folders unconditionally.
|
|
15
14
|
"""
|
|
16
15
|
base_folder = Path(base_folder_path)
|
|
17
16
|
|
|
@@ -23,19 +22,42 @@ def clean_old_folders(days: int, base_folder_path: str):
|
|
|
23
22
|
base_folder.unlink()
|
|
24
23
|
return
|
|
25
24
|
|
|
26
|
-
|
|
25
|
+
# ใช้ .replace เพื่อตัด Hour, Minute, Second, Microsecond ออกให้เป็น 00:00:00 ของวันนั้นๆ
|
|
26
|
+
today_start = datetime.now().replace(hour=0, minute=0, second=0, microsecond=0)
|
|
27
|
+
cutoff_date = today_start - timedelta(days=days)
|
|
28
|
+
|
|
27
29
|
folders_removed = 0
|
|
28
30
|
|
|
29
31
|
for folder in base_folder.iterdir():
|
|
30
32
|
if folder.is_dir():
|
|
31
33
|
try:
|
|
34
|
+
# กรณี days < 0 (เช่น -1) ให้ลบทุกโฟลเดอร์ทันทีโดยไม่เช็ควันที่
|
|
35
|
+
if days < 0:
|
|
36
|
+
shutil.rmtree(folder)
|
|
37
|
+
log(f"Force removed folder: {folder}")
|
|
38
|
+
folders_removed += 1
|
|
39
|
+
continue
|
|
40
|
+
|
|
41
|
+
# กรณี days >= 0 (เช่น 0, 1, 10)
|
|
32
42
|
folder_date = datetime.strptime(folder.name, "%Y_%m_%d")
|
|
43
|
+
|
|
44
|
+
# ถ้า folder_date น้อยกว่า cutoff_date ถึงจะลบ
|
|
33
45
|
if folder_date < cutoff_date:
|
|
34
46
|
shutil.rmtree(folder)
|
|
35
47
|
log(f"Removed folder: {folder}")
|
|
36
48
|
folders_removed += 1
|
|
49
|
+
|
|
37
50
|
except ValueError:
|
|
38
|
-
|
|
51
|
+
# เผื่อมีคนสร้างโฟลเดอร์ชื่ออื่นไว้ ถ้าสั่ง days < 0 ก็ควรลบออกไปด้วยเพื่อความสะอาด
|
|
52
|
+
if days < 0:
|
|
53
|
+
try:
|
|
54
|
+
shutil.rmtree(folder)
|
|
55
|
+
log(f"Force removed unexpected folder: {folder}")
|
|
56
|
+
folders_removed += 1
|
|
57
|
+
except Exception as e:
|
|
58
|
+
log(f"Error removing unexpected folder {folder}: {e}")
|
|
59
|
+
else:
|
|
60
|
+
log(f"Skipping folder: {folder} (unexpected name format)")
|
|
39
61
|
except Exception as e:
|
|
40
62
|
log(f"Error removing folder {folder}: {e}")
|
|
41
63
|
|
|
@@ -160,7 +160,7 @@ Column meaning
|
|
|
160
160
|
- Other columns depend on the agreement.
|
|
161
161
|
|
|
162
162
|
Date format is always:
|
|
163
|
-
`"
|
|
163
|
+
`"2025-09-11 13:07:38"`
|
|
164
164
|
Timezone may vary by customer data (usually Bangkok time).
|
|
165
165
|
You may sometimes be asked for the exact time zone if it is logically important for the program.
|
|
166
166
|
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|