ferrero-opentext/Python-Version/scripts/shared
DJP 65f2c9c68e Add Box file deletion, email notifications, and log rotation for A2→A3
Major Features Added:

1. Delete Files from Box After Upload
   - After successful DAM upload, delete file from Box
   - Prevents reprocessing same files
   - Keeps Box folder clean
   - Only deletes on success (keeps on failure for retry)

2. Email Notification for Each Upload
   - New template: a2_to_a3_file_uploaded
   - Sends email immediately after each successful upload
   - Includes: filename, clean filename, asset ID, tracking ID
   - Don't wait for "all done" - notify per file
   - Recipients: configured in .env (REPORT_EMAILS)

3. Log Rotation for Both Scripts
   - Uses RotatingFileHandler
   - Max file size: 10MB per log file
   - Backup count: 28 files (approximately 1 month)
   - Auto-rotates when log reaches 10MB
   - Keeps logs/a1_to_a2.log (current)
   - Backups: logs/a1_to_a2.log.1, .2, .3, etc.
   - Automatically deletes logs older than 28 rotations
   - Applied to both A1→A2 and A2→A3 scripts

Flow Changes:
A2→A3 now:
1. Poll Box folder
2. Find V2 files
3. Download from Box
4. Upload to DAM
5. Delete from Box  NEW
6. Send email notification  NEW
7. Store derivative record
8. Exit

Log Management:
- Active logs: ~10MB max
- Rotated backups: 28 files = ~280MB total
- Automatic cleanup (no manual intervention needed)
- 1 week of detailed logs + 3 weeks of backups

Database:
- Added dam_asset_id and upload_status columns to derivative_assets
- Fixed store_derivative_asset() to use existing schema columns

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-30 19:41:02 -04:00
..
__pycache__ Add A2→A3 polling version and fix database to use existing columns 2025-10-30 19:21:13 -04:00
__init__.py Start Python automation - Foundation components 2025-10-30 16:38:26 -04:00
box_client.py Add A2→A3 polling version and fix database to use existing columns 2025-10-30 19:21:13 -04:00
config_loader.py Start Python automation - Foundation components 2025-10-30 16:38:26 -04:00
dam_client.py PYTHON AUTOMATION FULLY WORKING! Complete A1→A2 workflow tested successfully 2025-10-30 17:50:24 -04:00
database.py Add A2→A3 polling version and fix database to use existing columns 2025-10-30 19:21:13 -04:00
filename_parser.py Complete Python automation implementation - All components built 2025-10-30 16:49:14 -04:00
metadata_extractor_mvp.py Complete Python automation implementation - All components built 2025-10-30 16:49:14 -04:00
notifier.py Add Box file deletion, email notifications, and log rotation for A2→A3 2025-10-30 19:41:02 -04:00