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

update files

üst b9c32c07
Package: system-monitoring-center
Version: 0.1.2-beta
Architecture: amd64
Maintainer: Hakan Dündar <hakandundar34coding@gmail.com>
Installed-Size: 3025
Depends: python3 (>= 3.7), python3-gi, python3-opengl, util-linux, mesa-utils, systemd
Section: utils
Priority: optional
Homepage: https://kod.pardus.org.tr/Hakan/system-monitoring-center
Description: Provides information about system performance and usage.
Provides information about CPU/RAM/Disk/Network/GPU performance, sensors, processes, users, storage, startup programs, services, environment variables and system.
system-monitoring-center (0.1.2-beta) unstable; urgency=medium
[ Hakan Dündar ]
* Implementations of functions for General Settings window
* Removed unnecessary commandline functions which are used for getting hardware information.
* 0 Byte values are shown as 0 B instead of 0.00 B.
* Menus longer than size of the main window are redesigned because they were trimmed on some systems.
* Various bug fixes
* Error handling improvements
* Minor translation updates
* Some code changes for easier code readability
* Removed unused code
-- Hakan Dündar <hakandundar34coding@gmail.com> Mon, 08 Sep 2021 17:35:00 +0300
system-monitoring-center (0.1.1-beta) unstable; urgency=medium
[ Hakan Dündar ]
* Changed default settings for more user friendly view.
* Changed some GTK GUI object properties which were deprecated.
* Various bug fixes
* Minor translation updates
-- Hakan Dündar <hakandundar34coding@gmail.com> Mon, 06 Sep 2021 20:44:00 +0300
system-monitoring-center (0.1.0-beta) unstable; urgency=medium
[ Hakan Dündar ]
* Initial commit
-- Hakan Dündar <hakandundar34coding@gmail.com> Sun, 05 Sep 2021 17:10:00 +0300
\ No newline at end of file
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: system-monitoring-center
Source: https://kod.pardus.org.tr/Hakan/system-monitoring-center
Files: *
Copyright: 2021 Hakan Dündar <hakandundar34coding@gmail.com>
License: GPL-3.0+
License: GPL-3.0+
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
.
This package is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
.
On Debian systems, the complete text of the GNU General
Public License version 3 can be found in "/usr/share/common-licenses/GPL-3".
......@@ -11,5 +11,5 @@ Terminal=false
Type=Application
Categories=Settings;System;
StartupNotify=true
Keywords=system monitor;center;performance;speed;frequency;cpu usage;ram usage;swap memory;memory usage;storage;network usage;download speed;fps;frame ratio;processes;users;startup programs;services;environment variables;shell variables;os;
Keywords[tr]=sistem gözlemcisi;performans;hız;frekans;cpu;mib;ram kullanımı;takas belleği;bellek kullanımı;depolama;indirme hızı;fps;kare oranı;işlemler;kullanıcılar;başlangıç programları;servisler;ortam değişkenleri;kabuk değişkenleri;os;is;
Keywords=system monitor;task manager;center;performance;speed;frequency;cpu usage;ram usage;swap memory;memory usage;storage;network usage;download speed;fps;frame ratio;processes;users;startup programs;services;environment variables;shell variables;os;
Keywords[tr]=sistem gözlemcisi;görev yöneticisi;performans;hız;frekans;cpu;mib;ram kullanımı;takas belleği;bellek kullanımı;depolama;indirme hızı;fps;kare oranı;işlemler;kullanıcılar;başlangıç programları;servisler;ortam değişkenleri;kabuk değişkenleri;os;is;
......@@ -266,7 +266,7 @@ def on_drawingarea1301_draw(drawingarea1301, chart1301):
chart1301_y_limit = 1.1 * ((max(max(disk_read_speed), max(disk_write_speed))) + 0.0000001)
if Config.plot_disk_read_speed == 1 and Config.plot_disk_write_speed == 0:
chart1301_y_limit = 1.1 * (max(disk_read_speed) + 0.0000001)
if Config.plot_disk_read_speed == 1 and Config.plot_disk_write_speed == 0:
if Config.plot_disk_read_speed == 0 and Config.plot_disk_write_speed == 1:
chart1301_y_limit = 1.1 * (max(disk_write_speed) + 0.0000001)
chart1301.set_dash([], 0)
......@@ -370,7 +370,7 @@ def on_drawingarea1401_draw(drawingarea1401, chart1401):
chart1401_y_limit = 1.1 * ((max(max(network_receive_speed), max(network_send_speed))) + 0.0000001)
if Config.plot_network_download_speed == 1 and Config.plot_network_upload_speed == 0:
chart1401_y_limit = 1.1 * (max(network_receive_speed) + 0.0000001)
if Config.plot_network_download_speed == 1 and Config.plot_network_upload_speed == 0:
if Config.plot_network_download_speed == 0 and Config.plot_network_upload_speed == 1:
chart1401_y_limit = 1.1 * (max(network_send_speed) + 0.0000001)
chart1401.set_dash([], 0)
......
This diff is collapsed.
......@@ -498,6 +498,11 @@ def performance_foreground_initial_func():
cpu_architecture = "-"
# Set CPU tab label texts by using information get
show_cpu_usage_per_core = Config.show_cpu_usage_per_core
if show_cpu_usage_per_core == 0:
PerformanceGUI.label1113.set_text(_tr("CPU Usage % (Average):"))
if show_cpu_usage_per_core == 1:
PerformanceGUI.label1113.set_text(_tr("CPU Usage % (Per Core):"))
PerformanceGUI.label1101.set_text(cpu_model_names[selected_cpu_core_number])
# PerformanceGUI.label1102.set_text(f'Selected CPU Core: {selected_cpu_core}')
PerformanceGUI.label1102.set_text(_tr("Selected CPU Core: ") + selected_cpu_core)
......@@ -732,10 +737,11 @@ def performance_foreground_initial_func():
def performance_foreground_func():
# Update performance data on the headerbar
ChartPlots.drawingarea101.queue_draw()
ChartPlots.drawingarea102.queue_draw()
MainGUI.label101.set_text(f'{performance_data_unit_converter_func((disk_read_speed[selected_disk_number][-1] + disk_write_speed[selected_disk_number][-1]), 0, 0)}/s')
MainGUI.label102.set_text(f'{performance_data_unit_converter_func((network_receive_speed[selected_network_card_number][-1] + network_send_speed[selected_network_card_number][-1]), 0, 0)}/s')
if Config.performance_summary_on_the_headerbar == 1: # Perform the following operations if "performance_summary_on_the_headerbar" preference is enabled by the user.
ChartPlots.drawingarea101.queue_draw()
ChartPlots.drawingarea102.queue_draw()
MainGUI.label101.set_text(f'{performance_data_unit_converter_func((disk_read_speed[selected_disk_number][-1] + disk_write_speed[selected_disk_number][-1]), 0, 0)}/s')
MainGUI.label102.set_text(f'{performance_data_unit_converter_func((network_receive_speed[selected_network_card_number][-1] + network_send_speed[selected_network_card_number][-1]), 0, 0)}/s')
# Update CPU tab data on the GUI
if PerformanceGUI.radiobutton1001.get_active() == True: # Check if CPU tab is selected.
......@@ -1045,18 +1051,23 @@ def performance_define_data_unit_converter_variables_func():
# ----------------------------------- Performance - Data Unit Converter Function (converts byte and bit data units) -----------------------------------
def performance_data_unit_converter_func(data, unit, precision):
global data_unit_list
if isinstance(data, str) is True:
return data
if unit >= 8:
data = data * 8
data = data * 8 # Source data is byte and a convertion is made by multiplicating with 8 if preferenced unit is bit.
if unit == 0 or unit == 8:
unit_counter = unit + 1 # Source data is byte and a convertion is made by multiplicating with 8 if preferenced unit is bit.
unit_counter = unit + 1
while data > 1024:
unit_counter = unit_counter + 1
data = data/1024
unit = data_unit_list[unit_counter][2]
if data == 0:
precision = 0
return f'{data:.{precision}f} {unit}'
data = data / data_unit_list[unit][1]
unit = data_unit_list[unit][2]
if data == 0:
precision = 0
return f'{data:.{precision}f} {unit}'
......@@ -20,12 +20,12 @@ def performance_gui_func():
# Performance tab GUI objects
global stack1001
global radiobutton1001, radiobutton1002, radiobutton1003, radiobutton1004, radiobutton1005, radiobutton1006, radiobutton1007, radiobutton1008
global radiobutton1001, radiobutton1002, radiobutton1003, radiobutton1004, radiobutton1005, radiobutton1006
global grid1001, grid1002, grid1003, grid1004, grid1005, grid1006, grid1007, grid1008
# CPU tab GUI objects
global button1101, label1101, label1102
global label1103, label1104, label1105, label1106, label1107, label1108, label1109, label1110, label1111, label1112
global label1103, label1104, label1105, label1106, label1107, label1108, label1109, label1110, label1111, label1112, label1113
global grid1101
# RAM tab GUI objects
......@@ -59,8 +59,6 @@ def performance_gui_func():
radiobutton1004 = MainGUI.builder.get_object('radiobutton1004')
radiobutton1005 = MainGUI.builder.get_object('radiobutton1005')
radiobutton1006 = MainGUI.builder.get_object('radiobutton1006')
radiobutton1007 = MainGUI.builder.get_object('radiobutton1007')
radiobutton1008 = MainGUI.builder.get_object('radiobutton1008')
grid1001 = MainGUI.builder.get_object('grid1001')
grid1002 = MainGUI.builder.get_object('grid1002')
grid1003 = MainGUI.builder.get_object('grid1003')
......@@ -84,6 +82,7 @@ def performance_gui_func():
label1110 = MainGUI.builder.get_object('label1110')
label1111 = MainGUI.builder.get_object('label1111')
label1112 = MainGUI.builder.get_object('label1112')
label1113 = MainGUI.builder.get_object('label1113')
grid1101 = MainGUI.builder.get_object('grid1101')
# RAM tab GUI objects - get
......@@ -163,61 +162,48 @@ def performance_gui_func():
def on_radiobutton1001_toggled(widget):
if radiobutton1001.get_active() == True:
performance_gui_function_run_func()
MainGUI.main_gui_main_function_run_func()
def on_radiobutton1002_toggled(widget):
if radiobutton1002.get_active() == True:
performance_gui_function_run_func()
MainGUI.main_gui_main_function_run_func()
def on_radiobutton1003_toggled(widget):
if radiobutton1003.get_active() == True:
performance_gui_function_run_func()
MainGUI.main_gui_main_function_run_func()
def on_radiobutton1004_toggled(widget):
if radiobutton1004.get_active() == True:
performance_gui_function_run_func()
MainGUI.main_gui_main_function_run_func()
def on_radiobutton1005_toggled(widget):
if radiobutton1005.get_active() == True:
performance_gui_function_run_func()
MainGUI.main_gui_main_function_run_func()
def on_radiobutton1006_toggled(widget):
if radiobutton1006.get_active() == True:
performance_gui_function_run_func()
def on_radiobutton1007_toggled(widget):
if radiobutton1007.get_active() == True:
performance_gui_function_run_func()
def on_radiobutton1008_toggled(widget):
if radiobutton1008.get_active() == True:
performance_gui_function_run_func()
MainGUI.main_gui_main_function_run_func()
# CPU tab GUI functions
def on_button1101_clicked(widget):
PerformanceMenusGUI.cpu_tab_popover_set_gui() # Apply settings on the CPU tab popover GUI before showing it
PerformanceMenusGUI.popover1101p.popup() # Show CPU tab popover GUI
# RAM tab GUI functions
def on_button1201_clicked(widget):
PerformanceMenusGUI.ram_tab_popover_set_gui() # Apply settings on the RAM tab popover GUI before showing it
PerformanceMenusGUI.popover1201p.popup() # Show RAM tab popover GUI
# Disk tab GUI functions
def on_button1301_clicked(widget):
PerformanceMenusGUI.disk_tab_popover_set_gui() # Apply settings on the Disk tab popover GUI before showing it
PerformanceMenusGUI.popover1301p.popup() # Show Disk tab popover GUI
# Network tab GUI functions
def on_button1401_clicked(widget):
PerformanceMenusGUI.network_tab_popover_set_gui() # Apply settings on the Network tab popover GUI before showing it
PerformanceMenusGUI.popover1401p.popup() # Show Network tab popover GUI
# GPU tab GUI functions
def on_button1501_clicked(widget):
Performance.performance_get_gpu_list_and_set_selected_gpu_func() # Get gpu/graphics card list and set selected gpu
PerformanceMenusGUI.gpu_tab_popover_set_gui() # Apply settings on the GPU tab popover GUI before showing it
Performance.performance_get_gpu_list_and_set_selected_gpu_func() # Get gpu/graphics card list and set selected gpu
PerformanceMenusGUI.popover1501p.popup() # Show GPU tab popover GUI
# Sensors tab GUI functions
......@@ -282,32 +268,3 @@ def performance_gui_func():
treeview1601.set_enable_search(True) # This command is used for searching by pressing on a key on keyboard or by using "Ctrl + F" shortcut.
treeview1601.set_search_column(2) # This command used for searching by using entry.
treeview1601.set_tooltip_column(2)
# ----------------------------------- Performance - Performance Functions Run Function (runs functions (CPU, RAM, Disk, Network, GPU, Sensors) when their stack page is selected) -----------------------------------
def performance_gui_function_run_func():
MainGUI.main_gui_main_function_run_func()
return
if radiobutton1001.get_active() == True:
stack1001.set_visible_child(grid1001)
if radiobutton1002.get_active() == True:
stack1001.set_visible_child(grid1002)
if radiobutton1003.get_active() == True:
stack1001.set_visible_child(grid1003)
if radiobutton1004.get_active() == True:
stack1001.set_visible_child(grid1004)
if radiobutton1005.get_active() == True:
stack1001.set_visible_child(grid1005)
if radiobutton1006.get_active() == True:
stack1001.set_visible_child(grid1006)
import Sensors
Sensors.sensors_import_func()
Sensors.sensors_thread_run_func()
Performance.performance_foreground_initial_func()
This diff is collapsed.
......@@ -705,14 +705,20 @@ def processes_define_data_unit_converter_variables_func():
def processes_data_unit_converter_func(data, unit, precision):
global data_unit_list
if unit >= 8:
data = data * 8 # Source data is byte and a convertion is made by multiplicating with 8 if preferenced unit is bit.
if unit == 0 or unit == 8:
unit_counter = unit + 1
while data > 1024:
unit_counter = unit_counter + 1
data = data/1024
unit = data_unit_list[unit_counter][2]
if data == 0:
precision = 0
return f'{data:.{precision}f} {unit}'
data = data / data_unit_list[unit][1]
unit = data_unit_list[unit][2]
if data == 0:
precision = 0
return f'{data:.{precision}f} {unit}'
......@@ -226,7 +226,7 @@ def process_details_foreground_func():
ProcessesDetailsGUI.label2106w.set_text(f'{selected_process_cpu_percent:.{processes_cpu_usage_percent_precision}f} %')
ProcessesDetailsGUI.label2107w.set_text(f'{processes_details_data_unit_converter_func(selected_process_memory_rss, processes_ram_swap_data_unit, processes_ram_swap_data_precision)}')
if selected_process_read_bytes != "-" and selected_process_write_bytes != "-":
ProcessesDetailsGUI.label2108w.set_text(f'{processes_details_data_speed_unit_converter_func(selected_process_read_speed, processes_disk_speed_data_unit, processes_disk_speed_data_precision)} / {processes_details_data_speed_unit_converter_func(selected_process_write_speed, processes_disk_speed_data_unit, processes_disk_speed_data_precision)}')
ProcessesDetailsGUI.label2108w.set_text(f'{processes_details_data_unit_converter_func(selected_process_read_speed, processes_disk_speed_data_unit, processes_disk_speed_data_precision)} / {processes_details_data_unit_converter_func(selected_process_write_speed, processes_disk_speed_data_unit, processes_disk_speed_data_precision)}')
if selected_process_read_bytes == "-" and selected_process_write_bytes == "-":
ProcessesDetailsGUI.label2108w.set_text("- / -")
ProcessesDetailsGUI.label2109w.set_text(datetime.fromtimestamp(selected_process_start_time).strftime("%d.%m.%Y %H:%M:%S"))
......@@ -398,8 +398,8 @@ def process_details_foreground_func():
selected_process_open_files = "-"
# Set label text by using process data
if selected_process_read_bytes != "-" and selected_process_write_bytes != "-":
ProcessesDetailsGUI.label2128w.set_text(f'{processes_details_data_speed_unit_converter_func(selected_process_read_speed, processes_disk_speed_data_unit, processes_disk_speed_data_precision)}')
ProcessesDetailsGUI.label2129w.set_text(f'{processes_details_data_speed_unit_converter_func(selected_process_write_speed, processes_disk_speed_data_unit, processes_disk_speed_data_precision)}')
ProcessesDetailsGUI.label2128w.set_text(f'{processes_details_data_unit_converter_func(selected_process_read_speed, processes_disk_speed_data_unit, processes_disk_speed_data_precision)}')
ProcessesDetailsGUI.label2129w.set_text(f'{processes_details_data_unit_converter_func(selected_process_write_speed, processes_disk_speed_data_unit, processes_disk_speed_data_precision)}')
ProcessesDetailsGUI.label2130w.set_text(f'{processes_details_data_unit_converter_func(selected_process_read_bytes, processes_disk_speed_data_unit, processes_disk_speed_data_precision)}')
ProcessesDetailsGUI.label2131w.set_text(f'{processes_details_data_unit_converter_func(selected_process_write_bytes, processes_disk_speed_data_unit, processes_disk_speed_data_precision)}')
ProcessesDetailsGUI.label2132w.set_text(f'{selected_process_read_count}')
......@@ -474,53 +474,36 @@ def process_details_foreground_thread_run_func():
# ----------------------------------- Processes - Processes Details Define Data Unit Converter Variables Function (contains data unit variables) -----------------------------------
def processes_details_define_data_unit_converter_variables_func():
global data_unit_list, data_speed_unit_list
global data_unit_list
# Calculated values are used in order to obtain faster code run, because this function will be called very frequently.
# For the details of the calculation, see "Data_unit_conversion.ods." document.
# Calculated values are used in order to obtain faster code run, because this function will be called very frequently. For the details of the calculation, see "Data_unit_conversion.ods." document.
data_unit_list = [[0, 0, "Auto-Byte"], [1, 1, "B"], [2, 1024, "KiB"], [3, 1.04858E+06, "MiB"], [4, 1.07374E+09, "GiB"],
data_unit_list = [[0, 0, _tr("Auto-Byte")], [1, 1, "B"], [2, 1024, "KiB"], [3, 1.04858E+06, "MiB"], [4, 1.07374E+09, "GiB"],
[5, 1.09951E+12, "TiB"], [6, 1.12590E+15, "PiB"], [7, 1.15292E+18, "EiB"],
[8, 0, "Auto-bit"], [9, 8, "b"], [10, 8192, "Kib"], [11, 8.38861E+06, "Mib"], [12, 8.58993E+09, "Gib"],
[8, 0, _tr("Auto-bit")], [9, 8, "b"], [10, 8192, "Kib"], [11, 8.38861E+06, "Mib"], [12, 8.58993E+09, "Gib"],
[13, 8.79609E+12, "Tib"], [14, 9.00720E+15, "Pib"], [15, 9.22337E+18, "Eib"]]
data_speed_unit_list = [[0, 0, "Auto-Byte/s"], [1, 1, "B/s"], [2, 1024, "KiB/s"], [3, 1.04858E+06, "MiB/s"], [4, 1.07374E+09, "GiB/s"],
[5, 1.09951E+12, "TiB/s"], [6, 1.12590E+15, "PiB/s"], [7, 1.15292E+18, "EiB/s"],
[8, 0, "Auto-bit/s"], [9, 8, "b"], [10, 8192, "Kib/s"], [11, 8.38861E+06, "Mib/s"], [12, 8.58993E+09, "Gib/s"],
[13, 8.79609E+12, "Tib/s"], [14, 9.00720E+15, "Pib/s"], [15, 9.22337E+18, "Eib/s"]]
# ----------------------------------- Processes - Processes Details Data Unit Converter Function (converts byte and bit data units) -----------------------------------
def processes_details_data_unit_converter_func(data, unit, precision):
global data_unit_list
if unit >= 8:
data = data * 8 # Source data is byte and a convertion is made by multiplicating with 8 if preferenced unit is bit.
if unit == 0 or unit == 8:
unit_counter = unit + 1
while data > 1024:
unit_counter = unit_counter + 1
data = data/1024
unit = data_unit_list[unit_counter][2]
if data == 0:
precision = 0
return f'{data:.{precision}f} {unit}'
data = data / data_unit_list[unit][1]
unit = data_unit_list[unit][2]
return f'{data:.{precision}f} {unit}'
# ----------------------------------- Processes - Processes Details Data Speed Unit Converter Function (converts byte and bit data speed units) -----------------------------------
def processes_details_data_speed_unit_converter_func(data, unit, precision):
global data_speed_unit_list
if unit == 0 or unit == 8:
unit_counter = unit + 1
while data > 1024:
unit_counter = unit_counter + 1
data = data/1024
unit = data_speed_unit_list[unit_counter][2]
return f'{data:.{precision}f} {unit}'
data = data / data_speed_unit_list[unit][1]
unit = data_speed_unit_list[unit][2]
if data == 0:
precision = 0
return f'{data:.{precision}f} {unit}'
......
......@@ -807,7 +807,7 @@ def processes_nice_error_dialog():
error_dialog2101.destroy()
# ----------------------------------- Processes - Processes End Process Warning Dialog Function (shows an warning dialog a process is tried to be end) -----------------------------------
# ----------------------------------- Processes - Processes End Process Warning Dialog Function (shows an warning dialog when a process is tried to be end) -----------------------------------
def processes_end_process_warning_dialog(process_name, process_pid):
warning_dialog2101 = Gtk.MessageDialog(transient_for=MainGUI.window1, title=_tr("Warning"), flags=0, message_type=Gtk.MessageType.WARNING,
......@@ -818,7 +818,7 @@ def processes_end_process_warning_dialog(process_name, process_pid):
warning_dialog2101.destroy()
# ----------------------------------- Processes - Processes End Process Tree Warning Dialog Function (shows an warning dialog a process is tried to be end) -----------------------------------
# ----------------------------------- Processes - Processes End Process Tree Warning Dialog Function (shows an warning dialog when a process tree is tried to be end) -----------------------------------
def processes_end_process_tree_warning_dialog(process_name, process_pid):
warning_dialog2102 = Gtk.MessageDialog(transient_for=MainGUI.window1, title=_tr("Warning"), flags=0, message_type=Gtk.MessageType.WARNING,
......
......@@ -243,16 +243,22 @@ def services_define_data_unit_converter_variables_func():
def services_details_data_unit_converter_func(data, unit, precision):
global data_unit_list
if unit >= 8:
data = data * 8 # Source data is byte and a convertion is made by multiplicating with 8 if preferenced unit is bit.
if unit == 0 or unit == 8:
unit_counter = unit + 1
while data > 1024:
unit_counter = unit_counter + 1
data = data/1024
unit = data_unit_list[unit_counter][2]
if data == 0:
precision = 0
return f'{data:.{precision}f} {unit}'
data = data / data_unit_list[unit][1]
unit = data_unit_list[unit][2]
if data == 0:
precision = 0
return f'{data:.{precision}f} {unit}'
......
This diff is collapsed.
......@@ -223,8 +223,8 @@ def storage_loop_func():
# Get disk total size
if 6 in storage_treeview_columns_shown:
with open("/sys/class/block/" + disk + "/size") as reader:
disk_size = int(reader.read()) * disk_sector_size
storage_data_row.append(disk_size)
disk_total_size = int(reader.read()) * disk_sector_size
storage_data_row.append(disk_total_size)
# Get disk free space
if 7 in storage_treeview_columns_shown:
if disk_mount_point != _tr("[Not mounted]"):
......@@ -750,6 +750,9 @@ def storage_treeview_column_order_width_row_sorting_func():
def storage_define_data_unit_converter_variables_func():
global data_unit_list
# Calculated values are used in order to obtain faster code run, because this function will be called very frequently. For the details of the calculation, see "Data_unit_conversion.ods." document.
data_unit_list = [[0, 0, _tr("Auto-Byte")], [1, 1, "B"], [2, 1024, "KiB"], [3, 1.04858E+06, "MiB"], [4, 1.07374E+09, "GiB"],
[5, 1.09951E+12, "TiB"], [6, 1.12590E+15, "PiB"], [7, 1.15292E+18, "EiB"],
[8, 0, _tr("Auto-bit")], [9, 8, "b"], [10, 8192, "Kib"], [11, 8.38861E+06, "Mib"], [12, 8.58993E+09, "Gib"],
......@@ -760,14 +763,20 @@ def storage_define_data_unit_converter_variables_func():
def storage_data_unit_converter_func(data, unit, precision):
global data_unit_list
if unit >= 8:
data = data * 8 # Source data is byte and a convertion is made by multiplicating with 8 if preferenced unit is bit.
if unit == 0 or unit == 8:
unit_counter = unit + 1
while data > 1024:
unit_counter = unit_counter + 1
data = data/1024
unit = data_unit_list[unit_counter][2]
if data == 0:
precision = 0
return f'{data:.{precision}f} {unit}'
data = data / data_unit_list[unit][1]
unit = data_unit_list[unit][2]
if data == 0:
precision = 0
return f'{data:.{precision}f} {unit}'
......@@ -154,7 +154,7 @@ def storage_details_foreground_func():
# Get disk total size
try:
with open("/sys/class/block/" + disk + "/size") as reader:
disk_size = int(reader.read()) * disk_sector_size
disk_total_size = int(reader.read()) * disk_sector_size
except FileNotFoundError:
StorageDetailsGUI.window4101w.hide()
storage_no_such_storage_error_dialog()
......@@ -168,6 +168,7 @@ def storage_details_foreground_func():
else:
disk_available = -9999 # "-9999" value is used as "disk_available" value if disk is not mounted. Code will recognize this valu e and show "[Not mounted]" information in this situation.
except:
StorageDetailsGUI.window4101w.hide()
storage_no_such_storage_error_dialog()
return
# Get disk used space
......@@ -175,11 +176,13 @@ def storage_details_foreground_func():
if disk_mount_point != _tr("[Not mounted]"):
statvfs_disk_usage_values = os.statvfs(disk_mount_point)
fragment_size = statvfs_disk_usage_values.f_frsize
disk_size = statvfs_disk_usage_values.f_blocks * fragment_size
disk_free = statvfs_disk_usage_values.f_bfree * fragment_size
disk_used = disk_size - disk_free
else:
disk_used = -9999 # "-9999" value is used as "disk_used" value if disk is not mounted. Code will recognize this valu e and show "[Not mounted]" information in this situation.
except:
StorageDetailsGUI.window4101w.hide()
storage_no_such_storage_error_dialog()
return
# Get disk used space percentage
......@@ -196,6 +199,7 @@ def storage_details_foreground_func():
else:
disk_usage_percent = -9999 # "-9999" value is used as "disk_usage_percent" value if disk is not mounted. Code will recognize this valu e and show "[Not mounted]" information in this situation.
except:
StorageDetailsGUI.window4101w.hide()
storage_no_such_storage_error_dialog()
return
# Get disk vendor and model
......@@ -342,7 +346,7 @@ def storage_details_foreground_func():
StorageDetailsGUI.label4104w.set_text(disk_type)
StorageDetailsGUI.label4105w.set_text(disk_transport_type)
StorageDetailsGUI.label4106w.set_text(disk_file_system)
StorageDetailsGUI.label4107w.set_text(f'{storage_data_unit_converter_func(disk_size, storage_disk_usage_data_unit, storage_disk_usage_data_precision)}')
StorageDetailsGUI.label4107w.set_text(f'{storage_data_unit_converter_func(disk_total_size, storage_disk_usage_data_unit, storage_disk_usage_data_precision)}')
if disk_available == -9999:
StorageDetailsGUI.label4108w.set_text(_tr("[Not mounted]"))
StorageDetailsGUI.label4109w.set_text(_tr("[Not mounted]"))
......@@ -389,6 +393,9 @@ def storage_details_foreground_thread_run_func():
def storage_define_data_unit_converter_variables_func():
global data_unit_list
# Calculated values are used in order to obtain faster code run, because this function will be called very frequently. For the details of the calculation, see "Data_unit_conversion.ods." document.
data_unit_list = [[0, 0, _tr("Auto-Byte")], [1, 1, "B"], [2, 1024, "KiB"], [3, 1.04858E+06, "MiB"], [4, 1.07374E+09, "GiB"],
[5, 1.09951E+12, "TiB"], [6, 1.12590E+15, "PiB"], [7, 1.15292E+18, "EiB"],
[8, 0, _tr("Auto-bit")], [9, 8, "b"], [10, 8192, "Kib"], [11, 8.38861E+06, "Mib"], [12, 8.58993E+09, "Gib"],
......@@ -399,16 +406,22 @@ def storage_define_data_unit_converter_variables_func():
def storage_data_unit_converter_func(data, unit, precision):
global data_unit_list
if unit >= 8:
data = data * 8 # Source data is byte and a convertion is made by multiplicating with 8 if preferenced unit is bit.
if unit == 0 or unit == 8:
unit_counter = unit + 1
while data > 1024:
unit_counter = unit_counter + 1
data = data/1024
unit = data_unit_list[unit_counter][2]
if data == 0:
precision = 0
return f'{data:.{precision}f} {unit}'
data = data / data_unit_list[unit][1]
unit = data_unit_list[unit][2]
if data == 0:
precision = 0
return f'{data:.{precision}f} {unit}'
......
......@@ -585,6 +585,9 @@ def users_treeview_column_order_width_row_sorting_func():
def users_define_data_unit_converter_variables_func():
global data_unit_list
# Calculated values are used in order to obtain faster code run, because this function will be called very frequently. For the details of the calculation, see "Data_unit_conversion.ods." document.
data_unit_list = [[0, 0, _tr("Auto-Byte")], [1, 1, "B"], [2, 1024, "KiB"], [3, 1.04858E+06, "MiB"], [4, 1.07374E+09, "GiB"],
[5, 1.09951E+12, "TiB"], [6, 1.12590E+15, "PiB"], [7, 1.15292E+18, "EiB"],
[8, 0, _tr("Auto-bit")], [9, 8, "b"], [10, 8192, "Kib"], [11, 8.38861E+06, "Mib"], [12, 8.58993E+09, "Gib"],
......@@ -595,14 +598,20 @@ def users_define_data_unit_converter_variables_func():
def users_data_unit_converter_func(data, unit, precision):
global data_unit_list
if unit >= 8:
data = data * 8 # Source data is byte and a convertion is made by multiplicating with 8 if preferenced unit is bit.
if unit == 0 or unit == 8:
unit_counter = unit + 1
while data > 1024:
unit_counter = unit_counter + 1
data = data/1024
unit = data_unit_list[unit_counter][2]
if data == 0:
precision = 0
return f'{data:.{precision}f} {unit}'
data = data / data_unit_list[unit][1]
unit = data_unit_list[unit][2]
if data == 0:
precision = 0
return f'{data:.{precision}f} {unit}'
0.1.1-beta
\ No newline at end of file
0.1.2-beta
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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