|
|
@ -32,6 +32,8 @@ class Actor(Thread):
|
|
|
|
def execute(self,cmd):
|
|
|
|
def execute(self,cmd):
|
|
|
|
stream = None
|
|
|
|
stream = None
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
|
|
|
|
print self.getIdentifier()
|
|
|
|
|
|
|
|
print cmd
|
|
|
|
handler = subprocess.Popen(cmd,shell=True,stdout=subprocess.PIPE)
|
|
|
|
handler = subprocess.Popen(cmd,shell=True,stdout=subprocess.PIPE)
|
|
|
|
stream = handler.communicate()[0]
|
|
|
|
stream = handler.communicate()[0]
|
|
|
|
except Exception,e:
|
|
|
|
except Exception,e:
|
|
|
@ -42,7 +44,15 @@ class Actor(Thread):
|
|
|
|
message = json.loads(stream)
|
|
|
|
message = json.loads(stream)
|
|
|
|
content = message['content']
|
|
|
|
content = message['content']
|
|
|
|
sender = message['from']
|
|
|
|
sender = message['from']
|
|
|
|
|
|
|
|
if content.lower() == 'quit' :
|
|
|
|
|
|
|
|
channel.close()
|
|
|
|
|
|
|
|
print " *** ",self.getIdentifier()
|
|
|
|
|
|
|
|
elif content.lower() == 'ping':
|
|
|
|
|
|
|
|
self.post(to=sender,content="1")
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
self.process(content)
|
|
|
|
self.post(to=sender,content=content)
|
|
|
|
self.post(to=sender,content=content)
|
|
|
|
|
|
|
|
|
|
|
|
#message = None
|
|
|
|
#message = None
|
|
|
|
#try:
|
|
|
|
#try:
|
|
|
|
#message = json.loads(stream)
|
|
|
|
#message = json.loads(stream)
|
|
|
@ -62,10 +72,10 @@ class Actor(Thread):
|
|
|
|
host = self.config['api']
|
|
|
|
host = self.config['api']
|
|
|
|
uid = self.config['key']
|
|
|
|
uid = self.config['key']
|
|
|
|
qid = to#self.config['id']
|
|
|
|
qid = to#self.config['id']
|
|
|
|
print [host,uid,qid]
|
|
|
|
|
|
|
|
qwriter = QueueWriter(host=host,uid=uid,qid=qid)
|
|
|
|
qwriter = QueueWriter(host=host,uid=uid,qid=qid)
|
|
|
|
qwriter.init(qid)
|
|
|
|
qwriter.init(qid)
|
|
|
|
qwriter.write(label=qid,row="got it")
|
|
|
|
qwriter.write(label=qid,row=content)
|
|
|
|
#qwriter.close()
|
|
|
|
#qwriter.close()
|
|
|
|
pass
|
|
|
|
pass
|
|
|
|
def run(self):
|
|
|
|
def run(self):
|
|
|
@ -96,9 +106,15 @@ class Start(Actor):
|
|
|
|
cmd = " ".join([path,args])
|
|
|
|
cmd = " ".join([path,args])
|
|
|
|
self.execute(cmd)
|
|
|
|
self.execute(cmd)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
This class is designed to send a message to a given AMQP enpoint
|
|
|
|
|
|
|
|
The AMQP endpoint is implemented by QueueWriter class
|
|
|
|
|
|
|
|
"""
|
|
|
|
class Alert(Actor):
|
|
|
|
class Alert(Actor):
|
|
|
|
|
|
|
|
def process(self,item):
|
|
|
|
pass
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
config = {"id":"demo","key":"[0v8]-247&7!v3","api":"localhost"}
|
|
|
|
config = {"id":"demo","key":"[0v8]-247&7!v3","api":"localhost"}
|
|
|
|
actor = Kill(config)
|
|
|
|
actor = Kill(config)
|
|
|
|
actor.start()
|
|
|
|
actor.start()
|
|
|
|