registration failed handled

This commit is contained in:
Volkan Şahin 2016-06-21 17:47:25 +03:00
parent 1e3377c048
commit 98784905dd
2 changed files with 9 additions and 8 deletions

View file

@ -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()

View file

@ -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()