Key Changes: - Updated metadata_extractor_mvp.py to use SIMPLE structure for all tabular fields - All tabular fields now use direct value objects (no MetadataTableFieldRow wrapper) - MAIN_LANGUAGES, ASSETCOMPLIANCE, MARKETING_TAG, CREATIVEX all use SIMPLE structure - Master Asset ID field updated to SIMPLE structure - Date fields now use type 'string' instead of 'long' - Matches DAM reference structure from asset_representation.json Added Files: - metadata_extractor_mvp_PROD.py: PROD-specific version with same SIMPLE structure - Backup files for safety - Analysis and comparison documentation Environment: - Tested and working in PPR environment (ppr.dam.ferrero.com) - All tabular fields match DAM-supplied reference structure - Successful uploads confirmed Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
154 lines
4.4 KiB
Python
Executable file
154 lines
4.4 KiB
Python
Executable file
#!/usr/bin/env python3
|
|
"""
|
|
Interactive Campaign Status Advance A1→A3
|
|
Allows user to advance A1 campaigns directly to A3 (skip A2)
|
|
Shows campaign details and asks for confirmation for each one
|
|
Useful for testing workflow progression
|
|
Compatible with Python 3.6+
|
|
"""
|
|
|
|
import sys
|
|
import os
|
|
import logging
|
|
import argparse
|
|
|
|
# Add shared library to path
|
|
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
|
|
|
|
from shared.config_loader import load_config
|
|
from shared.dam_client import DAMClient
|
|
|
|
# Setup simple console logging
|
|
logging.basicConfig(
|
|
level=logging.INFO,
|
|
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
|
|
)
|
|
|
|
logger = logging.getLogger('AdvanceA1toA3')
|
|
|
|
def get_user_confirmation(campaign_name, campaign_number):
|
|
"""
|
|
Ask user if they want to advance this campaign to A3
|
|
|
|
Args:
|
|
campaign_name: Campaign name
|
|
campaign_number: Campaign number (e.g., C000000078)
|
|
|
|
Returns:
|
|
bool: True if user says yes, False if no
|
|
"""
|
|
print("")
|
|
print("=" * 70)
|
|
print("Campaign: {}".format(campaign_name))
|
|
print("Number: {}".format(campaign_number if campaign_number else 'N/A'))
|
|
print("Current: A1")
|
|
print("Target: A3")
|
|
print("=" * 70)
|
|
|
|
while True:
|
|
response = input("Advance this campaign A1 → A3? (yes/no): ").strip().lower()
|
|
|
|
if response in ['yes', 'y']:
|
|
return True
|
|
elif response in ['no', 'n']:
|
|
return False
|
|
else:
|
|
print("Please enter 'yes' or 'no'")
|
|
|
|
def main():
|
|
"""Main interactive loop"""
|
|
# Parse command-line arguments
|
|
parser = argparse.ArgumentParser(description='Interactive Campaign Advance A1→A3')
|
|
parser.add_argument('--auth-pfx', action='store_true',
|
|
help='Use mTLS certificate authentication instead of OAuth2')
|
|
args = parser.parse_args()
|
|
|
|
print("")
|
|
print("=" * 70)
|
|
print("Ferrero Campaign Status Advance: A1 → A3")
|
|
if args.auth_pfx:
|
|
print("Authentication: mTLS Certificate (--auth-pfx)")
|
|
else:
|
|
print("Authentication: OAuth2 (default)")
|
|
print("")
|
|
print("Note: This skips A2 status and goes directly to A3")
|
|
print(" Useful for testing A2→A3 upload workflow")
|
|
print("=" * 70)
|
|
print("")
|
|
|
|
# Load configuration
|
|
config = load_config('config/config.yaml')
|
|
|
|
# Initialize DAM client
|
|
dam = DAMClient(config, use_mtls=args.auth_pfx)
|
|
|
|
# Test connection
|
|
logger.info("Testing DAM connection...")
|
|
if not dam.test_connection():
|
|
logger.error("DAM connection failed - exiting")
|
|
sys.exit(1)
|
|
|
|
logger.info("DAM connection OK")
|
|
print("")
|
|
|
|
# Get all A1 campaigns
|
|
logger.info("Searching for A1 campaigns...")
|
|
campaigns = dam.search_campaigns(status='A1')
|
|
|
|
if not campaigns:
|
|
print("")
|
|
print("No A1 campaigns found")
|
|
print("Exiting...")
|
|
sys.exit(0)
|
|
|
|
print("")
|
|
print("=" * 70)
|
|
print("Found {} A1 campaign(s) to review".format(len(campaigns)))
|
|
print("=" * 70)
|
|
print("")
|
|
|
|
# Process each campaign
|
|
advanced_count = 0
|
|
skipped_count = 0
|
|
|
|
for i, campaign in enumerate(campaigns, 1):
|
|
campaign_id = campaign['asset_id']
|
|
campaign_name = campaign['campaign_name']
|
|
campaign_number = campaign.get('campaign_id', 'N/A')
|
|
|
|
print("")
|
|
print("Campaign {}/{}".format(i, len(campaigns)))
|
|
|
|
# Ask user for confirmation
|
|
if get_user_confirmation(campaign_name, campaign_number):
|
|
# User said yes - advance to A3
|
|
print("")
|
|
print("Advancing campaign A1 → A3...")
|
|
|
|
result = dam.update_campaign_status(campaign_id, 'A3')
|
|
|
|
if result['success']:
|
|
print("✓ SUCCESS: Campaign advanced to A3")
|
|
advanced_count += 1
|
|
else:
|
|
print("✗ FAILED: {}".format(result.get('error', 'Unknown error')))
|
|
print("Continuing to next campaign...")
|
|
else:
|
|
# User said no - skip
|
|
print("Skipped (no change)")
|
|
skipped_count += 1
|
|
|
|
# Final summary
|
|
print("")
|
|
print("=" * 70)
|
|
print("Summary")
|
|
print("=" * 70)
|
|
print("Total campaigns reviewed: {}".format(len(campaigns)))
|
|
print("Advanced to A3: {}".format(advanced_count))
|
|
print("Skipped: {}".format(skipped_count))
|
|
print("=" * 70)
|
|
print("")
|
|
print("Done!")
|
|
|
|
if __name__ == '__main__':
|
|
main()
|