From 98784905dd7bdcc93fffe473247001db4e7e7955 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volkan=20=C5=9Eahin?= Date: Tue, 21 Jun 2016 17:47:25 +0300 Subject: [PATCH] registration failed handled --- opt/ahenk/ahenkd.py | 9 +++++---- opt/ahenk/base/util/util.py | 8 ++++---- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/opt/ahenk/ahenkd.py b/opt/ahenk/ahenkd.py index a903c5c..42ea1c8 100755 --- a/opt/ahenk/ahenkd.py +++ b/opt/ahenk/ahenkd.py @@ -114,12 +114,12 @@ class AhenkDeamon(BaseDaemon): def check_registration(self): max_attemp_number = int(System.Hardware.Network.interface_size()) * 3 logger = Scope.getInstance().getLogger() + try: while Scope.getInstance().getRegistration().is_registered() is False: max_attemp_number -= 1 logger.debug('[AhenkDeamon] Ahenk is not registered. Attempting for registration') - # TODO 'Could not reach Registration response from Lider. Be sure Lider is awake and it is connected to XMPP server!' - + # TODO 'Could not reach Registration response from Lider. Be sure Lider is running and it is connected to XMPP server!' Scope.getInstance().getRegistration().registration_request() if max_attemp_number < 0: logger.warning('[AhenkDeamon] Number of Attempting for registration is over') @@ -129,8 +129,9 @@ class AhenkDeamon(BaseDaemon): logger.error('[AhenkDeamon] Registration failed. Error message: {}'.format(str(e))) def registration_failed(self): - # TODO registration fail protocol implement - pass + self.logger.error('[AhenkDeamon] Registration failed. All registration attemps were failed. Ahenk is stopping...') + print('Registration failed. Ahenk is stopping..') + ahenkdaemon.stop() def reload_plugins(self): Scope.getInstance().getPluginManager().reloadPlugins() diff --git a/opt/ahenk/base/util/util.py b/opt/ahenk/base/util/util.py index 33eff7b..ca75a72 100644 --- a/opt/ahenk/base/util/util.py +++ b/opt/ahenk/base/util/util.py @@ -209,16 +209,16 @@ class Util: result_code, p_out, p_err = Util.execute('dpkg -s {}'.format(package_name)) try: - lines=str(p_out).split('\n') + lines = str(p_out).split('\n') for line in lines: - if len(line)>1: - if line.split(None, 1)[0].lower() =='status:': + if len(line) > 1: + if line.split(None, 1)[0].lower() == 'status:': if 'installed' in line.split(None, 1)[1].lower(): return True return False except Exception as e: return False - + @staticmethod def get_md5_file(fname): hash_md5 = hashlib.md5()