Python script to process Google Calendar and Add Hangout links to Description.
Python
Latest commit 7f5bee2 Oct 13, 2015 @Yeraze Merge pull request #5 from EvgenKostenko/master
fix crash when event declined
Permalink
Failed to load latest commit information.
apiclient Upgrade to gdata v3 api Dec 2, 2013
httplib2
oauth2client Upgrade to gdata v3 api Dec 2, 2013
uritemplate
.gitignore
CalendarHangout.sublime-project
LICENSE Initial commit Nov 28, 2013
README.md
com.yeraze.hangoutFix.plist Added logfiles (stdout/stderr) to launchctl specs Jan 7, 2014
hangoutFix.py

README.md

CalendarHangout

Python script to process Google Calendar and Add Hangout links to Description.

Prereqs

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
  • 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.

If any of those complain about permission denied, then just prefix the command with sudo and it should work.

First Run

Before your first run (which you'll need to do manually from the commandline)

  1. Create a ~/.hangoutFix directory
  2. Place your shiny new client_secrets.json file in it.
  3. Change the "CalendarID" at the Top of hangoutFix.py to your calendar. (note: if using Google Apps for Domains, this is your e-mail address)
  4. Now run it.. It will redirect you to your browser to enable access.
  5. 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.

Using launchctl

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. Then:

  • 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 24 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.