mirror of
https://github.com/Pardus-LiderAhenk/ahenk
synced 2024-11-25 17:02:15 +03:00
update db for logon user and set display number in gnome for unregistration agent
This commit is contained in:
parent
de02e60a3c
commit
2b1591e74e
2 changed files with 10 additions and 19 deletions
|
@ -130,7 +130,7 @@ class CommandRunner(object):
|
||||||
agreement_choice = True
|
agreement_choice = True
|
||||||
|
|
||||||
if agreement_choice is True or System.Ahenk.agreement() != '1':
|
if agreement_choice is True or System.Ahenk.agreement() != '1':
|
||||||
self.db_service.delete('session', 'username=\'{0}\''.format(username))
|
self.db_service.delete('session', '1=1')
|
||||||
|
|
||||||
self.logger.info(
|
self.logger.info(
|
||||||
'Display is {0}, desktop env is {1} for {2}'.format(display, desktop,
|
'Display is {0}, desktop env is {1} for {2}'.format(display, desktop,
|
||||||
|
|
|
@ -339,7 +339,6 @@ class Util:
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def send_notify(title, body, display, user, icon=None, timeout=5000):
|
def send_notify(title, body, display, user, icon=None, timeout=5000):
|
||||||
|
|
||||||
inner_command = 'notify-send "{0}" "{1}" -t {2}'.format(title, body, timeout)
|
inner_command = 'notify-send "{0}" "{1}" -t {2}'.format(title, body, timeout)
|
||||||
if icon:
|
if icon:
|
||||||
inner_command += ' -i {0}'.format(icon)
|
inner_command += ' -i {0}'.format(icon)
|
||||||
|
@ -350,15 +349,14 @@ class Util:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def show_message(username, display, message='', title=''):
|
def show_message(username, display, message='', title=''):
|
||||||
ask_path = Util.get_ask_path_file()+ 'confirm.py'
|
ask_path = Util.get_ask_path_file()+ 'confirm.py'
|
||||||
|
|
||||||
Scope.get_instance().get_logger().debug('DISPLAYYYY --------->>>>>>>>: ' + str(display))
|
Scope.get_instance().get_logger().debug('DISPLAYYYY --------->>>>>>>>: ' + str(display))
|
||||||
|
|
||||||
if display is None:
|
if display is None:
|
||||||
display_number = Util.get_username_display()
|
display_number = Util.get_username_display()
|
||||||
else:
|
else:
|
||||||
display_number = display
|
display_number = display
|
||||||
try:
|
try:
|
||||||
|
if Util.get_desktop_env() == "gnome":
|
||||||
|
display_number = Util.get_username_display_gnome(username)
|
||||||
if username is not None:
|
if username is not None:
|
||||||
command = 'su - {0} -c \'python3 {1} \"{2}\" \"{3}\" \"{4}\"\''.format(username, ask_path, message,
|
command = 'su - {0} -c \'python3 {1} \"{2}\" \"{3}\" \"{4}\"\''.format(username, ask_path, message,
|
||||||
title, display_number)
|
title, display_number)
|
||||||
|
@ -370,24 +368,21 @@ class Util:
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
except Exception as e :
|
except Exception as e :
|
||||||
print("Error when showing message " + str(e))
|
print("Error when showing message " + str(e))
|
||||||
|
|
||||||
return None
|
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 = Util.get_ask_path_file() + 'ahenkmessage.py'
|
ask_path = Util.get_ask_path_file() + 'ahenkmessage.py'
|
||||||
|
|
||||||
# display_number = ":0"
|
# display_number = ":0"
|
||||||
display_number = Util.get_username_display()
|
display_number = Util.get_username_display()
|
||||||
|
|
||||||
|
if Util.get_desktop_env() == "gnome":
|
||||||
|
display_number = Util.get_username_display_gnome(login_user_name)
|
||||||
|
|
||||||
if host is None:
|
if host is None:
|
||||||
command = 'su - {0} -c \"python3 {1} \'{2}\' \'{3}\' \'{4}\' \"'.format(login_user_name,
|
command = 'su - {0} -c \"python3 {1} \'{2}\' \'{3}\' \'{4}\' \"'.format(login_user_name,
|
||||||
ask_path, message, title, display_number)
|
ask_path, message, title, display_number)
|
||||||
|
@ -397,27 +392,23 @@ class Util:
|
||||||
message, title,
|
message, title,
|
||||||
host, display_number)
|
host, display_number)
|
||||||
result_code, p_out, p_err = Util.execute(command)
|
result_code, p_out, p_err = Util.execute(command)
|
||||||
|
|
||||||
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):
|
||||||
|
|
||||||
ask_path = Util.get_ask_path_file()+ 'unregistrationmessage.py'
|
ask_path = Util.get_ask_path_file()+ 'unregistrationmessage.py'
|
||||||
|
if Util.get_desktop_env() == "gnome":
|
||||||
|
display_number = Util.get_username_display_gnome(login_user_name)
|
||||||
|
|
||||||
command = 'su - {0} -c \"python3 {1} \'{2}\' \'{3}\' \'{4}\' \"'.format(login_user_name, ask_path, message, title, display_number)
|
command = 'su - {0} -c \"python3 {1} \'{2}\' \'{3}\' \'{4}\' \"'.format(login_user_name, ask_path, message, title, display_number)
|
||||||
result_code, p_out, p_err = Util.execute(command)
|
result_code, p_out, p_err = Util.execute(command)
|
||||||
|
|
||||||
pout = str(p_out).replace('\n', '')
|
pout = str(p_out).replace('\n', '')
|
||||||
|
|
||||||
return pout
|
return pout
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_username_display():
|
def get_username_display():
|
||||||
result_code, p_out, p_err = Util.execute("who | awk '{print $1, $5}' | sed 's/(://' | sed 's/)//'", result=True)
|
result_code, p_out, p_err = Util.execute("who | awk '{print $1, $5}' | sed 's/(://' | sed 's/)//'", result=True)
|
||||||
|
|
||||||
result = []
|
result = []
|
||||||
lines = str(p_out).split('\n')
|
lines = str(p_out).split('\n')
|
||||||
for line in lines:
|
for line in lines:
|
||||||
|
|
Loading…
Reference in a new issue