do not fail in windoz part 2
This commit is contained in:
parent
d8b732ad2a
commit
5989b495d1
|
@ -4,12 +4,15 @@ import sre
|
||||||
|
|
||||||
from pysqlite2 import dbapi2 as sqlite
|
from pysqlite2 import dbapi2 as sqlite
|
||||||
|
|
||||||
PATH_TO_LOGS_BASE_DIR = os.path.expanduser('~/.gajim/logs')
|
if os.name == 'nt':
|
||||||
|
PATH_TO_LOGS_BASE_DIR = os.environ['appdata'] + '/Gajim/Logs'
|
||||||
|
PATH_TO_DB = os.path.expanduser('~/.gajim/logs.db') # database is called logs.db
|
||||||
|
else:
|
||||||
|
PATH_TO_LOGS_BASE_DIR = os.path.expanduser('~/.gajim/logs')
|
||||||
|
PATH_TO_DB = os.path.expanduser('~/.gajim/logs.db') # database is called logs.db
|
||||||
|
|
||||||
# jid we already put in DB
|
jids_already_in = [] # jid we already put in DB
|
||||||
jid_in = []
|
con = sqlite.connect(PATH_TO_DB)
|
||||||
path_to_db = os.path.expanduser('~/.gajim/logs.db') # database is called logs.db
|
|
||||||
con = sqlite.connect(path_to_db)
|
|
||||||
cur = con.cursor()
|
cur = con.cursor()
|
||||||
# create the tables
|
# create the tables
|
||||||
# type can be 'gc', 'gcstatus', 'recv', 'sent', 'status'
|
# type can be 'gc', 'gcstatus', 'recv', 'sent', 'status'
|
||||||
|
@ -83,10 +86,10 @@ def visit(arg, dirname, filenames):
|
||||||
jid = get_jid(dirname, filename)
|
jid = get_jid(dirname, filename)
|
||||||
print 'Processing', jid
|
print 'Processing', jid
|
||||||
# jid is already in the DB, don't create the table, just get his jid_id
|
# jid is already in the DB, don't create the table, just get his jid_id
|
||||||
if jid in jid_in:
|
if jid in jids_already_in:
|
||||||
cur.execute('SELECT jid_id FROM jids WHERE jid="%s"' % jid)
|
cur.execute('SELECT jid_id FROM jids WHERE jid="%s"' % jid)
|
||||||
else:
|
else:
|
||||||
jid_in.append(jid)
|
jids_already_in.append(jid)
|
||||||
cur.execute('INSERT INTO jids (jid) VALUES (?)', (jid,))
|
cur.execute('INSERT INTO jids (jid) VALUES (?)', (jid,))
|
||||||
con.commit()
|
con.commit()
|
||||||
|
|
||||||
|
@ -146,7 +149,7 @@ if __name__ == '__main__':
|
||||||
# after huge import create the indices (they are slow on massive insert)
|
# after huge import create the indices (they are slow on massive insert)
|
||||||
cur.executescript(
|
cur.executescript(
|
||||||
'''
|
'''
|
||||||
CREATE UNIQUE INDEX JID_Index ON jids (jid);
|
CREATE UNIQUE INDEX jids_already_index ON jids (jid);
|
||||||
CREATE INDEX JID_ID_Index ON logs (jid_id);
|
CREATE INDEX JID_ID_Index ON logs (jid_id);
|
||||||
'''
|
'''
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue