From 9b96a6e2867480a76578ad45d8fb933caa7b5b09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volkan=20=C5=9Eahin?= Date: Wed, 24 Aug 2016 18:00:01 +0300 Subject: [PATCH] ssl parameter added to conf file --- .../base/config/{ConfigManager.py => config_manager.py} | 0 .../database/{AhenkDbService.py => ahenk_db_service.py} | 0 opt/ahenk/base/deamon/{BaseDeamon.py => base_daemon.py} | 0 opt/ahenk/base/event/{EventBase.py => event_base.py} | 5 +++-- .../base/event/{EventManager.py => event_manager.py} | 0 .../{ExecutionManager.py => execution_manager.py} | 0 opt/ahenk/base/logger/{AhenkLogger.py => ahenk_logger.py} | 0 .../{AnonymousMessenger.py => anonymous_messenger.py} | 0 ...{MessageResponseQueue.py => message_response_queue.py} | 0 opt/ahenk/base/messaging/{Messaging.py => messaging.py} | 0 opt/ahenk/base/messaging/{Messenger.py => messenger.py} | 8 +++++++- .../base/model/enum/{ContentType.py => content_type.py} | 0 .../base/model/enum/{MessageCode.py => message_code.py} | 0 .../base/model/enum/{MessageType.py => message_type.py} | 0 .../base/model/{MessageFactory.py => message_factory.py} | 2 +- opt/ahenk/base/model/{Plugin.py => plugin.py} | 0 opt/ahenk/base/model/{PluginBean.py => plugin_bean.py} | 0 opt/ahenk/base/model/{Policy.py => policy.py} | 0 opt/ahenk/base/model/{PolicyBean.py => policy_bean.py} | 0 opt/ahenk/base/model/{Profile.py => profile.py} | 2 +- opt/ahenk/base/model/{ProfileBean.py => profile_bean.py} | 2 +- opt/ahenk/base/model/{Response.py => response.py} | 0 opt/ahenk/base/model/{Task.py => task.py} | 2 +- opt/ahenk/base/model/{TaskBean.py => task_bean.py} | 0 opt/ahenk/base/plugin/{PluginQueue.py => plugin_queue.py} | 0 .../registration/{Registration.py => registration.py} | 2 +- opt/ahenk/base/{Scope.py => scope.py} | 0 opt/ahenk/base/task/{TaskInQueue.py => task_in_queue.py} | 0 opt/ahenk/base/task/{TaskJob.py => task_job.py} | 0 opt/ahenk/base/task/{TaskManager.py => task_manager.py} | 4 ++-- 30 files changed, 17 insertions(+), 10 deletions(-) rename opt/ahenk/base/config/{ConfigManager.py => config_manager.py} (100%) rename opt/ahenk/base/database/{AhenkDbService.py => ahenk_db_service.py} (100%) rename opt/ahenk/base/deamon/{BaseDeamon.py => base_daemon.py} (100%) rename opt/ahenk/base/event/{EventBase.py => event_base.py} (97%) rename opt/ahenk/base/event/{EventManager.py => event_manager.py} (100%) rename opt/ahenk/base/execution/{ExecutionManager.py => execution_manager.py} (100%) rename opt/ahenk/base/logger/{AhenkLogger.py => ahenk_logger.py} (100%) rename opt/ahenk/base/messaging/{AnonymousMessenger.py => anonymous_messenger.py} (100%) rename opt/ahenk/base/messaging/{MessageResponseQueue.py => message_response_queue.py} (100%) rename opt/ahenk/base/messaging/{Messaging.py => messaging.py} (100%) rename opt/ahenk/base/messaging/{Messenger.py => messenger.py} (94%) rename opt/ahenk/base/model/enum/{ContentType.py => content_type.py} (100%) rename opt/ahenk/base/model/enum/{MessageCode.py => message_code.py} (100%) rename opt/ahenk/base/model/enum/{MessageType.py => message_type.py} (100%) rename opt/ahenk/base/model/{MessageFactory.py => message_factory.py} (90%) rename opt/ahenk/base/model/{Plugin.py => plugin.py} (100%) rename opt/ahenk/base/model/{PluginBean.py => plugin_bean.py} (100%) rename opt/ahenk/base/model/{Policy.py => policy.py} (100%) rename opt/ahenk/base/model/{PolicyBean.py => policy_bean.py} (100%) rename opt/ahenk/base/model/{Profile.py => profile.py} (97%) rename opt/ahenk/base/model/{ProfileBean.py => profile_bean.py} (96%) rename opt/ahenk/base/model/{Response.py => response.py} (100%) rename opt/ahenk/base/model/{Task.py => task.py} (97%) rename opt/ahenk/base/model/{TaskBean.py => task_bean.py} (100%) rename opt/ahenk/base/plugin/{PluginQueue.py => plugin_queue.py} (100%) rename opt/ahenk/base/registration/{Registration.py => registration.py} (99%) rename opt/ahenk/base/{Scope.py => scope.py} (100%) rename opt/ahenk/base/task/{TaskInQueue.py => task_in_queue.py} (100%) rename opt/ahenk/base/task/{TaskJob.py => task_job.py} (100%) rename opt/ahenk/base/task/{TaskManager.py => task_manager.py} (96%) diff --git a/opt/ahenk/base/config/ConfigManager.py b/opt/ahenk/base/config/config_manager.py similarity index 100% rename from opt/ahenk/base/config/ConfigManager.py rename to opt/ahenk/base/config/config_manager.py diff --git a/opt/ahenk/base/database/AhenkDbService.py b/opt/ahenk/base/database/ahenk_db_service.py similarity index 100% rename from opt/ahenk/base/database/AhenkDbService.py rename to opt/ahenk/base/database/ahenk_db_service.py diff --git a/opt/ahenk/base/deamon/BaseDeamon.py b/opt/ahenk/base/deamon/base_daemon.py similarity index 100% rename from opt/ahenk/base/deamon/BaseDeamon.py rename to opt/ahenk/base/deamon/base_daemon.py diff --git a/opt/ahenk/base/event/EventBase.py b/opt/ahenk/base/event/event_base.py similarity index 97% rename from opt/ahenk/base/event/EventBase.py rename to opt/ahenk/base/event/event_base.py index e2d3986..7c23cb1 100644 --- a/opt/ahenk/base/event/EventBase.py +++ b/opt/ahenk/base/event/event_base.py @@ -2,8 +2,8 @@ # -*- coding: utf-8 -*- # @author: İsmail BAŞARAN -class EventBase(): +class EventBase: """ This is base event class for event management. """ @@ -24,13 +24,14 @@ class EventBase(): self.listener_events.append({'event_name': event_name, 'callback_func': callback_func}) -class Event(): +class Event: """ This is event class. Takes two argument ; Args: event_name : name of event. callback_args : arguments specified by user. This function will transmit args to callback function directly. """ + def __init__(self, event_name, *callback_args): for listener in EventBase.listeners: for listener_cls in listener.listener_events: diff --git a/opt/ahenk/base/event/EventManager.py b/opt/ahenk/base/event/event_manager.py similarity index 100% rename from opt/ahenk/base/event/EventManager.py rename to opt/ahenk/base/event/event_manager.py diff --git a/opt/ahenk/base/execution/ExecutionManager.py b/opt/ahenk/base/execution/execution_manager.py similarity index 100% rename from opt/ahenk/base/execution/ExecutionManager.py rename to opt/ahenk/base/execution/execution_manager.py diff --git a/opt/ahenk/base/logger/AhenkLogger.py b/opt/ahenk/base/logger/ahenk_logger.py similarity index 100% rename from opt/ahenk/base/logger/AhenkLogger.py rename to opt/ahenk/base/logger/ahenk_logger.py diff --git a/opt/ahenk/base/messaging/AnonymousMessenger.py b/opt/ahenk/base/messaging/anonymous_messenger.py similarity index 100% rename from opt/ahenk/base/messaging/AnonymousMessenger.py rename to opt/ahenk/base/messaging/anonymous_messenger.py diff --git a/opt/ahenk/base/messaging/MessageResponseQueue.py b/opt/ahenk/base/messaging/message_response_queue.py similarity index 100% rename from opt/ahenk/base/messaging/MessageResponseQueue.py rename to opt/ahenk/base/messaging/message_response_queue.py diff --git a/opt/ahenk/base/messaging/Messaging.py b/opt/ahenk/base/messaging/messaging.py similarity index 100% rename from opt/ahenk/base/messaging/Messaging.py rename to opt/ahenk/base/messaging/messaging.py diff --git a/opt/ahenk/base/messaging/Messenger.py b/opt/ahenk/base/messaging/messenger.py similarity index 94% rename from opt/ahenk/base/messaging/Messenger.py rename to opt/ahenk/base/messaging/messenger.py index edd309b..3bfbb9d 100644 --- a/opt/ahenk/base/messaging/Messenger.py +++ b/opt/ahenk/base/messaging/messenger.py @@ -34,6 +34,11 @@ class Messenger(ClientXMPP): self.hostname = self.configuration_manager.get('CONNECTION', 'host') self.receiver_resource = self.configuration_manager.get('CONNECTION', 'receiverresource') + if self.configuration_manager.get('CONNECTION', 'use_tls').split().lower() == 'true': + self.use_tls = True + else: + self.use_tls = False + self.receiver = self.configuration_manager.get('CONNECTION', 'receiverjid') + '@' + self.configuration_manager.get( 'CONNECTION', 'servicename') @@ -67,7 +72,8 @@ class Messenger(ClientXMPP): def connect_to_server(self): # Connect to the XMPP server and start processing XMPP stanzas. try: self['feature_mechanisms'].unencrypted_plain = True - self.connect((self.hostname, 5222), use_tls=False) + + self.connect((self.hostname, 5222), use_tls=self.use_tls) self.process(block=False) self.logger.debug('[Messenger] Connection were established successfully') return True diff --git a/opt/ahenk/base/model/enum/ContentType.py b/opt/ahenk/base/model/enum/content_type.py similarity index 100% rename from opt/ahenk/base/model/enum/ContentType.py rename to opt/ahenk/base/model/enum/content_type.py diff --git a/opt/ahenk/base/model/enum/MessageCode.py b/opt/ahenk/base/model/enum/message_code.py similarity index 100% rename from opt/ahenk/base/model/enum/MessageCode.py rename to opt/ahenk/base/model/enum/message_code.py diff --git a/opt/ahenk/base/model/enum/MessageType.py b/opt/ahenk/base/model/enum/message_type.py similarity index 100% rename from opt/ahenk/base/model/enum/MessageType.py rename to opt/ahenk/base/model/enum/message_type.py diff --git a/opt/ahenk/base/model/MessageFactory.py b/opt/ahenk/base/model/message_factory.py similarity index 90% rename from opt/ahenk/base/model/MessageFactory.py rename to opt/ahenk/base/model/message_factory.py index 42b7916..17732d8 100644 --- a/opt/ahenk/base/model/MessageFactory.py +++ b/opt/ahenk/base/model/message_factory.py @@ -1,7 +1,7 @@ #!/usr/bin/python3 # -*- coding: utf-8 -*- # Author: İsmail BAŞARAN -from base.model.enum.MessageType import MessageType +from base.model.enum.message_type import MessageType class MessageFactory(object): diff --git a/opt/ahenk/base/model/Plugin.py b/opt/ahenk/base/model/plugin.py similarity index 100% rename from opt/ahenk/base/model/Plugin.py rename to opt/ahenk/base/model/plugin.py diff --git a/opt/ahenk/base/model/PluginBean.py b/opt/ahenk/base/model/plugin_bean.py similarity index 100% rename from opt/ahenk/base/model/PluginBean.py rename to opt/ahenk/base/model/plugin_bean.py diff --git a/opt/ahenk/base/model/Policy.py b/opt/ahenk/base/model/policy.py similarity index 100% rename from opt/ahenk/base/model/Policy.py rename to opt/ahenk/base/model/policy.py diff --git a/opt/ahenk/base/model/PolicyBean.py b/opt/ahenk/base/model/policy_bean.py similarity index 100% rename from opt/ahenk/base/model/PolicyBean.py rename to opt/ahenk/base/model/policy_bean.py diff --git a/opt/ahenk/base/model/Profile.py b/opt/ahenk/base/model/profile.py similarity index 97% rename from opt/ahenk/base/model/Profile.py rename to opt/ahenk/base/model/profile.py index e492f68..48dc19d 100644 --- a/opt/ahenk/base/model/Profile.py +++ b/opt/ahenk/base/model/profile.py @@ -3,7 +3,7 @@ # Author: Volkan Şahin import json -from base.model.Plugin import Plugin +from base.model.plugin import Plugin class Profile(object): diff --git a/opt/ahenk/base/model/ProfileBean.py b/opt/ahenk/base/model/profile_bean.py similarity index 96% rename from opt/ahenk/base/model/ProfileBean.py rename to opt/ahenk/base/model/profile_bean.py index 09d185b..8757380 100644 --- a/opt/ahenk/base/model/ProfileBean.py +++ b/opt/ahenk/base/model/profile_bean.py @@ -3,7 +3,7 @@ # Author: Volkan Şahin import json -from base.model.PluginBean import PluginBean +from base.model.plugin_bean import PluginBean class ProfileBean(object): diff --git a/opt/ahenk/base/model/Response.py b/opt/ahenk/base/model/response.py similarity index 100% rename from opt/ahenk/base/model/Response.py rename to opt/ahenk/base/model/response.py diff --git a/opt/ahenk/base/model/Task.py b/opt/ahenk/base/model/task.py similarity index 97% rename from opt/ahenk/base/model/Task.py rename to opt/ahenk/base/model/task.py index 93c390b..93778af 100644 --- a/opt/ahenk/base/model/Task.py +++ b/opt/ahenk/base/model/task.py @@ -4,7 +4,7 @@ # Author: Volkan Şahin import json -from base.model.Plugin import Plugin +from base.model.plugin import Plugin class Task(object): diff --git a/opt/ahenk/base/model/TaskBean.py b/opt/ahenk/base/model/task_bean.py similarity index 100% rename from opt/ahenk/base/model/TaskBean.py rename to opt/ahenk/base/model/task_bean.py diff --git a/opt/ahenk/base/plugin/PluginQueue.py b/opt/ahenk/base/plugin/plugin_queue.py similarity index 100% rename from opt/ahenk/base/plugin/PluginQueue.py rename to opt/ahenk/base/plugin/plugin_queue.py diff --git a/opt/ahenk/base/registration/Registration.py b/opt/ahenk/base/registration/registration.py similarity index 99% rename from opt/ahenk/base/registration/Registration.py rename to opt/ahenk/base/registration/registration.py index 8aa9bd2..ee97496 100644 --- a/opt/ahenk/base/registration/Registration.py +++ b/opt/ahenk/base/registration/registration.py @@ -8,7 +8,7 @@ import uuid from uuid import getnode as get_mac from base.Scope import Scope -from base.messaging.AnonymousMessenger import AnonymousMessenger +from base.messaging.anonymous_messenger import AnonymousMessenger from base.system.system import System from base.timer.setup_timer import SetupTimer from base.timer.timer import Timer diff --git a/opt/ahenk/base/Scope.py b/opt/ahenk/base/scope.py similarity index 100% rename from opt/ahenk/base/Scope.py rename to opt/ahenk/base/scope.py diff --git a/opt/ahenk/base/task/TaskInQueue.py b/opt/ahenk/base/task/task_in_queue.py similarity index 100% rename from opt/ahenk/base/task/TaskInQueue.py rename to opt/ahenk/base/task/task_in_queue.py diff --git a/opt/ahenk/base/task/TaskJob.py b/opt/ahenk/base/task/task_job.py similarity index 100% rename from opt/ahenk/base/task/TaskJob.py rename to opt/ahenk/base/task/task_job.py diff --git a/opt/ahenk/base/task/TaskManager.py b/opt/ahenk/base/task/task_manager.py similarity index 96% rename from opt/ahenk/base/task/TaskManager.py rename to opt/ahenk/base/task/task_manager.py index 86c5907..1e5aa0c 100644 --- a/opt/ahenk/base/task/TaskManager.py +++ b/opt/ahenk/base/task/task_manager.py @@ -3,8 +3,8 @@ # Author: İsmail BAŞARAN from base.Scope import Scope -from base.model.MessageFactory import MessageFactory -from base.model.enum.MessageType import MessageType +from base.model.message_factory import MessageFactory +from base.model.enum.message_type import MessageType class TaskManager(object):