pam-python 0.1.44__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.
Files changed (42) hide show
  1. {pam_python-0.1.44/pam_python.egg-info → pam_python-0.1.45}/PKG-INFO +1 -1
  2. {pam_python-0.1.44 → pam_python-0.1.45}/pam/temp_file_utils.py +27 -5
  3. {pam_python-0.1.44 → pam_python-0.1.45}/pam/templates/init/AGENT.md +1 -1
  4. {pam_python-0.1.44 → pam_python-0.1.45/pam_python.egg-info}/PKG-INFO +1 -1
  5. {pam_python-0.1.44 → pam_python-0.1.45}/setup.py +1 -1
  6. {pam_python-0.1.44 → pam_python-0.1.45}/LICENSE.txt +0 -0
  7. {pam_python-0.1.44 → pam_python-0.1.45}/README.md +0 -0
  8. {pam_python-0.1.44 → pam_python-0.1.45}/pam/__init__.py +0 -0
  9. {pam_python-0.1.44 → pam_python-0.1.45}/pam/api.py +0 -0
  10. {pam_python-0.1.44 → pam_python-0.1.45}/pam/cli.py +0 -0
  11. {pam_python-0.1.44 → pam_python-0.1.45}/pam/interface_task_manager.py +0 -0
  12. {pam_python-0.1.44 → pam_python-0.1.45}/pam/logger.py +0 -0
  13. {pam_python-0.1.44 → pam_python-0.1.45}/pam/models/__init__.py +0 -0
  14. {pam_python-0.1.44 → pam_python-0.1.45}/pam/models/request_command.py +0 -0
  15. {pam_python-0.1.44 → pam_python-0.1.45}/pam/request_file_format.py +0 -0
  16. {pam_python-0.1.44 → pam_python-0.1.45}/pam/server.py +0 -0
  17. {pam_python-0.1.44 → pam_python-0.1.45}/pam/service.py +0 -0
  18. {pam_python-0.1.44 → pam_python-0.1.45}/pam/sqlite.py +0 -0
  19. {pam_python-0.1.44 → pam_python-0.1.45}/pam/task_manager.py +0 -0
  20. {pam_python-0.1.44 → pam_python-0.1.45}/pam/templates/buildcmd/pamb +0 -0
  21. {pam_python-0.1.44 → pam_python-0.1.45}/pam/templates/buildcmd/pamb-base.sh +0 -0
  22. {pam_python-0.1.44 → pam_python-0.1.45}/pam/templates/docker/Dockerfile +0 -0
  23. {pam_python-0.1.44 → pam_python-0.1.45}/pam/templates/init/dockerignore.tmpl +0 -0
  24. {pam_python-0.1.44 → pam_python-0.1.45}/pam/templates/init/gitignore.tmpl +0 -0
  25. {pam_python-0.1.44 → pam_python-0.1.45}/pam/templates/init/main.tmpl +0 -0
  26. {pam_python-0.1.44 → pam_python-0.1.45}/pam/templates/init/pylintrc.tmpl +0 -0
  27. {pam_python-0.1.44 → pam_python-0.1.45}/pam/templates/init/requirements.txt +0 -0
  28. {pam_python-0.1.44 → pam_python-0.1.45}/pam/templates/init/run_unit_test.bat +0 -0
  29. {pam_python-0.1.44 → pam_python-0.1.45}/pam/templates/init/run_unit_test.ps1 +0 -0
  30. {pam_python-0.1.44 → pam_python-0.1.45}/pam/templates/init/run_unit_test.sh +0 -0
  31. {pam_python-0.1.44 → pam_python-0.1.45}/pam/templates/service/functions.tmpl +0 -0
  32. {pam_python-0.1.44 → pam_python-0.1.45}/pam/templates/service/service.test.tmpl +0 -0
  33. {pam_python-0.1.44 → pam_python-0.1.45}/pam/templates/service/service.yaml +0 -0
  34. {pam_python-0.1.44 → pam_python-0.1.45}/pam/templates/service/service_class.tmpl +0 -0
  35. {pam_python-0.1.44 → pam_python-0.1.45}/pam/tester_task.py +0 -0
  36. {pam_python-0.1.44 → pam_python-0.1.45}/pam/utils.py +0 -0
  37. {pam_python-0.1.44 → pam_python-0.1.45}/pam_python.egg-info/SOURCES.txt +0 -0
  38. {pam_python-0.1.44 → pam_python-0.1.45}/pam_python.egg-info/dependency_links.txt +0 -0
  39. {pam_python-0.1.44 → pam_python-0.1.45}/pam_python.egg-info/entry_points.txt +0 -0
  40. {pam_python-0.1.44 → pam_python-0.1.45}/pam_python.egg-info/requires.txt +0 -0
  41. {pam_python-0.1.44 → pam_python-0.1.45}/pam_python.egg-info/top_level.txt +0 -0
  42. {pam_python-0.1.44 → pam_python-0.1.45}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pam-python
3
- Version: 0.1.44
3
+ Version: 0.1.45
4
4
  Summary: Pam Python Library
5
5
  Home-page: https://github.com/heart/pam-python
6
6
  Author: Narongrit Kanhanoi
@@ -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
- :param days: Number of days to retain folders.
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
- cutoff_date = datetime.now() - timedelta(days=days)
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
- log(f"Skipping folder: {folder} (unexpected name format)")
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
- `"02/08/2026, 18:23:54"`
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
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pam-python
3
- Version: 0.1.44
3
+ Version: 0.1.45
4
4
  Summary: Pam Python Library
5
5
  Home-page: https://github.com/heart/pam-python
6
6
  Author: Narongrit Kanhanoi
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name="pam-python",
5
- version="0.1.44",
5
+ version="0.1.45",
6
6
  author="Narongrit Kanhanoi",
7
7
  author_email="narongrit@pams.ai",
8
8
  description="Pam Python Library",
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