<commit_before>#!/usr/bin/python3

# Access to mattermost
from matterhook import Webhook

import datetime
import html2text


from calendarBot.calendarBotSettings import *
from calendarBot.calendarApi import *
from calendarBot.calendarTimer import *

# Initialize Mattermost access
mattermostHook = Webhook(mattermostSettings['URL'], mattermostSettings['ApiKey'])
mattermostHook.username = mattermostSettings['Username']
mattermostHook.icon_url = mattermostSettings['IconURL']

def checkCalendarForUpcomingEvents():
    """
    Checks calendar for upcoming events
    """
    nowDate = datetime.datetime.now()
    laterDate = nowDate + datetime.timedelta(minutes = calendarSettings['TimespanToCheck'])
    successful, res = showAgenda('', nowDate.strftime("%d.%m.%Y %H:%M"), laterDate.strftime("%d.%m.%Y %H:%M"), True)
    if successful:
        for item in res:
            eventContent = 'EventName: {0}\n EventBeschreibung: {1}\n EventStart: {2}\n EventEnd: {3}\n EventLocation: {4}\n EventCategory: {5}\n\n'.format(item.subject, html2text.html2text(item.body),item.start.astimezone(EWSTimeZone.timezone('Europe/Copenhagen')), item.end.astimezone(EWSTimeZone.timezone('Europe/Copenhagen')), item.location, item.categories)
            for subcalendar in item.categories:
                try:
                    mattermostHook.send(eventContent, channel=subcalendar)
                except Exception as e:
                    messageContent = eventContent + '\n Error occured: \n {0} \n'.format(e.__doc__)
                    mattermostHook.send(messageContent, channel=mattermostSettings['DefaultChannel'])

timer = RepeatedTimer(calendarSettings['CheckInterval'], checkCalendarForUpcomingEvents)
<commit_msg>changed the datetime string for output of calendarbot<commit_after>#!/usr/bin/python3

# Access to mattermost
from matterhook import Webhook

import datetime
import html2text


from calendarBot.calendarBotSettings import *
from calendarBot.calendarApi import *
from calendarBot.calendarTimer import *

# Initialize Mattermost access
mattermostHook = Webhook(mattermostSettings['URL'], mattermostSettings['ApiKey'])
mattermostHook.username = mattermostSettings['Username']
mattermostHook.icon_url = mattermostSettings['IconURL']

def checkCalendarForUpcomingEvents():
    """
    Checks calendar for upcoming events
    """
    nowDate = datetime.datetime.now()
    laterDate = nowDate + datetime.timedelta(minutes = calendarSettings['TimespanToCheck'])
    successful, res = showAgenda('', nowDate.strftime("%d.%m.%Y %H:%M"), laterDate.strftime("%d.%m.%Y %H:%M"), True)
    if successful:
        for item in res:
            eventContent = 'Upcoming event: {0}\n Details: {1}\n Time: {2} (KIT time)\n Location: {3}\n\n'.format(item.subject, html2text.html2text(item.body),item.start.strftime("%H:%M")), item.location)
            for subcalendar in item.categories:
                try:
                    mattermostHook.send(eventContent, channel=subcalendar)
                except Exception as e:
                    messageContent = eventContent + '\n Error occured: \n {0} \n'.format(e.__doc__)
                    mattermostHook.send(messageContent, channel=mattermostSettings['DefaultChannel'])

timer = RepeatedTimer(calendarSettings['CheckInterval'], checkCalendarForUpcomingEvents)

{'fraction_non_alphanumeric': 0.117664851784634, 'fraction_numerical': 0.006049606775559589, 'mean_word_length': 4.151090342679128, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3295627', 'n_tokens_mistral': 950, 'n_tokens_neox': 903, 'n_words': 202}