Kaydet (Commit) e7c66b6f authored tarafından Hakan Dündar's avatar Hakan Dündar

Fixed Processes tab right click menu bugs

üst 7381eaea
......@@ -76,12 +76,17 @@ def processes_custom_priority_gui_func():
if len(selected_process_name) == 15: # Linux kernel trims process names longer than 16 (TASK_COMM_LEN, see: https://man7.org/linux/man-pages/man5/proc.5.html) characters (it is counted as 15). "/proc/[PID]/cmdline/" file is read and it is split by the last "/" character (not all process cmdlines have this) in order to obtain full process name.
try:
with open("/proc/" + selected_process_pid + "/cmdline") as reader:
selected_process_name = reader.read().split("/")[-1].split("\x00")[0] # Some process names which are obtained from "cmdline" contain "\x00" and these are trimmed by using "split()".
except FileNotFoundError:
process_cmdline = reader.read()
selected_process_name = process_cmdline.split("/")[-1].split("\x00")[0] # Some process names which are obtained from "cmdline" contain "\x00" and these are trimmed by using "split()".
except FileNotFoundError: # Removed pid from "pid_list" and skip to next loop (pid) if process is ended just after pid_list is generated.
processes_no_such_process_error_dialog()
return
if selected_process_name.startswith(process_name_from_stat) == False:
selected_process_name = process_name_from_stat # Root access is needed for reading "cmdline" file of the some processes. Otherwise it gives "" as output. Process name from "stat" file of the process is used is this situation. Also process name from "stat" file is used if name from "cmdline" does not start with name from "stat" file.
selected_process_name = process_cmdline.split(" ")[0].split("\x00")[0].strip() # Some process names which are obtained from "cmdline" contain "\x00" and these are trimmed by using "split()".
if selected_process_name.startswith(process_name_from_stat) == False:
selected_process_name = process_cmdline.split("\x00")[0].split("/")[-1].strip()
if selected_process_name.startswith(process_name_from_stat) == False:
selected_process_name = process_name_from_stat # Root access is needed for reading "cmdline" file of the some processes. Otherwise it gives "" as output. Process name from "stat" file of the process is used is this situation. Also process name from "stat" file is used if name from "cmdline" does not start with name from "stat" file.
selected_process_nice = int(proc_pid_stat_lines_split[-34])
adjustment2101w2.configure(selected_process_nice, -20, 19, 1, 0, 0)
label2101w2.set_text(f'{selected_process_name} - (PID: {selected_process_pid})')
......@@ -92,17 +97,13 @@ def processes_custom_priority_gui_func():
def on_button2102w2_clicked(widget): # "Apply" button
processes_get_process_current_nice_func()
selected_process_nice = int(adjustment2101w2.get_value())
if selected_process_current_nice <= selected_process_nice:
(subprocess.check_output("renice -n " + str(selected_process_nice) + " -p " + selected_process_pid, shell=True).strip()).decode() # It gives "renice: failed to set priority for [PID] (process ID): Access denied" output if application is not run with root privileges.
if selected_process_current_nice > selected_process_nice:
try:
(subprocess.check_output("pkexec renice -n " + str(selected_process_nice) + " -p " + selected_process_pid, shell=True).strip()).decode() # It gives "renice: failed to set priority for [PID] (process ID): Access denied" output if application is not run with root privileges.
except subprocess.CalledProcessError:
processes_nice_error_dialog()
try:
(subprocess.check_output("renice -n " + str(selected_process_nice) + " -p " + selected_process_pid, shell=True).strip()).decode()
except subprocess.CalledProcessError:
(subprocess.check_output("pkexec renice -n " + str(selected_process_nice) + " -p " + selected_process_pid, shell=True).strip()).decode()
window2101w2.hide()
# Processes Custom Priority window GUI functions - connect
window2101w2.connect("delete-event", on_window2101w2_delete_event)
window2101w2.connect("show", on_window2101w2_show)
......
......@@ -369,7 +369,7 @@ def processes_tab_popover_set_gui():
checkbutton2123p.set_active(False)
# Set Processes tab customizations popover menu Precision/Data Units tab GUI object data/selections appropriate for settings
# Add CPU usage percent data into combobox
if "liststore2101p" not in globals(): # Check if "liststore2101p" is in global variables list (Python's own list = globals()) in order to prevent readdition of items to the listbox and combobox.
if "liststore2101p" not in globals(): # Check if "liststore2101p" is in global variables list (Python's own list = globals()) in order to prevent readdition of items to the listbox and combobox.
global liststore2101p
liststore2101p = Gtk.ListStore()
liststore2101p.set_column_types([str, int])
......
This diff is collapsed.
......@@ -334,7 +334,8 @@ def storage_tab_popover_set_gui():
checkbutton4124p.set_active(False)
# Set Storage tab customizations popover menu Precision/Data Units tab GUI object data/selections appropriate for settings
# Add Disk usage data precision into combobox
if "liststore4101p" not in globals(): # Check if "liststore4101p" is in global variables list (Python's own list = globals()) in order to prevent readdition of items to the listbox and combobox.
if "liststore4101p" not in globals(): # Check if "liststore4101p" is in global variables list (Python's own list = globals()) in order to prevent readdition of items to the listbox and combobox.
global liststore4101p
liststore4101p = Gtk.ListStore()
liststore4101p.set_column_types([str, int])
combobox4101p.set_model(liststore4101p)
......
......@@ -47,7 +47,7 @@
<property name="can-focus">False</property>
<child>
<object class="GtkImageMenuItem" id="menuitem2101m">
<property name="label" translatable="yes">Pause Process</property>
<property name="label" translatable="yes">Stop Process</property>
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="image">menuitem2101mimage</property>
......@@ -56,7 +56,7 @@
</child>
<child>
<object class="GtkImageMenuItem" id="menuitem2102m">
<property name="label" translatable="yes">Resume Process</property>
<property name="label" translatable="yes">Continue Process</property>
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="image">menuitem2102mimage</property>
......@@ -65,7 +65,7 @@
</child>
<child>
<object class="GtkImageMenuItem" id="menuitem2103m">
<property name="label" translatable="yes">End Prcocess</property>
<property name="label" translatable="yes">Terminate Process</property>
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="image">menuitem2103mimage</property>
......@@ -74,7 +74,7 @@
</child>
<child>
<object class="GtkImageMenuItem" id="menuitem2104m">
<property name="label" translatable="yes">End Process Tree</property>
<property name="label" translatable="yes">Kill Process</property>
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="image">menuitem2104mimage</property>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment