Re: [S] Kalender-Programm mit Mail-Benachrichtigung
Hallo,
Wolf Wiegand wrote:
> wolf@denkbrett:~ $ sqlite .mozilla/sunbird/ql0b9oxy.default/storage.sdb
> Unable to open database ".mozilla/sunbird/ql0b9oxy.default/storage.sdb":
> file is encrypted or is not a database
>
> Hmpf. Wäre für Empfehlungen (auch dafür, wie man die storage.sdb lesen
> kann) dankbar.
Es handelt sich um eine sqlite3-DB, deshalb ging das oben nicht. Ich
habe mir jetzt ein kleines Skript gebastelt, das alle sich
wiederholenden Termine und alle einmaligen Termine, die in der Zukunft
liegen, im calendar-Format ausgibt. Ich hab das Skript mal
angehängt, es wird zusätzlich noch python2.4-pysqlite2 (nicht für Stable
vorhanden) benötigt.
Schönen Gruß,
Wolf
--
Büroschimpfwort des Tages: Kurzstrecken-Grübler - sein Vorgang des
Nachdenkens bleibt recht übersichtlich und erfreut die Steno-Sekretärin.
(Richard Hörner)
#!/usr/bin/python2.4
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License.
from pysqlite2 import dbapi2 as sqlite
import time, ConfigParser, os.path, os
def databases():
# add names of other databases as you like
return [default_database()]
def default_database():
sunpath = os.environ["HOME"]+"/.mozilla/sunbird/"
conffile = sunpath + "profiles.ini"
try:
fd = open(conffile, "r")
except:
return ""
parser = ConfigParser.SafeConfigParser()
try:
parser.readfp(fd)
val = parser.get("Profile0", "Path")
fd.close()
sdbpath = sunpath + val + "/storage.sdb"
if os.path.isfile(sdbpath):
return sdbpath
else:
return ""
except:
return ""
def tstamp2date(tstamp):
# returns the given unix time stamp as a string with day/month only
# cut trailing 000000
tstamp=tstamp/1000000
time_tuple = time.gmtime(tstamp)
return "%d %d"%(time_tuple[2], time_tuple[1])
def cal_entry(cur):
# returns the contents of the given tuple suitable for use by calendar
text, date = cur
return "%s\t%s"%(tstamp2date(date), text)
def main():
dbs = databases()
for db in dbs:
if db=="":
continue
con = sqlite.connect(db)
queries=[]
# all repeating entries
queries.append("select title, event_start from cal_events inner join cal_recurrence on cal_events.id=cal_recurrence.item_id;")
# all non-repeating entries starting in the future
cur_sec = long(time.time())*1000000
queries.append("select title, event_start from cal_events where event_start > %d and id not in (select id from cal_events inner join cal_recurrence on cal_events.id=cal_recurrence.item_id);"%cur_sec)
cur = con.cursor()
for query in queries:
cur.execute(query)
output = cur.fetchone()
while output:
print cal_entry(output)
output = cur.fetchone()
main()
Reply to: