Added INI conf file
This commit is contained in:
parent
c18c9165cd
commit
d9cf74b749
|
@ -1,2 +1,6 @@
|
|||
config.py
|
||||
__pycache__/
|
||||
conf/*custom.ini
|
||||
.directory
|
||||
*.swp
|
||||
*~
|
||||
*.pyc
|
|
@ -0,0 +1,19 @@
|
|||
# zerocalcare - Zero Optimized Caldav Calendar Reader Engine
|
||||
# Main configuration file
|
||||
#
|
||||
# Do not edit this file directly if you want to keep your git repository clean.
|
||||
# Copy/Rename it as `conf.custom.ini` and edit it.
|
||||
# It will override this file's values, and it will not be tracked.
|
||||
################################################################################
|
||||
|
||||
# Database and tables settings
|
||||
[mysql]
|
||||
unix_socket =
|
||||
host =
|
||||
user =
|
||||
password =
|
||||
db =
|
||||
|
||||
# Calendar related variables
|
||||
[caldav]
|
||||
cal_name =
|
|
@ -1,8 +0,0 @@
|
|||
UNIX_SOCKET=''
|
||||
HOST=''
|
||||
USER=''
|
||||
PASSWORD=''
|
||||
DB=''
|
||||
CALENDAR_NAME=''
|
||||
|
||||
|
|
@ -3,7 +3,7 @@ import mysql.connector as sql
|
|||
import datetime as dt
|
||||
import sys
|
||||
import re
|
||||
from config import *
|
||||
import glob
|
||||
|
||||
def parseOptions(arr):
|
||||
if len(arr) == 1:
|
||||
|
@ -27,11 +27,11 @@ def getEvents(baseDay, interval):
|
|||
raise ValueError('Invalid argument passed to getEvents')
|
||||
leftLimit = baseDay.strftime('%s')
|
||||
|
||||
c = sql.connect(unix_socket=UNIX_SOCKET, host=HOST, user=USER, password=PASSWORD, db=DB)
|
||||
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'])
|
||||
mycursor = c.cursor()
|
||||
# For repeated events (not yet supported)
|
||||
#sql = "SELECT obj.calendardata FROM oc_calendarobjects AS obj INNER JOIN oc_calendars AS cal ON obj.calendarid = cal.id WHERE cal.displayname='prova'AND obj.firstoccurence < %s AND obj.lastoccurence > %s" % (leftLimit, rightLimit)
|
||||
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.firstoccurence > %s" % (CALENDAR_NAME, rightLimit, leftLimit)
|
||||
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.firstoccurence > %s" % (glob.cfg['caldav']['cal_name'], rightLimit, leftLimit)
|
||||
mycursor.execute(query)
|
||||
result = mycursor.fetchall()
|
||||
c.close()
|
||||
|
|
Loading…
Reference in New Issue