initial commit

This commit is contained in:
2026-06-25 23:17:45 +00:00
commit 780fae7df0
11 changed files with 3502 additions and 0 deletions
+34
View File
@@ -0,0 +1,34 @@
#!/usr/bin/env python3
import os, time, shutil
DATA_ROOT = "/var/www/WEATHER/public_html/data"
TTL = 24 * 3600 # 24 hours
def is_old(path):
try:
age = time.time() - os.path.getmtime(path)
return age > TTL
except Exception:
return False
def main():
# Remove old files
for root, dirs, files in os.walk(DATA_ROOT, topdown=False):
for name in files:
p = os.path.join(root, name)
if is_old(p):
try:
os.remove(p)
except Exception as e:
print(f"Failed to remove {p}: {e}")
# Remove empty dirs
for d in dirs:
dp = os.path.join(root, d)
try:
if not os.listdir(dp):
os.rmdir(dp)
except Exception:
pass
if __name__ == "__main__":
main()