mirror of
https://github.com/Pardus-LiderAhenk/ahenk
synced 2024-11-25 21:42:21 +03:00
unregister show message fixed
This commit is contained in:
parent
9232b6439f
commit
8991f8d768
3 changed files with 58 additions and 46 deletions
|
@ -240,6 +240,29 @@ class AhenkDaemon(BaseDaemon):
|
||||||
Util.create_file(System.Ahenk.fifo_file())
|
Util.create_file(System.Ahenk.fifo_file())
|
||||||
Util.set_permission(System.Ahenk.fifo_file(), '600')
|
Util.set_permission(System.Ahenk.fifo_file(), '600')
|
||||||
|
|
||||||
|
def disable_local_users(self):
|
||||||
|
|
||||||
|
self.logger.info('Local users disable action start..')
|
||||||
|
conf_manager = Scope.get_instance().get_configuration_manager()
|
||||||
|
|
||||||
|
if conf_manager.has_section('MACHINE'):
|
||||||
|
user_disabled = conf_manager.get("MACHINE", "user_disabled")
|
||||||
|
self.logger.info('User disabled value=' + str(user_disabled))
|
||||||
|
if user_disabled == '0':
|
||||||
|
self.logger.info('local user disabling')
|
||||||
|
Scope.get_instance().get_registration().disable_local_users()
|
||||||
|
|
||||||
|
conf_manager.set('MACHINE', 'user_disabled', '1')
|
||||||
|
|
||||||
|
with open('/etc/ahenk/ahenk.conf', 'w') as configfile:
|
||||||
|
self.logger.info('oepning config file ')
|
||||||
|
conf_manager.write(configfile)
|
||||||
|
|
||||||
|
user_disabled = conf_manager.get("MACHINE", "user_disabled")
|
||||||
|
self.logger.info('User succesfully disabled value=' + str(user_disabled))
|
||||||
|
else:
|
||||||
|
self.logger.info('users already disabled')
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
""" docstring"""
|
""" docstring"""
|
||||||
print('Ahenk running...')
|
print('Ahenk running...')
|
||||||
|
@ -287,27 +310,9 @@ class AhenkDaemon(BaseDaemon):
|
||||||
|
|
||||||
self.check_registration()
|
self.check_registration()
|
||||||
|
|
||||||
self.is_registered()
|
#self.is_registered()
|
||||||
|
|
||||||
conf_manager= global_scope.get_configuration_manager()
|
self.disable_local_users()
|
||||||
|
|
||||||
if conf_manager.has_section('MACHINE'):
|
|
||||||
user_disabled = conf_manager.get("MACHINE", "user_disabled")
|
|
||||||
self.logger.info('User disabled value='+ str(user_disabled))
|
|
||||||
if user_disabled == '0':
|
|
||||||
self.logger.info('local user disabling')
|
|
||||||
global_scope.get_registration().disable_local_users()
|
|
||||||
|
|
||||||
conf_manager.set('MACHINE', 'user_disabled', '1')
|
|
||||||
|
|
||||||
with open('/etc/ahenk/ahenk.conf', 'w') as configfile:
|
|
||||||
self.logger.info('oepning config file ')
|
|
||||||
conf_manager.write(configfile)
|
|
||||||
|
|
||||||
user_disabled = conf_manager.get("MACHINE", "user_disabled")
|
|
||||||
self.logger.info('User succesfully disabled value=' + str(user_disabled))
|
|
||||||
else :
|
|
||||||
self.logger.info('users already disabled')
|
|
||||||
|
|
||||||
#self.logger.info('Ahenk was registered')
|
#self.logger.info('Ahenk was registered')
|
||||||
|
|
||||||
|
|
|
@ -352,6 +352,10 @@ class Registration:
|
||||||
|
|
||||||
|
|
||||||
def purge_and_unregister(self):
|
def purge_and_unregister(self):
|
||||||
|
try:
|
||||||
|
user_name = self.db_service.select_one_result('session', 'username')
|
||||||
|
display = self.db_service.select_one_result('session', 'display')
|
||||||
|
|
||||||
self.logger.info('Ahenk conf cleaned')
|
self.logger.info('Ahenk conf cleaned')
|
||||||
self.logger.info('Ahenk conf cleaning from db')
|
self.logger.info('Ahenk conf cleaning from db')
|
||||||
self.unregister()
|
self.unregister()
|
||||||
|
@ -369,14 +373,16 @@ class Registration:
|
||||||
self.logger.info('Enable Users')
|
self.logger.info('Enable Users')
|
||||||
self.enable_local_users()
|
self.enable_local_users()
|
||||||
|
|
||||||
user_name = self.db_service.select_one_result('session', 'username')
|
|
||||||
display = self.db_service.select_one_result('session', 'display')
|
|
||||||
|
|
||||||
Util.show_message(user_name, display, "Ahenk etki alanından çıkarılmıştır.", "")
|
Util.show_message(user_name, display, "Ahenk etki alanından çıkarılmıştır.", "")
|
||||||
|
|
||||||
if Util.show_message(user_name,display,"Değişikliklerin etkili olması için sistem yeniden başlatmanız gerekmektedir.",""):
|
if Util.show_message(user_name, display,
|
||||||
|
"Değişikliklerin etkili olması için sistem yeniden başlatmanız gerekmektedir.", ""):
|
||||||
Util.shutdown()
|
Util.shutdown()
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
self.logger.error("Error while running purge_and_unregister process.. Error Message " + str(e))
|
||||||
|
|
||||||
|
|
||||||
#System.Process.kill_by_pid(int(System.Ahenk.get_pid_number()))
|
#System.Process.kill_by_pid(int(System.Ahenk.get_pid_number()))
|
||||||
#sys.exit(2)
|
#sys.exit(2)
|
||||||
|
|
||||||
|
@ -475,6 +481,7 @@ class Registration:
|
||||||
file.close()
|
file.close()
|
||||||
print('Ahenk cleaned.')
|
print('Ahenk cleaned.')
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
self.logger.error("Error while running clean command. Error Message " + str(e))
|
||||||
print('Error while running clean command. Error Message {0}'.format(str(e)))
|
print('Error while running clean command. Error Message {0}'.format(str(e)))
|
||||||
|
|
||||||
def enable_local_users(self):
|
def enable_local_users(self):
|
||||||
|
|
|
@ -332,7 +332,7 @@ class Util:
|
||||||
Util.execute('export DISPLAY={0}; su - {1} -c \'{2}\''.format(display, user, inner_command))
|
Util.execute('export DISPLAY={0}; su - {1} -c \'{2}\''.format(display, user, inner_command))
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def show_message(username,display=':0',message="", title=""):
|
def show_message(username,display=':0',message='', title=''):
|
||||||
ask_path = '/usr/share/ahenk/base/agreement/confirm.py'
|
ask_path = '/usr/share/ahenk/base/agreement/confirm.py'
|
||||||
try:
|
try:
|
||||||
|
|
||||||
|
@ -352,14 +352,14 @@ class Util:
|
||||||
|
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
except Exception:
|
except Exception as e :
|
||||||
return None
|
print("Error when showing message " + str(e))
|
||||||
|
|
||||||
|
return None;
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def show_registration_message(login_user_name,message,title,host=None):
|
def show_registration_message(login_user_name,message,title,host=None):
|
||||||
|
|
||||||
ask_path = '/usr/share/ahenk/base/agreement/ahenkmessage.py'
|
ask_path = '/usr/share/ahenk/base/agreement/ahenkmessage.py'
|
||||||
|
|
||||||
display_number = ":0"
|
display_number = ":0"
|
||||||
|
|
||||||
if host is None:
|
if host is None:
|
||||||
|
@ -375,7 +375,7 @@ class Util:
|
||||||
|
|
||||||
pout = str(p_out).replace('\n', '')
|
pout = str(p_out).replace('\n', '')
|
||||||
|
|
||||||
return pout\
|
return pout
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def show_unregistration_message(login_user_name,display_number,message,title):
|
def show_unregistration_message(login_user_name,display_number,message,title):
|
||||||
|
|
Loading…
Reference in a new issue