mirror of
https://github.com/adulau/aha.git
synced 2024-12-28 11:46:19 +00:00
Decision engine creates messages
This commit is contained in:
parent
4d468f9ad9
commit
582318e4cb
1 changed files with 17 additions and 0 deletions
17
aha/aha.py
17
aha/aha.py
|
@ -4,7 +4,13 @@
|
||||||
#License GPL
|
#License GPL
|
||||||
import os,sys
|
import os,sys
|
||||||
from pyinotify import *
|
from pyinotify import *
|
||||||
|
from ctypes import *
|
||||||
KERNEL_OUT="/home/gerard/kernel/linux-2.6/out"
|
KERNEL_OUT="/home/gerard/kernel/linux-2.6/out"
|
||||||
|
KERNEL_IN="/home/gerard/kernel/linux-2.6/in"
|
||||||
|
|
||||||
|
class ReplyMessage(Structure):
|
||||||
|
__fields_ = [ ("block" , c_int), ("exitcode" , c_int), ("substitue" ,c_int),
|
||||||
|
("insult" , c_int) ]
|
||||||
|
|
||||||
class KernelEvents(ProcessEvent):
|
class KernelEvents(ProcessEvent):
|
||||||
def silent_clean(self,filename):
|
def silent_clean(self,filename):
|
||||||
|
@ -13,6 +19,14 @@ class KernelEvents(ProcessEvent):
|
||||||
except OSError,e:
|
except OSError,e:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def create_message(self,filename,block,exitcode,substitue,insult):
|
||||||
|
reply = ReplyMessage(block=block,exitcode=exitcode,substitue=substitue,
|
||||||
|
insult = insult)
|
||||||
|
fn = KERNEL_IN + os.sep + filename
|
||||||
|
f = open (fn,'wb')
|
||||||
|
f.write(reply)
|
||||||
|
f.close()
|
||||||
|
|
||||||
def load_file(self,filename):
|
def load_file(self,filename):
|
||||||
msg = {}
|
msg = {}
|
||||||
fp = open(filename,'r')
|
fp = open(filename,'r')
|
||||||
|
@ -32,6 +46,9 @@ class KernelEvents(ProcessEvent):
|
||||||
filename = os.path.join(event.path,event.name)
|
filename = os.path.join(event.path,event.name)
|
||||||
msg = self.load_file(filename)
|
msg = self.load_file(filename)
|
||||||
print msg
|
print msg
|
||||||
|
#Send back a message
|
||||||
|
self.create_message(event.name, block=23, insult=98,
|
||||||
|
exitcode=1, substitue=55)
|
||||||
#Cleanup the file
|
#Cleanup the file
|
||||||
self.silent_clean(filename)
|
self.silent_clean(filename)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue