PyXA icon indicating copy to clipboard operation
PyXA copied to clipboard

No calendars found

Open sbeaumont opened this issue 1 year ago • 1 comments

Hi,

I'm trying out PyXA to extract calendar events, but it does not seem to work. I've tested print(PyXA.Application("Safari").front_window.current_tab.url) which works fine, so my PyXA install should be working.

app = PyXA.Application("Calendar") print(app.calendars())

leads to an empty list

<<class 'PyXA.apps.Calendar.XACalendarCalendarList'>[]>

despite me having a ton of calendars visible in the Calendar app. All my calendars are tied to categorties or accounts like iCloud and Google and "other".

I have tried to look in the docs, but can't find a reference to finding calendars in any other way.

Tried creating a new calendar, but that also does not work:

`Traceback (most recent call last): File "(My project path)/test.py", line 9, in new_calendar = app.new_calendar("PyXA Development") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "(My project path)/.venv/lib/python3.11/site-packages/PyXA/apps/Calendar.py", line 244, in new_calendar self.calendars().push(new_calendar) File "(My project path)/.venv/lib/python3.11/site-packages/PyXA/XABase.py", line 884, in push self.xa_elem.get().addObject_(element.xa_elem) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'addObject_'

Process finished with exit code 1`

sbeaumont avatar May 08 '24 21:05 sbeaumont

Hi, thanks for filing an issue! I believe the issue is that wherever you're running the Python script from lacks permission to access or modify the calendar.

If you're running the code from Terminal, make sure Calendar is enabled under Settings -> Privacy & Security -> Automation -> Terminal. Other terminal emulators like iTerm should be similar. However, with VSCode, I can't get your code working even when permissions are enabled, unfortunately.

Let me know if that helps!

I'll see about adding better error reporting for this.

SKaplanOfficial avatar May 09 '24 03:05 SKaplanOfficial