From 80079685b528281fb4f682bcf677cc36046b66f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volkan=20=C5=9Eahin?= Date: Thu, 31 Mar 2016 18:21:24 +0300 Subject: [PATCH] minor bug fixes --- opt/ahenk/base/execution/ExecutionManager.py | 4 ++-- opt/ahenk/base/messaging/Messager.py | 7 +++++++ opt/ahenk/base/plugin/Plugin.py | 6 ++---- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/opt/ahenk/base/execution/ExecutionManager.py b/opt/ahenk/base/execution/ExecutionManager.py index a9211f8..24a381b 100644 --- a/opt/ahenk/base/execution/ExecutionManager.py +++ b/opt/ahenk/base/execution/ExecutionManager.py @@ -41,8 +41,8 @@ class ExecutionManager(object): policy = Policy(json.loads(arg)) # TODO get username and machine uid - username = 'volkan' - machine_uid='616161616161' + username = 'lider' + machine_uid = self.db_service.select_one_result('registration', 'jid', 'registered=1') ahenk_policy_ver = self.db_service.select_one_result('policy', 'version', 'type = \'A\'') user_policy_version = self.db_service.select_one_result('policy', 'version', 'type = \'U\' and name = \'' + username + '\'') diff --git a/opt/ahenk/base/messaging/Messager.py b/opt/ahenk/base/messaging/Messager.py index ead9c49..6e3a428 100644 --- a/opt/ahenk/base/messaging/Messager.py +++ b/opt/ahenk/base/messaging/Messager.py @@ -15,6 +15,9 @@ from base.Scope import Scope class Messager(slixmpp.ClientXMPP): + + global loop + def __init__(self): # global scope of ahenk scope = Scope().getInstance() @@ -41,6 +44,7 @@ class Messager(slixmpp.ClientXMPP): def add_listeners(self): self.add_event_handler('session_start', self.session_start) + self.add_event_handler('session_end', self.session_end) self.add_event_handler('message', self.recv_direct_message) self.add_event_handler('socks5_connected', self.stream_opened) @@ -72,6 +76,9 @@ class Messager(slixmpp.ClientXMPP): self.get_roster() self.send_presence() + def session_end(self): + print("disconnect") + # TODO need check def send_file(self, file_path): self.file = open(file_path, 'rb') diff --git a/opt/ahenk/base/plugin/Plugin.py b/opt/ahenk/base/plugin/Plugin.py index ccfe570..197f48a 100644 --- a/opt/ahenk/base/plugin/Plugin.py +++ b/opt/ahenk/base/plugin/Plugin.py @@ -57,8 +57,7 @@ class Plugin(threading.Thread): # TODO create response message from context and item_obj. item_obj is task #TODO Message Code keep - #item_obj.id ?? - response = Response(type=MessageType.TASK_STATUS, id='id', code=MessageCode.TASK_PROCESSED, message='__message__', data=self.context.get('data'), content_type=self.context.get('content_type')) + response = Response(type=MessageType.TASK_STATUS, id=item_obj.id, code=MessageCode.TASK_PROCESSED, message='__message__', data=self.context.get('data'), content_type=self.context.get('content_type')) #self.response_queue.put(self.messaging.response_msg(response)) #TODO DEBUG Scope.getInstance().getMessager().send_direct_message(self.messaging.response_msg(response)) #TODO REMOVE @@ -74,8 +73,7 @@ class Plugin(threading.Thread): policy_module.handle_policy(profile_data, self.context) #TODO Message Code keep - #item_obj.id ?? - response = Response(type=MessageType.POLICY_STATUS, id='id', code=MessageCode.POLICY_PROCESSED, message='__message__', data=self.context.get('data'), content_type=self.context.get('content_type')) + response = Response(type=MessageType.POLICY_STATUS, id=item_obj.id, code=MessageCode.POLICY_PROCESSED, message='__message__', data=self.context.get('data'), content_type=self.context.get('content_type')) #self.response_queue.put(self.messaging.response_msg(response)) #TODO DEBUG Scope.getInstance().getMessager().send_direct_message(self.messaging.response_msg(response))#TODO REMOVE