From 28fec709b76c4ffa1d0fdb4d19d79af3a70dc378 Mon Sep 17 00:00:00 2001 From: edip Date: Thu, 15 Nov 2018 23:10:54 +0300 Subject: [PATCH] unregistariton message fixed --- src/base/agreement/unregistrationmessage.py | 39 +++++++++++++++++++++ src/base/messaging/messaging.py | 27 +++++--------- src/base/registration/registration.py | 4 +-- src/base/util/util.py | 18 ++++++++++ 4 files changed, 68 insertions(+), 20 deletions(-) create mode 100644 src/base/agreement/unregistrationmessage.py diff --git a/src/base/agreement/unregistrationmessage.py b/src/base/agreement/unregistrationmessage.py new file mode 100644 index 0000000..53d153b --- /dev/null +++ b/src/base/agreement/unregistrationmessage.py @@ -0,0 +1,39 @@ +import sys +from easygui import multpasswordbox, msgbox + +def ask(message, title): + + field_names = [] + field_names.append("Yetkili Kullanıcı") + field_names.append("Parola") + + field_values = multpasswordbox( + msg=message, + title=title, fields=(field_names)) + + if field_values is None: + return print('N'); + + is_fieldvalue_empty = False; + + for value in field_values: + if value == '': + is_fieldvalue_empty = True; + + if is_fieldvalue_empty: + msgbox("Lütfen zorunlu alanları giriniz.", ok_button="Tamam") + return print('Z'); + + print(field_values[0], field_values[1]) + +if __name__ == '__main__': + + if len(sys.argv) > 1: + try: + message=sys.argv[1] + title=sys.argv[2] + ask(message,title) + except Exception as e: + print(str(e)) + else: + print('Argument fault. Check your parameters or content of parameters. Parameters: ' + str(sys.argv)) \ No newline at end of file diff --git a/src/base/messaging/messaging.py b/src/base/messaging/messaging.py index 20e3346..00f7cfd 100644 --- a/src/base/messaging/messaging.py +++ b/src/base/messaging/messaging.py @@ -6,6 +6,7 @@ import json from base.scope import Scope from base.system.system import System from base.util.util import Util +import os # TODO Message Factory @@ -150,36 +151,26 @@ class Messaging(object): return json_data def unregister_msg(self): - from easygui import multpasswordbox,msgbox - field_names = [] - field_names.append("Yetkili Kullanıcı") - field_names.append("Parola") + user_name = os.getlogin() - field_values = multpasswordbox( - msg='Makineyi etki alanından çıkarmak için zorunlu alanları giriniz. Lütfen devam eden işlemlerini sonlandırdığınıza emin olunuz !', - title='ETKI ALANI ÇIKARMA', fields=(field_names)) + self.logger.debug('User : ' + str(user_name)) - if field_values is None: - return None; + pout = Util.show_unregistration_message(user_name, + 'Makineyi etki alanından çıkarmak için zorunlu alanları giriniz. Lütfen DEVAM EDEN İŞLEMLERİNİZİ sonlandırdığınıza emin olunuz !', + 'ETKI ALANINDAN ÇIKARMA') - is_fieldvalue_empty = False; + self.logger.debug('pout : ' + str(pout)) - for value in field_values: - if value == '': - is_fieldvalue_empty = True; + field_values = pout.split(' ') - if is_fieldvalue_empty: - msgbox("Lütfen zorunlu alanları giriniz.", ok_button="Tamam") - return False; + user_registration_info = list(field_values) data = dict() data['type'] = 'UNREGISTER' data['from'] = str(self.conf_manager.get('CONNECTION', 'uid')) data['password'] = str(self.conf_manager.get('CONNECTION', 'password')) - user_registration_info = list(field_values) - data['userName'] = user_registration_info[0]; data['userPassword'] = user_registration_info[1]; diff --git a/src/base/registration/registration.py b/src/base/registration/registration.py index 4fe2ae9..ae0ecfe 100644 --- a/src/base/registration/registration.py +++ b/src/base/registration/registration.py @@ -372,8 +372,8 @@ class Registration: if Util.show_message("Değişikliklerin etkili olması için sistem yeniden başlatmanız gerekmektedir.",""): Util.shutdown() - System.Process.kill_by_pid(int(System.Ahenk.get_pid_number())) - sys.exit(2) + #System.Process.kill_by_pid(int(System.Ahenk.get_pid_number())) + #sys.exit(2) def change_configs_after_purge(self): diff --git a/src/base/util/util.py b/src/base/util/util.py index 66cc94b..e280c63 100644 --- a/src/base/util/util.py +++ b/src/base/util/util.py @@ -377,5 +377,23 @@ class Util: pout = str(p_out).replace('\n', '') + return pout\ + + @staticmethod + def show_unregistration_message(login_user_name,message,title): + + ask_path = '/usr/share/ahenk/base/agreement/unregistrationmessage.py' + + display_number = ":0" + + command = 'export DISPLAY={0}; su - {1} -c \"python3 {2} \'{3}\' \'{4}\' \"'.format(display_number, + login_user_name, + ask_path, + message, title + ) + result_code, p_out, p_err = Util.execute(command) + + pout = str(p_out).replace('\n', '') + return pout