-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSteamThread.py
66 lines (48 loc) · 1.69 KB
/
SteamThread.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# Import the core and GUI elements of Qt
from PyQt5.QtCore import QThread, pyqtSignal
import psutil
import os
from pathlib import Path
import subprocess
class SteamThread_launch(QThread):
# signal
noSteamPath = pyqtSignal()
def __init__(self, username, password):
QThread.__init__(self)
self.username = username
self.password = password
local_program_folder_path = os.path.normpath(
os.path.normpath(Path.home()) + "\AppData\Local\SteamAccountManager")
self.filename = os.path.join(local_program_folder_path, 'steam_path.txt')
self.steam_path = ""
self.load_steam_path_file()
def __del__(self):
self.wait()
def run(self):
if self.steam_path:
self.launch_steam(self.username, self.password)
else:
self.noSteamPath.emit()
self.exit(-1)
def launch_steam(self, login, password):
subprocess.run([self.steam_path, "-login", login, password], shell=False)
def load_steam_path_file(self):
try:
f = open(self.filename, "r+")
for line in f.readlines():
self.steam_path = line.replace('\n', '')
f.close()
except FileNotFoundError:
print("File Not Found Error !")
class SteamThread_shutdown(QThread):
def __init__(self):
QThread.__init__(self)
def __del__(self):
self.wait()
def run(self):
self.kill_steam()
def kill_steam(self):
PROCNAME = "Steam.exe"
for proc in psutil.process_iter():
if proc.name() == PROCNAME:
proc.terminate()