mirror of
https://github.com/Pardus-LiderAhenk/ahenk
synced 2024-11-10 11:12:16 +03:00
execution commands handlers
This commit is contained in:
parent
74ffa7d20e
commit
3005bc4b3f
2 changed files with 45 additions and 0 deletions
45
opt/ahenk/base/execution/ExecutionManager.py
Normal file
45
opt/ahenk/base/execution/ExecutionManager.py
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Author: Volkan Şahin <volkansah.in> <bm.volkansahin@gmail.com>
|
||||||
|
import sys
|
||||||
|
import logging
|
||||||
|
import logging.config
|
||||||
|
from base.Scope import Scope
|
||||||
|
|
||||||
|
class ExecutionManager(object):
|
||||||
|
"""docstring for FileTransferManager"""
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
super(ExecutionManager, self).__init__()
|
||||||
|
|
||||||
|
scope = Scope.getInstance()
|
||||||
|
self.config_manager = scope.getConfigurationManager()
|
||||||
|
self.event_manager = scope.getEventManager()
|
||||||
|
|
||||||
|
self.event_manager.register_event('EXECUTE_TASK',self.execute_task)
|
||||||
|
self.event_manager.register_event('EXECUTE_SCRIPT',self.execute_script)
|
||||||
|
self.event_manager.register_event('SEND_FILE',self.send_file)
|
||||||
|
|
||||||
|
def execute_task(self,arg):
|
||||||
|
print("execute_task")
|
||||||
|
|
||||||
|
def execute_script(self,arg):
|
||||||
|
print("execute_script")
|
||||||
|
j = json.loads(arg)
|
||||||
|
msg_id =str(j['id']).lower()
|
||||||
|
file_path =str(j['filePath']).lower()
|
||||||
|
time_stamp=str(j['timestamp']).lower()
|
||||||
|
|
||||||
|
os.system('./command.sh') #TODO
|
||||||
|
|
||||||
|
|
||||||
|
#need to move somewhere else
|
||||||
|
def send_file(self,arg):
|
||||||
|
print("send_file")
|
||||||
|
j = json.loads(arg)
|
||||||
|
msg_id =str(j['id']).lower()
|
||||||
|
file_path =str(j['filePath']).lower()
|
||||||
|
time_stamp=str(j['timestamp']).lower()
|
||||||
|
|
||||||
|
message_sender=MessageSender(None,file_path)
|
||||||
|
message_sender.connect_to_server()
|
0
opt/ahenk/base/execution/__init__.py
Normal file
0
opt/ahenk/base/execution/__init__.py
Normal file
Loading…
Reference in a new issue