mirror of
https://github.com/adulau/aha.git
synced 2024-12-27 03:06:10 +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
|
||||
import os,sys
|
||||
from pyinotify import *
|
||||
from ctypes import *
|
||||
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):
|
||||
def silent_clean(self,filename):
|
||||
|
@ -13,6 +19,14 @@ class KernelEvents(ProcessEvent):
|
|||
except OSError,e:
|
||||
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):
|
||||
msg = {}
|
||||
fp = open(filename,'r')
|
||||
|
@ -32,6 +46,9 @@ class KernelEvents(ProcessEvent):
|
|||
filename = os.path.join(event.path,event.name)
|
||||
msg = self.load_file(filename)
|
||||
print msg
|
||||
#Send back a message
|
||||
self.create_message(event.name, block=23, insult=98,
|
||||
exitcode=1, substitue=55)
|
||||
#Cleanup the file
|
||||
self.silent_clean(filename)
|
||||
|
||||
|
|
Loading…
Reference in a new issue