GUI database filename is now read from the configuration file

This commit is contained in:
Gerard Wagener 2010-10-12 09:25:28 +02:00
parent b863cb2717
commit c3a37be48c
3 changed files with 14 additions and 14 deletions

View file

@ -17,6 +17,5 @@ inqueue=/home/gerard/dev/linux-2.6/in
[insults] [insults]
maxidx = 3 maxidx = 3
[game] [gui]
cases=0.54 database=gui.db
block=0.1

View file

@ -7,19 +7,21 @@ from pyinotify import *
from ctypes import * from ctypes import *
from ahalib import * from ahalib import *
import sys import sys
import os
import sqlite3,os.path import sqlite3,os.path
database = '../gui.db'
class KernelEvents(ProcessEvent): class KernelEvents(ProcessEvent):
def __init__(self,inqueue,outqueue,insultmaxidx,cases,block): def __init__(self,inqueue,outqueue,insultmaxidx, guidb):
self.ahaa = AHAActions(inqueue,outqueue) self.ahaa = AHAActions(inqueue,outqueue)
self.database = guidb
self.processtrees = ProcessTrees() self.processtrees = ProcessTrees()
if os.path.exists(database): if os.path.exists(self.database):
self.con = sqlite3.connect(database) self.con = sqlite3.connect(self.database)
#Do it here to win time #Do it here to win time
self.cur = self.con.cursor() self.cur = self.con.cursor()
else: else:
print "[ERROR] Database file not found ",database os.system('pwd')
print "[ERROR] Database file not found ",self.database
sys.exit(1) sys.exit(1)
def askgui(self, filekey,msg): def askgui(self, filekey,msg):
@ -149,15 +151,14 @@ if __name__ == '__main__':
inqueue = c.get('common','inqueue') inqueue = c.get('common','inqueue')
outqueue = c.get('common','outqueue') outqueue = c.get('common','outqueue')
insultmaxidx = int(c.get('insults','maxidx')) insultmaxidx = int(c.get('insults','maxidx'))
cases = float(c.get('game','cases')) guidb = c.get('gui','database')
blockpr = float(c.get('game','block'))
print "Setting up listeners..." print "Setting up listeners..."
wm = WatchManager() wm = WatchManager()
mask = IN_CLOSE_WRITE # watched events mask = IN_CLOSE_WRITE # watched events
notifier = Notifier(wm, KernelEvents(inqueue,outqueue,insultmaxidx, k = KernelEvents(inqueue, outqueue,insultmaxidx,guidb)
cases,blockpr)) #If database is not valid exit here
notifier = Notifier(wm,k)
wdd = wm.add_watch(outqueue, mask, rec=True) wdd = wm.add_watch(outqueue, mask, rec=True)
print "Waiting for events..." print "Waiting for events..."

View file

@ -219,7 +219,7 @@ class ProcessTrees:
self.processList.pop(pid) self.processList.pop(pid)
if self.userList.has_key(pid): if self.userList.has_key(pid):
self.userList.pop(pid) self.userList.pop(pid)
print "User in process ",pid," pid disconnected" #print "User in process ",pid," pid disconnected"
except KeyError,e: except KeyError,e:
pass pass