Skip to content

Commit 5479e00

Browse files
committed
Significantly improved speed of process check, maybe helped AV
1 parent ab4c372 commit 5479e00

2 files changed

Lines changed: 24 additions & 19 deletions

File tree

generateexe.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
pyinstaller --windowed --onefile --name Virtual_Desktop_Body_Tracking_Configurator main.py
1+
pyinstaller --windowed --onefile --name Virtual_Desktop_Body_Tracking_Configurator main.py

main.py

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,31 @@
44
import psutil
55
import qdarktheme
66
import os
7+
import subprocess
78

89

10+
def process_exists(process_name):
11+
call = 'TASKLIST', '/FI', 'imagename eq %s' % process_name
12+
# use buildin check_output right away
13+
output = subprocess.check_output(call).decode()
14+
# check in last line for process name
15+
last_line = output.strip().split('\r\n')[-1]
16+
# because Fail message could be translated
17+
return last_line.lower().startswith(process_name.lower())
918

1019
class MainWindow(QMainWindow):
1120
def __init__(self):
1221
super().__init__()
1322

1423
self.setWindowTitle("Virtual Desktop Body Tracking Configurator")
1524

16-
for proc in psutil.process_iter(['name']):
17-
if "vrserver.exe" in proc.info['name'].lower():
18-
dlg2 = QMessageBox()
19-
dlg2.setWindowTitle("Virtual Desktop Body Tracking Configurator")
20-
dlg2.setText("Error!\n\nvrserver.exe running!\n\nPlease close SteamVR and try again")
21-
dlg2.exec()
22-
if QMessageBox.StandardButton.Ok:
23-
exit()
25+
if process_exists("vrserver.exe"):
26+
dlg2 = QMessageBox()
27+
dlg2.setWindowTitle("Virtual Desktop Body Tracking Configurator")
28+
dlg2.setText("Error!\n\nvrserver.exe running!\n\nPlease close SteamVR and try again")
29+
dlg2.exec()
30+
if QMessageBox.StandardButton.Ok:
31+
exit()
2432

2533
self.steam = ""
2634
try:
@@ -309,16 +317,13 @@ def load_settings_clicked(self):
309317

310318
def export_clicked(self):
311319

312-
for proc in psutil.process_iter(['name']):
313-
if "vrserver.exe" in proc.info['name'].lower():
314-
dlg2 = QMessageBox()
315-
dlg2.setWindowTitle("Virtual Desktop Body Tracking Configurator")
316-
dlg2.setText("Error!\n\nvrserver.exe running!\n\nPlease close SteamVR and try again")
317-
318-
dlg2.exec()
319-
320-
if QMessageBox.StandardButton.Ok:
321-
exit()
320+
if process_exists("vrserver.exe"):
321+
dlg2 = QMessageBox()
322+
dlg2.setWindowTitle("Virtual Desktop Body Tracking Configurator")
323+
dlg2.setText("Error!\n\nvrserver.exe running!\n\nPlease close SteamVR and try again")
324+
dlg2.exec()
325+
if QMessageBox.StandardButton.Ok:
326+
exit()
322327

323328

324329
#print("Export clicked")

0 commit comments

Comments
 (0)