SKaplanOfficial / PyXA

Python for Automation
https://skaplanofficial.github.io/PyXA/
MIT License
116 stars 4 forks source link

No calendars found #20

Open sbeaumont opened 6 months ago

sbeaumont commented 6 months ago

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.xaelem.get().addObject(element.xaelem) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'addObject'

Process finished with exit code 1`

SKaplanOfficial commented 6 months ago

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.