Skip to content
This repository was archived by the owner on Sep 4, 2025. It is now read-only.

Commit 337e1f6

Browse files
author
Raven
committed
Update code for consistency across Raven software
1 parent 5f568ee commit 337e1f6

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

resmon.py

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
""" Import the necessary modules for the program to work """
12
import sys
23
import os
34
import psutil
@@ -11,8 +12,9 @@
1112
QTableWidget, QHeaderView, QSplitter, QTableWidgetItem, QLabel, QTextBrowser, QTabWidget, QProgressBar
1213
)
1314

14-
prevDrive = None
1515

16+
17+
""" Function to load the CSS style for the program """
1618
def loadStyle():
1719
user_css_path = os.path.join(os.path.expanduser("~"), "rmstyle.css")
1820
stylesheet = None
@@ -39,6 +41,9 @@ def loadStyle():
3941
else:
4042
print("No QApplication instance found. Stylesheet not applied.")
4143

44+
45+
46+
""" Thread for fetching the processes """
4247
class ProcessFetcher(QThread):
4348
update_processes = pyqtSignal(list)
4449
update_stats = pyqtSignal(float, float, str)
@@ -70,6 +75,9 @@ def run(self):
7075
self.update_stats.emit(cpu_usage, memory_info.percent, disk_display)
7176
self.update_drives.emit(psutil.disk_partitions())
7277

78+
79+
80+
""" Dialog for displaying System Information """
7381
class SystemInfoDialog(QDialog):
7482
def __init__(self, parent=None):
7583
super().__init__(parent)
@@ -82,7 +90,7 @@ def __init__(self, parent=None):
8290

8391
def display_system_info(self):
8492
try:
85-
process = subprocess.Popen("systeminfo", stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, shell=True)
93+
process = subprocess.Popen("systeminfo", stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True, encoding="mbcs")
8694
stdout, stderr = process.communicate()
8795
if process.returncode == 0:
8896
self.info_browser.setPlainText(stdout)
@@ -91,13 +99,17 @@ def display_system_info(self):
9199
except Exception as e:
92100
self.info_browser.setPlainText(f"An error occurred: {str(e)}")
93101

102+
103+
104+
""" Main class for the program """
94105
class Resmon(QMainWindow):
95106
def __init__(self):
96107
super().__init__()
97108
self.setWindowTitle("Resmon")
98109
self.setGeometry(100, 100, 770, 700)
99110
self.always_on_top = False
100111
self.selected_pid = None
112+
self.prev_drive = None
101113
self.init_ui()
102114
self.fetcher = ProcessFetcher()
103115
self.fetcher.update_processes.connect(self.update_process_table)
@@ -227,10 +239,9 @@ def update_process_table(self, process_data):
227239
self.process_table.selectRow(row_to_select)
228240

229241
def update_drives(self, drive_data):
230-
global prevDrive
231-
if drive_data == prevDrive:
242+
if drive_data == self.prev_drive:
232243
return
233-
prevDrive = drive_data
244+
self.prev_drive = drive_data
234245
disks = drive_data
235246
for i in reversed(range(self.disk_tab_layout.count())):
236247
self.disk_tab_layout.itemAt(i).widget().setParent(None)
@@ -347,6 +358,9 @@ def view_system_info(self):
347358
dialog = SystemInfoDialog(self)
348359
dialog.exec_()
349360

361+
362+
363+
""" Dialog for starting a process """
350364
class StartProcessDialog(QDialog):
351365
def __init__(self, parent=None):
352366
super().__init__(parent)

0 commit comments

Comments
 (0)