aktuelle Scripte rein
This commit is contained in:
parent
f385bd0cbc
commit
77c5d31afc
4 changed files with 183 additions and 717 deletions
|
@ -12,7 +12,7 @@ class DataBase:
|
||||||
user="szene", \
|
user="szene", \
|
||||||
passwd="szene", \
|
passwd="szene", \
|
||||||
use_unicode=1)
|
use_unicode=1)
|
||||||
print "Verbunden"
|
print "Verbindung zur DB steht"
|
||||||
|
|
||||||
def close (self):
|
def close (self):
|
||||||
self.db.close()
|
self.db.close()
|
||||||
|
@ -29,38 +29,38 @@ class DataBase:
|
||||||
print "latest uid for %s is: %i" % (type, j)
|
print "latest uid for %s is: %i" % (type, j)
|
||||||
return j
|
return j
|
||||||
|
|
||||||
def prepare_new_month(self):
|
def prepare_new_month(self, month):
|
||||||
#TODO Monatsvorlage rekursiv kopieren
|
#TODO Monatsvorlage rekursiv kopieren
|
||||||
# IDs der Kategorien aus config
|
# IDs der Kategorien aus config
|
||||||
next_month = "Februar"
|
next_month = str(month)
|
||||||
parentid = 34
|
parentid = str(34)
|
||||||
doktype = 254
|
doktype = str(254)
|
||||||
perms_user = 31
|
perms_user = str(31)
|
||||||
perms_group = 27
|
perms_group = str(27)
|
||||||
hidden = 1
|
hidden = str(1)
|
||||||
tx_rgmenu_special = 5
|
tx_rgmenu_special = str(5)
|
||||||
tstamp = str(int(mktime(datetime.now().timetuple())))
|
tstamp = str(int(mktime(datetime.now().timetuple())))
|
||||||
sqlqueue="INSERT INTO `pages` (`pid`, `title`, `doktype`, `tstamp`, `perms_user`, `perms_group`, `hidden`, `tx_rgmenu_special`) \
|
sqlqueue="INSERT INTO `pages` (`pid`, `title`, `doktype`, `tstamp`, `perms_user`, `perms_group`, `hidden`, `tx_rgmenu_special`) \
|
||||||
VALUES (" \
|
VALUES (" \
|
||||||
+ "'" + parentid + "'" \
|
+ "'" + parentid + "', " \
|
||||||
+ "'" + next_month + "'" \
|
+ "'" + next_month + "', " \
|
||||||
+ "'" + doktype + "'" \
|
+ "'" + doktype + "', " \
|
||||||
+ "'" + tstamp + "'" \
|
+ "'" + tstamp + "', " \
|
||||||
+ "'" + perms_user + "'" \
|
+ "'" + perms_user + "', " \
|
||||||
+ "'" + perms_group + "'" \
|
+ "'" + perms_group + "', " \
|
||||||
+ "'" + hidden + "'" \
|
+ "'" + hidden + "', " \
|
||||||
+ "'" + tx_rgmenu_special + "'" \
|
+ "'" + tx_rgmenu_special \
|
||||||
+ "');"
|
+ "');"
|
||||||
|
print sqlqueue
|
||||||
|
c = self.db.cursor()
|
||||||
c.execute(sqlqueue)
|
c.execute(sqlqueue)
|
||||||
|
|
||||||
def prepare_event(self):
|
def prepare_event(self, event_dic):
|
||||||
'''hiermit wird eine neue Veranstaltung in passender Form
|
'''hiermit wird eine neue Veranstaltung in passender Form
|
||||||
fuer die VCE Extension vorbereitet'''
|
fuer die VCE Extension vorbereitet'''
|
||||||
## Testdatensaetze
|
|
||||||
event_pid = "29"
|
event_pid = "29"
|
||||||
event_title = "Test2888888"
|
event_title = event_dic["WAS_XML"]
|
||||||
event_title2= "Test2345345"
|
event_description = event_dic["INFORMATION"]
|
||||||
event_description = "blablabla"
|
|
||||||
event_startdate = str(int(mktime((datetime(2008,01,31,11,11,00)).timetuple())))
|
event_startdate = str(int(mktime((datetime(2008,01,31,11,11,00)).timetuple())))
|
||||||
event_targetgroup = "5"
|
event_targetgroup = "5"
|
||||||
event_category = "1"
|
event_category = "1"
|
||||||
|
@ -68,23 +68,24 @@ class DataBase:
|
||||||
event_location = "1"
|
event_location = "1"
|
||||||
event_tstamp = str(int(mktime(datetime.now().timetuple())))
|
event_tstamp = str(int(mktime(datetime.now().timetuple())))
|
||||||
event_crdate = str(int(mktime(datetime.now().timetuple())))
|
event_crdate = str(int(mktime(datetime.now().timetuple())))
|
||||||
# felder ohne default wert mit leerem string besetzen
|
## felder ohne default wert mit leerem string besetzen
|
||||||
event_image = ""
|
event_image = ""
|
||||||
event_link = ""
|
event_link = ""
|
||||||
event_exeptions = ""
|
event_exeptions = ""
|
||||||
event_l18n_diffsource = ""
|
event_l18n_diffsource = ""
|
||||||
# liste fuer alle datensaetze zusammenstellen
|
|
||||||
#TODO aus xml holen
|
|
||||||
event1 = (event_pid, event_title, event_description, event_startdate, event_targetgroup, event_category, event_organizer, event_location, event_tstamp, event_crdate, event_image, event_link, event_exeptions, event_l18n_diffsource)
|
event1 = (event_pid, event_title, event_description, event_startdate, event_targetgroup, event_category, event_organizer, event_location, event_tstamp, event_crdate, event_image, event_link, event_exeptions, event_l18n_diffsource)
|
||||||
event2 = (event_pid, event_title2, event_description, event_startdate, event_targetgroup, event_category, event_organizer, event_location, event_tstamp, event_crdate, event_image, event_link, event_exeptions, event_l18n_diffsource)
|
#event2 = (event_pid, event_title2, event_description, event_startdate, event_targetgroup, event_category, event_organizer, event_location, event_tstamp, event_crdate, event_image, event_link, event_exeptions, event_l18n_diffsource)
|
||||||
event_data = [ event1, event2 ]
|
## liste fuer alle datensaetze zusammenstellen
|
||||||
return event_data
|
#event_data = [ event1, event2 ]
|
||||||
|
#return event_data
|
||||||
|
print event1
|
||||||
|
return event1
|
||||||
|
|
||||||
def insert_event(self):
|
def insert_event(self, dataset):
|
||||||
'''den MySQL Befehl absetzen'''
|
'''den MySQL Befehl absetzen'''
|
||||||
#sqlqueue="INSERT INTO `tx_skcalendar_event` (`pid`) VALUES ('29');"
|
#sqlqueue="INSERT INTO `tx_skcalendar_event` (`pid`) VALUES ('29');"
|
||||||
#c.execute(sqlqueue)
|
#c.execute(sqlqueue)
|
||||||
"""
|
'''
|
||||||
sqlqueue="INSERT INTO `tx_skcalendar_event` (`pid` , `title`, `description`, `targetgroup`, `category`, `organizer`, `location`, `tstamp` , `crdate` ) VALUES (" \
|
sqlqueue="INSERT INTO `tx_skcalendar_event` (`pid` , `title`, `description`, `targetgroup`, `category`, `organizer`, `location`, `tstamp` , `crdate` ) VALUES (" \
|
||||||
+ "'" + self.event_pid + "', "\
|
+ "'" + self.event_pid + "', "\
|
||||||
+ "'" + self.event_title + "', "\
|
+ "'" + self.event_title + "', "\
|
||||||
|
@ -96,19 +97,26 @@ class DataBase:
|
||||||
+ "'" + self.event_tstamp + "', "\
|
+ "'" + self.event_tstamp + "', "\
|
||||||
+ "'" + self.event_crdate \
|
+ "'" + self.event_crdate \
|
||||||
+ "');"
|
+ "');"
|
||||||
"""
|
|
||||||
c = self.db.cursor()
|
|
||||||
data = self.prepare_event()
|
|
||||||
print "folgende Datensaetze einfuegen:"
|
print "folgende Datensaetze einfuegen:"
|
||||||
for i in data:
|
for i in dataset:
|
||||||
print i
|
print i
|
||||||
c.executemany("""INSERT INTO `tx_skcalendar_event` (`pid` , `title`, `description`, `startdate`, `targetgroup`, `category`, `organizer`, `location`, `tstamp` , `crdate`, `image`, `link`, `exeptions`, `l18n_diffsource`) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)""", data)
|
#c.executemany("""INSERT INTO `tx_skcalendar_event` (`pid` , `title`, `description`, `startdate`, `targetgroup`, `category`, `organizer`, `location`, `tstamp` , `crdate`, `image`, `link`, `exeptions`, `l18n_diffsource`) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)""", data)
|
||||||
|
'''
|
||||||
|
#data = self.prepare_event()
|
||||||
|
c = self.db.cursor()
|
||||||
|
c.executemany("""INSERT INTO `tx_skcalendar_event` (`pid` , `title`, `description`, `startdate`, `targetgroup`, `category`, `organizer`, `location`, `tstamp` , `crdate`, `image`, `link`, `exeptions`, `l18n_diffsource`) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)""", dataset)
|
||||||
|
|
||||||
|
def insert_organizer(self):
|
||||||
|
#get_organizers_from_config()
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
test = DataBase()
|
test = DataBase()
|
||||||
test.connect()
|
test.connect()
|
||||||
#test.get_latest_uid_category("organizer")
|
#test.get_latest_uid_category("organizer")
|
||||||
test.insert_event()
|
datasource = XMLSource()
|
||||||
|
#test.insert_event()
|
||||||
test.close()
|
test.close()
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,6 +1,8 @@
|
||||||
[Kategorien]
|
[Monat]
|
||||||
## IDs der Kategorienvorlage
|
pid = 89
|
||||||
Monatsvorlage = 58
|
|
||||||
|
[Kategorie]
|
||||||
|
pid = 58
|
||||||
Live = 67
|
Live = 67
|
||||||
Sonstiges = 66
|
Sonstiges = 66
|
||||||
Lesungen = 65
|
Lesungen = 65
|
||||||
|
@ -10,3 +12,11 @@ Familie = 61
|
||||||
Party = 60
|
Party = 60
|
||||||
Kino = 59
|
Kino = 59
|
||||||
|
|
||||||
|
[Veranstalter]
|
||||||
|
pid = 1
|
||||||
|
|
||||||
|
[Ort]
|
||||||
|
pid = 1
|
||||||
|
|
||||||
|
[Zielgruppe]
|
||||||
|
pid = 1
|
||||||
|
|
|
@ -2,7 +2,67 @@
|
||||||
"""
|
"""
|
||||||
this script fetches single nodes from a eventmanagement xml file
|
this script fetches single nodes from a eventmanagement xml file
|
||||||
"""
|
"""
|
||||||
|
from optparse import OptionParser
|
||||||
from xml.dom.minidom import parse
|
from xml.dom.minidom import parse
|
||||||
|
import mysql_connect
|
||||||
|
|
||||||
|
def main():
|
||||||
|
usage = "usage: %prog [options] arg"
|
||||||
|
parser = OptionParser(usage)
|
||||||
|
parser.add_option("-f", "--file", dest="filename",
|
||||||
|
help="read xml data from FILENAME")
|
||||||
|
parser.add_option("-c", "--config", dest="configfile",
|
||||||
|
help="read DB config from FILENAME")
|
||||||
|
(options, args) = parser.parse_args()
|
||||||
|
if options.filename:
|
||||||
|
print "reading XML file: %s " % options.filename
|
||||||
|
else:
|
||||||
|
print parser.print_help()
|
||||||
|
return
|
||||||
|
dic = readXML(options.filename)
|
||||||
|
|
||||||
|
xmltags = ["INFORMATION", "WANN_START_XML", "WANN_ENDE", "WO_XML", "WAS_XML", "RUBRIK_XML", "SONSTIGES"]
|
||||||
|
print
|
||||||
|
print "XML Quelle: ", dic["FMPDSORESULT"]["DATABASE"]
|
||||||
|
#print "Data 0", dic["FMPDSORESULT"]["ROW"][0]
|
||||||
|
#print "Data 1", dic["FMPDSORESULT"]["ROW"][1]
|
||||||
|
entry = 0
|
||||||
|
days = 0
|
||||||
|
data = []
|
||||||
|
test = mysql_connect.DataBase()
|
||||||
|
|
||||||
|
for item in dic["FMPDSORESULT"]["ROW"]:
|
||||||
|
entry += 1
|
||||||
|
if len(item["DATUM"]) > 1:
|
||||||
|
days +=1
|
||||||
|
text = "\tDatum: %s" % item["DATUM"]
|
||||||
|
#filename = "/tmp/szene"+str(days)
|
||||||
|
#f = open(filename,mode="a")
|
||||||
|
#f.write(text)
|
||||||
|
#print text
|
||||||
|
data.append(test.prepare_event(item))
|
||||||
|
'''
|
||||||
|
for content in xmltags:
|
||||||
|
text = ("%s: %s") % (content, item[content])
|
||||||
|
#f.write(text)
|
||||||
|
print text
|
||||||
|
'''
|
||||||
|
|
||||||
|
#f.close()
|
||||||
|
|
||||||
|
print "Tage durchlaufen: %i" % days
|
||||||
|
entries = len(dic["FMPDSORESULT"]["ROW"])
|
||||||
|
print "Eintraege insgesamt: %i" % entries
|
||||||
|
if entries != entry:
|
||||||
|
print "Es gibt %i Eintraege in der xml Datei aber nur %i wurden durchlaufen" % (entries, entry)
|
||||||
|
|
||||||
|
## finally put the mess into mysql db
|
||||||
|
test.connect()
|
||||||
|
print "Datenbank fuellen.."
|
||||||
|
#test.prepare_new_month("Mai")
|
||||||
|
#test.insert_event(data)
|
||||||
|
test.close()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class NotTextNodeError:
|
class NotTextNodeError:
|
||||||
|
@ -74,28 +134,12 @@ def nodeToDic(node):
|
||||||
return dic
|
return dic
|
||||||
|
|
||||||
|
|
||||||
def readConfig(filename):
|
def readXML(filename):
|
||||||
dom = parse(filename)
|
dom = parse(filename)
|
||||||
return nodeToDic(dom)
|
return nodeToDic(dom)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
dic = readConfig("source.xml")
|
main()
|
||||||
xmltags = ["INFORMATION", "WANN_START_XML", "WANN_ENDE", "WO_XML", "WAS_XML", "RUBRIK_XML", "SONSTIGES"]
|
|
||||||
print
|
|
||||||
print "Database", dic["FMPDSORESULT"]["DATABASE"]
|
|
||||||
#for item in dic["Config"]["Items"]["Item"]:
|
|
||||||
entry = 0
|
|
||||||
days = 0
|
|
||||||
for item in dic["FMPDSORESULT"]["ROW"]:
|
|
||||||
entry += 1
|
|
||||||
print entry
|
|
||||||
if len(item["DATUM"]) > 1:
|
|
||||||
days +=1
|
|
||||||
print "Datum: %s" % item["DATUM"]
|
|
||||||
for content in xmltags:
|
|
||||||
print ("%s: %s") % (content, item[content])
|
|
||||||
print
|
|
||||||
|
|
||||||
print "Tage: %s" % days
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue