def main(): # Fill These Up date = "8/26/2016" maxdate = "8/30/2016" allday = "yes" #yes or no mintime = "8:00am" maxtime = "5:00pm" title = "Tibz - Out of Office" guest = "*****@*****.**" # Where you call cal = Calendar() cal.run(date, allday, mintime, maxdate, maxtime, title, guest) tes = Test()
def main(): # Fill These Up date = "8/26/2016" maxdate = "8/30/2016" allday = "yes" #yes or no mintime = "8:00am" maxtime = "5:00pm" title = "Tibz - Out of Office" guest = "*****@*****.**" # Where you call cal = Calendar() cal.run(date,allday,mintime,maxdate,maxtime,title,guest) tes = Test()
def test_tomorrow_event(self, mock__get_response): mock__get_response.return_value = [{ 'title': 'Interaktive Systeme', 'location': '', 'start': '09:00', 'end': '14:00' }] google_calendar = Calendar("DHBW6") events = google_calendar.get_first_event_tomorrow() response = { 'title': 'Interaktive Systeme', 'location': '', 'start': '09:00', 'end': '14:00' } self.assertEqual(events, response)
def test_todays_events(self, mock__get_response): mock__get_response.return_value = [{ 'title': 'Datenbanken', 'location': 'https://dhbw-stuttgart.zoom.us/j/99643057619', 'start': '10:00', 'end': '12:30' }, { 'title': 'Security', 'location': '', 'start': '13:15', 'end': '15:45' }, { 'title': 'Zero Knowledge', 'location': '', 'start': '13:00', 'end': '15:30' }] google_calendar = Calendar("DHBW6") events = google_calendar.get_events_today() response = [{ 'title': 'Datenbanken', 'location': 'https://dhbw-stuttgart.zoom.us/j/99643057619', 'start': '10:00', 'end': '12:30' }, { 'title': 'Security', 'location': '', 'start': '13:15', 'end': '15:45' }, { 'title': 'Zero Knowledge', 'location': '', 'start': '13:00', 'end': '15:30' }] self.assertEqual(events, response)
def pressedCalendarButton(self): try: calendarButtonCurrentGeometry = QtCore.QRect( self.calendarToolButton.geometry()) calendarButtonAnimation = QPropertyAnimation( self.calendarToolButton, 'geometry'.encode(encoding='utf_8')) calendarButtonAnimation.setDuration(self.ANIMATIONDURATION) calendarButtonAnimation.setStartValue( calendarButtonCurrentGeometry) calendarWidgetCurrentGeometry = QtCore.QRect( self.calendarWidget.geometry()) calendarWidgetAnimation = QPropertyAnimation( self.calendarWidget, 'geometry'.encode(encoding='utf_8')) calendarWidgetAnimation.setDuration(self.ANIMATIONDURATION) calendarWidgetAnimation.setStartValue( calendarWidgetCurrentGeometry) if self.CalendarCurrentState == 'Closed': calendarButtonEndTopLeftCorner = QtCore.QPoint( self.calendarToolButton.pos() - QtCore.QPoint(275, 0)) calendarWidgetEndTopLeftCorner = QtCore.QPoint( self.calendarWidget.pos() - QtCore.QPoint(275, 0)) self.CalendarCurrentState = 'Open' self.Calendar = Calendar() self.calendarLabel.setText(self.Calendar.EventList) else: calendarButtonEndTopLeftCorner = QtCore.QPoint( self.calendarToolButton.pos() + QtCore.QPoint(275, 0)) calendarWidgetEndTopLeftCorner = QtCore.QPoint( self.calendarWidget.pos() + QtCore.QPoint(275, 0)) self.CalendarCurrentState = 'Closed' calendarButtonFinalGeometry = QtCore.QRect( calendarButtonEndTopLeftCorner, QtCore.QSize(self.calendarToolButton.width(), self.calendarToolButton.height())) calendarButtonAnimation.setEndValue(calendarButtonFinalGeometry) calendarWidgetFinalGeometry = QtCore.QRect( calendarWidgetEndTopLeftCorner, QtCore.QSize(self.calendarWidget.width(), self.calendarWidget.height())) calendarWidgetAnimation.setEndValue(calendarWidgetFinalGeometry) calendarButtonAnimation.start() calendarWidgetAnimation.start() #self.setcalendarWidgetStyleSheet() self.CalendarIconAnimation = calendarButtonAnimation self.CalendarWidgetAnimation = calendarWidgetAnimation except Exception as e: print(e.strerror)
def test_get_events(self): today = datetime.now() calendar = Calendar("DHBW6") events = calendar.get_events_for_day(today) response = [{ 'title': 'Datenbanken', 'location': 'https://dhbw-stuttgart.zoom.us/j/99643057619', 'start': '10:00', 'end': '12:30' }, { 'title': 'Security', 'location': '', 'start': '13:15', 'end': '15:45' }, { 'title': 'Zero Knowledge', 'location': '', 'start': '13:00', 'end': '15:30' }] self.assertEqual(events, response)
def _reply(self, channel_id, source_user_id, dest_user): events = Calendar().is_busy(datetime.datetime.now(), dest_user.key.id()) if len(events) > 0: if source_user_id in dest_user.whitelist_ids: message = random.choice(self.FRIENDLY_MESSAGES) elif source_user_id in dest_user.blacklist_ids: message = random.choice(self.HATE_MESSAGES) else: message = random.choice(self.NORMAL_MESSAGES) message = message.format( meeting=events[0]['summary'], minutes=str(((int(events[0]['end']) - int(time.time())) / 60) - 240)) SlackApi().send_message(dest_user.slack_token, channel_id, message, True)
def __init__(self): client = MongoClient() self.db = client.courses self.actions = [] self.calendar = Calendar()
class Storage: def __init__(self): client = MongoClient() self.db = client.courses self.actions = [] self.calendar = Calendar() def save(self, courses): saved_graphics = self.__get_graphics() for saved_graphic in saved_graphics: found = False for course_graphic in reversed(courses): if saved_graphic['start_date'] == course_graphic['start_date'] and \ saved_graphic['end_date'] == course_graphic['end_date'] and \ saved_graphic['course_name'] == course_graphic['course_name']: self.__update(saved_graphic, course_graphic) courses.remove(course_graphic) found = True break # course has been deleted from online schedule. Therefore we delete it as well. if not found: self.__delete(saved_graphic) for course_graphic in courses: self.__insert(course_graphic) def get_actions(self): return self.actions def __action(self, type, graphic, data = []): self.actions.append({ 'type': type, 'graphic': graphic, 'data': data }) def __get_graphics(self): mongo_graphics = self.db.graphic.find({}) return mongo_graphics def __update(self, saved_graphic, course_graphic): diff = { key: val for key, val in course_graphic.items() if saved_graphic.get(key, None) != val } if diff: self.calendar.delete_event(saved_graphic['calendar_id']) calendar_desc = course_graphic['course_lecturer'] + ', ' + str(course_graphic['course_location']) + ', ' + str(course_graphic['course_type']) + ', ' + str(course_graphic['educational_form']) + ', ' + str(course_graphic['course_year']) calendar_id = self.calendar.insert_event(course_graphic['course_name'], calendar_desc, course_graphic['graphic_url'], course_graphic['start_date'], course_graphic['end_date']) if calendar_id: course_graphic['calendar_id'] = calendar_id self.db.graphic.update_one({'_id' : saved_graphic['_id']}, {'$set': course_graphic}) self.__action('update', course_graphic, diff) def __delete(self, saved_graphic): self.calendar.delete_event(saved_graphic['calendar_id']) self.db.graphic.delete_one({'_id' : saved_graphic['_id']}) self.__action('delete', saved_graphic) def __insert(self, course_graphic): calendar_desc = course_graphic['course_lecturer'] + ', ' + str(course_graphic['course_location']) + ', ' + str(course_graphic['course_type']) + ', ' + str(course_graphic['educational_form']) + ', ' + str(course_graphic['course_year']) calendar_id = self.calendar.insert_event(course_graphic['course_name'], calendar_desc, course_graphic['graphic_url'], course_graphic['start_date'], course_graphic['end_date']) if calendar_id: course_graphic['calendar_id'] = calendar_id self.db.graphic.insert_one(course_graphic) self.__action('insert', course_graphic)
def calendar_action(self, button, action_params): calendar = Calendar(self.settings, action_params['calendar_id']) self.event(calendar, action_params)
def add_classes_to_calendar(self): calendar = Calendar() for course in self.get_study_list(): if course["Time"] != "ON LINE": calendar.add_event(course)