cleanup
This commit is contained in:
52
bitbylaw/scripts/calendar_sync/delete_all_calendars.py
Normal file
52
bitbylaw/scripts/calendar_sync/delete_all_calendars.py
Normal file
@@ -0,0 +1,52 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Script to delete all calendars from Google Calendar account
|
||||
"""
|
||||
import asyncio
|
||||
import sys
|
||||
import os
|
||||
sys.path.append('.')
|
||||
|
||||
from steps.advoware_cal_sync.calendar_sync_event_step import get_google_service
|
||||
|
||||
async def delete_all_calendars():
|
||||
"""Delete all calendars from the Google account"""
|
||||
try:
|
||||
service = await get_google_service()
|
||||
|
||||
# Get all calendars
|
||||
print("Fetching calendar list...")
|
||||
calendars_result = service.calendarList().list().execute()
|
||||
calendars = calendars_result.get('items', [])
|
||||
|
||||
print(f"Raw calendars result: {calendars_result}")
|
||||
print(f"Calendars list: {calendars}")
|
||||
|
||||
print(f"Found {len(calendars)} calendars to delete:")
|
||||
|
||||
for calendar in calendars:
|
||||
calendar_id = calendar['id']
|
||||
summary = calendar.get('summary', 'No summary')
|
||||
primary = calendar.get('primary', False)
|
||||
|
||||
print(f" - {summary} (ID: {calendar_id}, Primary: {primary})")
|
||||
|
||||
# Skip primary calendar if you want to keep it
|
||||
if primary:
|
||||
print(f" Skipping primary calendar: {summary}")
|
||||
continue
|
||||
|
||||
try:
|
||||
# Delete the calendar
|
||||
service.calendars().delete(calendarId=calendar_id).execute()
|
||||
print(f" ✓ Deleted calendar: {summary}")
|
||||
except Exception as e:
|
||||
print(f" ✗ Failed to delete calendar {summary}: {e}")
|
||||
|
||||
print("\nAll non-primary calendars have been deleted.")
|
||||
|
||||
except Exception as e:
|
||||
print(f"Error: {e}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(delete_all_calendars())
|
||||
Reference in New Issue
Block a user