From e0f68c9bf267f72e8a826596b94ffe7420be6811 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volkan=20=C5=9Eahin?= Date: Tue, 8 Mar 2016 18:05:42 +0200 Subject: [PATCH] prepare json messages for fix events --- opt/ahenk/base/messaging/Messaging.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/opt/ahenk/base/messaging/Messaging.py b/opt/ahenk/base/messaging/Messaging.py index dc87dd0..b779d48 100644 --- a/opt/ahenk/base/messaging/Messaging.py +++ b/opt/ahenk/base/messaging/Messaging.py @@ -10,15 +10,17 @@ from base.Scope import Scope class Messaging(object): def __init__(self): - print("messaging initilaziton") + scope = Scope().getInstance() self.logger = scope.getLogger() self.configurationManager = scope.getConfigurationManager() self.event_manger=scope.getEventManager() + #TODO can use sh commands for getting username and timestamp + def login_msg(self): data = {} - data['type'] = 'login' + data['type'] = 'LOGIN' data['username'] = str(pwd.getpwuid( os.getuid() )[ 0 ]) data['timestamp'] = str(datetime.datetime.now().strftime("%d-%m-%Y %I:%M")) json_data = json.dumps(data) @@ -26,7 +28,7 @@ class Messaging(object): def logout_msg(self): data = {} - data['type'] = 'logout' + data['type'] = 'LOGOUT' data['username'] = str(pwd.getpwuid( os.getuid() )[ 0 ]) data['timestamp'] = str(datetime.datetime.now().strftime("%d-%m-%Y %I:%M")) json_data = json.dumps(data) @@ -34,7 +36,7 @@ class Messaging(object): def get_policies_msg(self): data = {} - data['type'] = 'get_policies' + data['type'] = 'GET_POLICIES' data['username'] = str(pwd.getpwuid( os.getuid() )[ 0 ]) data['timestamp'] = str(datetime.datetime.now().strftime("%d-%m-%Y %I:%M")) json_data = json.dumps(data) @@ -42,8 +44,7 @@ class Messaging(object): def unregister_msg(self): data = {} - data['type'] = 'registration' - data['status'] = 'unregister' + data['type'] = 'UNREGISTER' data['username'] = str(pwd.getpwuid( os.getuid() )[ 0 ]) data['timestamp'] = str(datetime.datetime.now().strftime("%d-%m-%Y %I:%M")) json_data = json.dumps(data)