This repository has been archived by the owner on Jun 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
start.py
executable file
·89 lines (77 loc) · 2.61 KB
/
start.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/usr/bin/python
import sys
from subprocess import check_output, call
from multiprocessing import Process
from multiprocessing.connection import Client, Listener
import os
import random
version = 13
testMode = False
user = check_output(['whoami']).decode('utf-8')[:-1]
path = "/home/"+user+"/.var/app/com.nyaker.RyzenTuningUtility"
key = random.randint(0,999999999999999999)
connAddress = ('localhost', 6001)
address = ('localhost', 6000)
def start(verbose):
try :
conn = Client(connAddress, authkey=bytes('open/close', 'ascii'))
conn.send('OPEN')
conn.close()
except :
if user == 'root':
print('do not run as root please, passwd will be asked next')
else :
daemon_proc = Process(target=startDaemon, args=(verbose,))
gui_proc = Process(target=startGui, args=(verbose,))
daemon_proc.start()
gui_proc.start()
daemon_proc.join()
gui_proc.join()
def startDaemon(verbose):
if testMode:
code = call((python, path + '/daemon/RyzenTuningDaemon.py', str(key), user, verbose))
else:
code = call(('pkexec', python, path + '/daemon/RyzenTuningDaemon.py', str(key), user, verbose))
if code == 126:
call(('zenity', '--error', '--text', 'PLEASE RESTART OR CLOSE RYZEN TUNING UTILITY (KILL DAEMON)'))
listener = Listener(address, authkey=bytes(str(key), 'ascii'))
conn = listener.accept()
running = True
while running:
while conn.poll():
msg = conn.recv()
if msg == "EXIT":
running = False
else:
conn.send("EXIT")
def startGui(verbose):
call((python, path + '/gui/RyzenTuningUtility.py', str(key), user, verbose))
if os.path.exists("/usr/bin/python"):
python = "python"
elif os.path.exists("/usr/bin/python3"):
python = "python3"
else:
print("=============== python not found ===============")
print("Your distro is not currently supported, you can still try to modify the script, please report the problem in github")
exit(1)
try :
arg = sys.argv[1]
if arg == "version":
print(version)
elif arg == "test":
print("Entering Test Mode")
testMode = True
start("0")
elif arg == "log":
try:
subarg = int(sys.argv[2])
except:
print("Invalid argument")
else:
if subarg in range(1, 4):
start(str(subarg))
else :
print(sys.argv)
except Exception as e:
print(e)
start("0")