From a0dd7e68a630abafe2601121500e1a25a0924602 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hakan=20D=C3=BCndar?= Date: Sat, 6 Nov 2021 16:49:12 +0300 Subject: [PATCH] Fixed a bug for RAM hardware information window --- src/Ram.py | 4 +++- src/RamHardwareInformation.py | 3 +-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Ram.py b/src/Ram.py index 40e8e9c1..b6023230 100644 --- a/src/Ram.py +++ b/src/Ram.py @@ -81,7 +81,9 @@ def on_eventbox1201_button_click_event(widget, event): import RamHardwareInformation RamHardwareInformation.ram_hardware_information_import_func() RamHardwareInformation.ram_hardware_information_gui_func() - RamHardwareInformation.window1201w.show() + RamHardwareInformation.ram_hardware_information_get_func() + if RamHardwareInformation.memory_hardware_information_text != "": # This statement is used in order to avoid errors if user closes polkit window without entering password. + RamHardwareInformation.window1201w.show() def on_eventbox1201_enter_notify_event(widget, event): # Eventbox is used for defining signals for the widget ("Query..." label) placed on it. changed_cursor = Gdk.Cursor(Gdk.CursorType.QUESTION_ARROW) # Define cursor type (when mouse cursor is entered area of the widget) to inform user this GUI object is clickable. diff --git a/src/RamHardwareInformation.py b/src/RamHardwareInformation.py index b62a4f69..7d41c002 100644 --- a/src/RamHardwareInformation.py +++ b/src/RamHardwareInformation.py @@ -56,7 +56,6 @@ def on_window1201w_delete_event(widget, event): def on_window1201w_show(widget): label1201w.set_text("-") # Reset label text when window is shown. - ram_hardware_information_get_func() # There are problems on Gnome desktop environment installed systems if this function is called from another module. global memory_hardware_information_text try: # "try-except" is used in order to avoid errors if user closed polkit dialog without entering password. Because "memory_hardware_information_text" string will not be defined and will not be get in this situation. label1201w.set_text(memory_hardware_information_text) # Set label text for showing RAM hardware information. @@ -82,7 +81,7 @@ def ram_hardware_information_get_func(): memory_hardware_information_text = "" # Set initial value of "memory_hardware_information_text". Hardware information will be appended to this string. try: - dmidecode_output = (subprocess.check_output(["pkexec", "sudo", "dmidecode", "-t", "16,17"], stderr=subprocess.STDOUT, shell=False)).decode().strip() # "sudo" has to be used for using "pkexec" to run "dmidecode" with root privileges. + dmidecode_output = (subprocess.check_output(["pkexec", "pkexec", "dmidecode", "-t", "16,17"], stderr=subprocess.STDOUT, shell=False)).decode().strip() # "sudo" has to be used for using "pkexec" to run "dmidecode" with root privileges. except: window1201w.hide() ram_hardware_information_root_privileges_warning_dialog()