diff --git a/migrate_cache.py b/migrate_cache.py deleted file mode 100644 index 6f67065..0000000 --- a/migrate_cache.py +++ /dev/null @@ -1,63 +0,0 @@ -#!/usr/bin/env python3 -""" -migrate_cache.py - -Migrate DiskCache caches from “old” in‐memory entries (bytes, mime) into -“new” on‐disk read=True entries so that Flask can send them via send_file(path). - -Usage: - python migrate_cache.py /path/to/filecache_audio \ - /path/to/filecache_image \ - /path/to/filecache_video \ - /path/to/filecache_other -""" - -import io -import sys -from diskcache import Cache - -def migrate_cache(cache_path): - """ - Walks every key in the cache at `cache_path`. If the value is a tuple of - (bytes, mime), re‐writes it via read=True so DiskCache stores it as a file. - """ - print(f"➡ Migrating cache at {cache_path!r}") - cache = Cache(cache_path) - migrated = 0 - skipped = 0 - - # Iterate keys without loading everything into memory - for key in cache.iterkeys(): - try: - val = cache.get(key) - except Exception as e: - print(f" [ERROR] key={key!r} get failed: {e}") - continue - - # Detect old‐style entries: (bytes, mime) - if ( - isinstance(val, tuple) - and len(val) == 2 - and isinstance(val[0], (bytes, bytearray)) - and isinstance(val[1], str) - ): - data, mime = val - buf = io.BytesIO(data) - buf.seek(0) - # Re‐store as an on‐disk file - cache.set(key, buf, read=True) - migrated += 1 - else: - skipped += 1 - - cache.close() - print(f" → Done: migrated={migrated}, skipped={skipped}\n") - - -if __name__ == "__main__": - if len(sys.argv) < 2: - print("Usage: migrate_cache.py [ ...]") - sys.exit(1) - - for directory in sys.argv[1:]: - migrate_cache(directory) diff --git a/swap_city_country.py b/swap_city_country.py deleted file mode 100644 index 505967a..0000000 --- a/swap_city_country.py +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env python3 -import sqlite3 - -# — CONFIGURE — -DB_NAME = 'access_log.db' -INDICATORS = [ - "Germany", - "Canada", - "Paraguay", - "Uruguay", - "France", - "Australia", - "Ukraine", - "India" -] -# — END CONFIG — - -# connect exactly as you use elsewhere -log_db = sqlite3.connect(DB_NAME, check_same_thread=False) - -# build and run the swap -placeholders = ",".join("?" for _ in INDICATORS) -sql = f""" - UPDATE file_access_log - SET city = country, - country = city - WHERE city IN ({placeholders}) -""" -cur = log_db.cursor() -cur.execute(sql, INDICATORS) -log_db.commit() - -print(f"Swapped city↔country on {cur.rowcount} row{'s' if cur.rowcount!=1 else ''}.") -log_db.close()