my_gcal.py
Description
The my_gcal.py is a simple Python script that can insert an event to the Google Calendar. An event can comes from emails attachment, file of text/calendar type or command line parameter.
Usage
my_gcal.py [-m] [-P PROXY] -u USER@EMAIL -p PASSWORD <INPUT-FILENAME> [ <INPUT-FILENAME> ] my_gcal.py [-P PROXY] -u USER@EMAIL -p PASSWORD -n NEW_EVENT
With the -m option you can use an email folder (INPUT-FILENAME) as input. In that case, the my_gcal.py will read the first email record and will try to seachar the text/calendar mime-type attachment which will be processed. Without -m option, the INPUT-FILENAME will be treated as text/calendar mime-type file.
The -P option is for proxy definition. If this option is used, the $http_proxy and the $https_proxy environmental variables are sets (or override) by PROXY value. Useful in using with procmail.
With the -n option new event will be add. The NEW_EVENT is the strike like:
'2009-04-18 16:00-23:00 10080 [Septim] Dinner with my wife'
Where 10080 is how many minutes before is set the reminder, the my office is location of the event.
Usage in The Field
Mutt
If you wish to use the my_gcal.py with Mutt you should find useful line in the ~/.mailcap file:
text/calendar; APPROPRIATE_PATH/my_gcal.py -u 'USERNAME@EMAIL' -p 'PASSWORD' %s ; needsterminal;
It assume the follwing line in the ~/.muttrc configuration file:
set mailcap_path=/home/kokot/.mailcap:/etc/mailcap
Procmail
If you want to add all events automatically you can add following lines in the ~/.procmailrc file:
# add evet to the calendar :0c | APPROPRIATE_PATH/my_gcal.py -m -u 'USERNAME@EMAIL' -p 'PASSWORD' -P 'http://proxy.som ething.xy:1234'
Limitations
Note that only single event are supported for this time.
FAQ
Q: ImportError: No module named vobject
I received message like this:
Traceback (most recent call last): File "APPROPRIATE_PATH/my_gcal.py", line 42, in <module> import vobject ImportError: No module named vobject
What does it mean?
A: you have to install the vobject Python modukle.
Hint for Ubuntu:
sudo apt-get install python-vobject