[Remind-Fans] From remind to Google calendar

Monty Zukowski monty at codetransform.com
Mon Sep 17 18:26:30 EDT 2007


I just realized the remind -s parsing is not correct for the latest
version of remind.  Here's better code for the parsing:

def events():
    output = subprocess.Popen(["remind", "-s",
"/home/monty/.reminders"], stdout=subprocess.PIPE).communicate()[0]
    events = []
    for line in string.split(output, '\n'):
        if string.strip(line):
            print line
            t=string.split(line)
            date = t[0]
            time = t[5]
            duration = t[3]
            msg = string.join(t[6:])
            events.append(Event( date, time, duration, msg))
    return events

Monty

On 9/17/07, Monty Zukowski <monty at codetransform.com> wrote:
> This script doesn't handle all day events.  It doesn't create
> recurring vevents either, just one event per line of output of remind
> -s.  It works for me though.
>
> First I tried iCalendar.py, but that didn't seem to do timezones
> automatically.  Then I tried vObject.py.  That handles timezones, but
> the standard python example timezones weren't up to date for
> US/Pacific.  I noticed in vObject the program to_pst.py.  It used
> PyICU.  That depended on ibm's ICU library.  The debian package is
> libicu36-dev, which I installed.  Then PyICU's binaries wouldn't link
> to that, so I built it from source instead.  With that in place, I
> finally seem to have timezone support working properly.
>
> http://www.thescoop.org/archives/2007/07/31/django-ical-and-vobject/
> helped me out a bit in figuring out some of the vevent details.
>
> More information on IBM's ICU at http://www.icu-project.org/
>
> import vobject, datetime
> import subprocess, string
> import PyICU
>
> class Event:
>     def __init__(self, date, time, duration, msg):
>         self.date=date
>         self.time=time
>         self.duration=duration
>         self.msg=msg
>         self.dtstart=datetime.datetime.strptime(date+" " +time,
> "%Y/%m/%d %I:%M%p")
>         self.dtend = self.dtstart + datetime.timedelta(minutes=int(duration))
> def events():
>     output = subprocess.Popen(["remind", "-s",
> "/home/monty/.reminders"], stdout=subprocess.PIPE).communicate()[0]
>     events = []
>     for line in string.split(output, '\n'):
>         if string.strip(line):
>             msg= string.split(line, 'MSG')[1]
>             body = string.split(line, 'repeat')[0]
>             t=string.split(body)
>             date = t[0]
>             time = t[5]
>             duration = t[3]
>             events.append(Event( date, time, duration, msg))
>     return events
>
> pst = PyICU.ICUtzinfo.getInstance('US/Pacific')
>
>
> cal = vobject.iCalendar()
> cal.add('prodid').value='-//Remind2ical//codetransform.com//'
> cal.add('version').value='2.0'
> cal.add('method').value='PUBLISH'
>
> events = events()
>
> for e in events:
>   ev1 = cal.add('vevent')
>   ev1.add('dtstart').value = e.dtstart
>   ev1.add('dtend').value = e.dtend
>   ev1.add('dtstamp').value = datetime.datetime.now()
>   ev1.add('summary').value = e.msg
>
> f = open('monty.ics', 'w')
> f.write( cal.serialize())
> f.close()
>
> I hereby place this code in the public domain.
>
> Monty
>
> On 9/17/07, Daniel Martins <danielemc at gmail.com> wrote:
> > > It was a pain to install
> > > vObject and PyICU and the IBM ICU libraries, all just to get proper
> > > timezones, however now I can finally get my 'remind' work schedule
> > > into Google calendar.
> >
> > Great!
> >
> >  Could you please send us the complete recipe to us?
> >
> > Daniel
> >
> > 2007/9/17, Monty Zukowski <monty at codetransform.com>:
> > > Thanks for the quick response!
> > >
> > > I installed 03.01.02 and got that example to work.  I originally had
> > > Dec 22 as the end date, but moved it to Sept just to see if it would
> > > end in this month...
> > >
> > > I have made my own little remind2ical.py script since nothing I could
> > > find out there handled timezones well.  It was a pain to install
> > > vObject and PyICU and the IBM ICU libraries, all just to get proper
> > > timezones, however now I can finally get my 'remind' work schedule
> > > into Google calendar.
> > >
> > > Monty
> > >
> > > On 9/17/07, David F. Skoll <dfs at roaringpenguin.com> wrote:
> > > > Monty Zukowski wrote:
> > > >
> > > > > What I'm trying to say is I'm working 9-2 Mondays & Wednesdays between
> > > > > Sept. 15 2007 and Sept 22 2007 (exclusive).
> > > >
> > > > That's just two days, so you could do it as two simple separate
> > reminders.
> > > >
> > > > If you have the latest version of Remind:
> > > >
> > > > REM Mon Wed AT 9:00 DURATION 5:00 FROM 15 Sep 2007 UNTIL 22 Sep 2007 MSG
> > ...
> > > >
> > > > You need at least 03.01.01 to get the "FROM..." clause.
> > > >
> > > > > REM Mon Wed AT 9:00 DURATION 5:00 repeat UNTIL 22 Sep SATISFY
> > > > > [trigdate() >= '2007-09-15'] MSG Monty working
> > > >
> > > > "repeat" is not a Remind keyword, so it's as if you wrote:
> > > >
> > > > REM Mon Wed AT 9:00 DURATION 5:00 MSG repeat ...
> > > >
> > > > Regards,
> > > >
> > > > David.
> > > > _______________________________________________
> > > > Remind-fans mailing list
> > > > Remind-fans at lists.whatexit.org
> > > > http://lists.whatexit.org/mailman/listinfo/remind-fans
> > > >
> > > _______________________________________________
> > > Remind-fans mailing list
> > > Remind-fans at lists.whatexit.org
> > > http://lists.whatexit.org/mailman/listinfo/remind-fans
> > >
> >
> >
> > _______________________________________________
> > Remind-fans mailing list
> > Remind-fans at lists.whatexit.org
> > http://lists.whatexit.org/mailman/listinfo/remind-fans
> >
> >
>



More information about the Remind-fans mailing list