Moved from database to caldav library
This commit is contained in:
parent
1392e94f62
commit
799c458107
|
@ -16,5 +16,6 @@
|
||||||
|
|
||||||
# Calendar related variables
|
# Calendar related variables
|
||||||
[caldav]
|
[caldav]
|
||||||
|
cal_url =
|
||||||
cal_name =
|
cal_name =
|
||||||
local_tz =
|
local_tz =
|
24
getInfo.py
24
getInfo.py
|
@ -1,11 +1,12 @@
|
||||||
#!/usr/bin/python3
|
#!/usr/bin/env python3
|
||||||
import mysql.connector as sql
|
|
||||||
import datetime as dt
|
import datetime as dt
|
||||||
import dateutil.relativedelta as rd
|
import dateutil.relativedelta as rd
|
||||||
import sys
|
import sys
|
||||||
import re
|
import re
|
||||||
import glob
|
import glob
|
||||||
import pytz
|
import pytz
|
||||||
|
import caldav
|
||||||
|
|
||||||
# Parameter: a TEXT string
|
# Parameter: a TEXT string
|
||||||
# Returns: the escaped string, according to RFC 5545 §3.3.11
|
# Returns: the escaped string, according to RFC 5545 §3.3.11
|
||||||
|
@ -53,21 +54,22 @@ def getEvents(baseDay, interval):
|
||||||
leftLimit = local_tz.localize(leftLimit)
|
leftLimit = local_tz.localize(leftLimit)
|
||||||
rightLimit = local_tz.localize(rightLimit)
|
rightLimit = local_tz.localize(rightLimit)
|
||||||
|
|
||||||
c = sql.connect(unix_socket=glob.cfg['mysql']['unix_socket'], host=glob.cfg['mysql']['host'], user=glob.cfg['mysql']['user'], password=glob.cfg['mysql']['password'], db=glob.cfg['mysql']['db'])
|
url = glob.cfg['caldav']['cal_url']
|
||||||
mycursor = c.cursor()
|
|
||||||
# For repeated events
|
client = caldav.DAVClient(url=url)
|
||||||
query = "SELECT obj.calendardata FROM oc_calendarobjects AS obj INNER JOIN oc_calendars AS cal ON obj.calendarid = cal.id WHERE cal.displayname='%s' AND obj.firstoccurence < %s AND obj.lastoccurence > %s" % (glob.cfg['caldav']['cal_name'], rightLimit.strftime('%s'), leftLimit.strftime('%s'))
|
calendar = caldav.Calendar(client=client, url=url)
|
||||||
mycursor.execute(query)
|
|
||||||
result = mycursor.fetchall()
|
result = calendar.date_search(
|
||||||
c.close()
|
start=leftLimit,
|
||||||
|
end=rightLimit)
|
||||||
|
|
||||||
events = []
|
events = []
|
||||||
|
|
||||||
for event in result:
|
for event in result:
|
||||||
repetition = {'single' : True, 'freq' : {'DAILY': 0, 'WEEKLY' : 0, 'MONTHLY' : 0, 'YEARLY': 0}, 'interval' : 1, 'count': 0, 'until' : None}
|
repetition = {'single' : True, 'freq' : {'DAILY': 0, 'WEEKLY' : 0, 'MONTHLY' : 0, 'YEARLY': 0}, 'interval' : 1, 'count': 0, 'until' : None}
|
||||||
|
|
||||||
# selected only first column
|
# fetch ascii data
|
||||||
event = event[0].decode('utf8')
|
event = event.data
|
||||||
# Current BEGIN:xxx block name
|
# Current BEGIN:xxx block name
|
||||||
blockParsing = None
|
blockParsing = None
|
||||||
# Current property name (for long content line unfolding, RFC §3.1)
|
# Current property name (for long content line unfolding, RFC §3.1)
|
||||||
|
|
Loading…
Reference in New Issue