import paramiko

HOST = "135.125.102.180"
USER = "ubuntu"
PASS = "BotPascal2026!"
REMOTE_FILE = "/var/www/html/repondeur_mail_grok/data/queue.csv"

def main():
    try:
        ssh = paramiko.SSHClient()
        ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
        ssh.connect(HOST, username=USER, password=PASS)
        
        # Write only headers
        print("Clearing queue.csv...")
        # Columns from init_csv.php + body + sender_name
        header = "id,email,subject,date_received,tag_zimbra,grok_response,status,shop_id,client_id,body,sender_name\n"
        
        ssh.exec_command(f"echo '{header}' > {REMOTE_FILE}")
        ssh.exec_command(f"chmod 666 {REMOTE_FILE}")
        
        print("Queue cleared.")
        ssh.close()
    except Exception as e:
        print(f"Error: {e}")

if __name__ == "__main__":
    main()
