def get_calendar(self, appointment_id): try: appointmet = self.get_appointment(appointment_id) if appointmet: cal = Calendar() cal.add( 'prodid', '-//{0} Events Calendar//{1}//'.format( "BMW service Appointment", "BMW service Appointment")) cal.add('version', '2.0') ical_event = Event() ical_event.add('summary', "Appointment Scheduled with BMW Services") ical_event.add('dtstart', appointmet.start_time) ical_event.add( 'dtend', appointmet.start_time + datetime.timedelta(minutes=20)) ical_event.add('dtstamp', appointmet.start_time) ical_event['uid'] = str(appointmet.confirmation_code) cal.add_component(ical_event) return cal else: return False except Exception, e: print e return False