Python script to process Google Calendar and Add Hangout links to Description.
Before running this, you need to get:
- Python
- The py-applescript python module
- The pyobjc python module (which you may already have)
- The dateutils module
- The GData Python Client v3 - Included
- Or you can install it globally via
easy_install --upgrade google-api-python-client
- Or you can install it globally via
- client_secrets.json file
- Easiest way to get that is via The Google Developer Console
- Create a new project, give it a good name like "Calendar Hangouts" (This can take a minute or two)
- Select "Enable an API" and turn on the "Calendar API"
- Under "APIs & Auth", click "Credentials"
- Click "Create a new Client ID", and select "Installed Application", select platform "Other"
- Then select "Download JSON"
Now, that list of prereqs may seem daunting to the Python-uninitiated, but it's not bad. Just do this:
easy_install pip
pip install py_applescript
pip install dateutils
pip install --upgrade google-api-python-client
If you're a Homebrew User, then you'll optionally also need to do:
pip install pyobjc
That one takes a while.
Note: if you receive errors about GameKit
when trying to run the script, your pyobjc
library may be out of date.
Clone the pyobjc repo (make sure to use commit a2cdc24
) and install it locally.
If any of those complain about permission denied, then just prefix the command with sudo
and it should work.
Before your first run (which you'll need to do manually from the commandline)
- Create a
~/.hangoutFix
directory - Place your shiny new
client_secrets.json
file in it. - Change the "CalendarID" at the Top of
hangoutFix.py
to your calendar, or use the--calendar
flag. - Now run it.. It will redirect you to your browser to enable access.
- Once you've granted access, it should take off and update.
You can safely Ctrl-C it if you don't want it to do the total run right now. Keep in mind, that you can't break while it's running the applescript, so you'll have to kill it between updates.
This script won't work inside of cron.. Don't ask me, blame apple.
Because of that, if you really want to automate it, you'll need to do so via launchctl.
So, edit the com.yeraze.hangoutFix.plist
file here to reflect the directory of where
you placed the newly corrected hangoutFix.py script, and the calendar ID/email to use. Then:
ln -s com.yeraze.hangoutFix.plist ~/Library/LaunchAgents
- launchctl load com.yeraze.hangoutFix.plist
- launchctl start com.yeraze.hangoutFix
That should start off the job. After that one completes, it should start another every 4 hours!
Note If you get a strange error like:
Could not open job overrides database at: /private/var/db/launchd.db/com.apple.launchd/overrides.plist: 13: Permission denied
launch_msg(): Socket is not connected
Then this means you're in tmux, aren't you? Either exit tmux and try it again, or read up on reattach-to-user-namespace
.