Coder Social home page Coder Social logo

science-computing / wartungsplan Goto Github PK

View Code? Open in Web Editor NEW
5.0 2.0 3.0 89 KB

A tool to extract events from an ical file by day or day range and perform an action per event like sending an email or opening a ticket

License: GNU General Public License v3.0

Python 95.65% Dockerfile 0.38% Shell 3.97%
administration infrastructure it otrs tasks ticketing-system eviden

wartungsplan's People

Contributors

dependabot[bot] avatar jack28 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

wartungsplan's Issues

Download calendar from Microsoft Exchange

Can somebody with access to a Microsoft Exchange-Server (normal user access should be sufficient) try the following scripts (suggested by ChatGPT) to download a Wartungsplan calendar:

from exchangelib import Credentials, Account, EWSDateTime
from icalendar import Calendar, Event

# Set up credentials (replace with your own credentials)
credentials = Credentials('[email protected]', 'your_password')

# Connect to the Exchange server
account = Account('[email protected]', credentials=credentials, autodiscover=True)

# Define the start and end datetime for which you want to fetch events
start_date = EWSDateTime(2024, 1, 1)
end_date = EWSDateTime(2024, 1, 31)

# Fetch calendar items between start_date and end_date
calendar_items = account.calendar.view(start=start_date, end=end_date)

# Create a new iCalendar object
ical = Calendar()

# Iterate through each calendar item and add it to the iCalendar object
for item in calendar_items:
    event = Event()
    event.add('summary', item.subject)
    event.add('dtstart', item.start)
    event.add('dtend', item.end)
    event.add('description', item.body)
    
    # Add more properties as needed, such as location, attendees, etc.
    
    ical.add_component(event)

# Save the iCalendar object to a file
with open('calendar_events.ics', 'wb') as f:
    f.write(ical.to_ical())

print("Calendar events have been exported to 'calendar_events.ics'")

somewhat different:

from exchangelib import Credentials, Account, EWSDateTime
from icalendar import Calendar, Event
from icalendar import vRecur, vText

def convert_to_ical_recur_pattern(exchange_item):
    """Converts Exchange recurring pattern to iCalendar recurrence rules."""
    recurrence = exchange_item.recurrence
    rule = vRecur()

    if recurrence.number:
        rule['COUNT'] = recurrence.number

    if recurrence.start:
        rule['DTSTART'] = recurrence.start

    if recurrence.interval:
        rule['INTERVAL'] = recurrence.interval

    if recurrence.first_day_of_week:
        rule['WKST'] = vText(recurrence.first_day_of_week)

    # Handle more recurrence pattern details as needed

    return rule

# Set up credentials (replace with your own credentials)
credentials = Credentials('[email protected]', 'your_password')

# Connect to the Exchange server
account = Account('[email protected]', credentials=credentials, autodiscover=True)

# Define the start and end datetime for which you want to fetch events
start_date = EWSDateTime(2024, 1, 1)
end_date = EWSDateTime(2024, 1, 31)

# Fetch calendar items between start_date and end_date
calendar_items = account.calendar.view(start=start_date, end=end_date)

# Create a new iCalendar object
ical = Calendar()

# Iterate through each calendar item and add it to the iCalendar object
for item in calendar_items:
    event = Event()
    event.add('summary', item.subject)
    event.add('dtstart', item.start)
    event.add('dtend', item.end)
    event.add('description', item.body)
    
    # Check if it's a recurring event and convert recurrence pattern
    if item.recurrence:
        recurrence_rule = convert_to_ical_recur_pattern(item)
        event.add('rrule', recurrence_rule)
    
    ical.add_component(event)

# Save the iCalendar object to a file
with open('calendar_events.ics', 'wb') as f:
    f.write(ical.to_ical())

print("Calendar events have been exported to 'calendar_events.ics'")

Empty event in calendar

  • A couple of days ago an empty event appeared in one of our calendars
  • The origin is unknown
  • It triggers the back-end action

The event doesn't get listed / shown in Thunderbird Lightning but exists in the file:

BEGIN:VEVENT
DTSTAMP:20230904T165012Z
CLASS:PUBLIC
CREATED:20230904T165012Z
DTEND;TZID=Europe/Berlin:20230908T120000
DTSTART;TZID=Europe/Berlin:20230908T080000
LAST-MODIFIED:20230904T165012Z
SEQUENCE:0
TRANSP:OPAQUE
UID:f628faef-2c5f-4d36-9c5d-b9ba92c59dd8
X-MICROSOFT-CDO-BUSYSTATUS:BUSY
END:VEVENT

It doesn't have SUMMARY nor DESCRIPTION field.

Maybe it is an event thats creation was aborted.
It could also be a task.

That's all we know for know

Add Changelog

Once there is a release 1.0 don't forget to begin a changelog

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.