-
Notifications
You must be signed in to change notification settings - Fork 2
/
stop.py
executable file
·81 lines (63 loc) · 2.2 KB
/
stop.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
#!/usr/bin/env python
from subprocess import Popen, PIPE, STDOUT
import os
services = {
'python framework/services/input/mic.py':'Mic Service',
'python skills/system_skills/skill_volume.py':'Volume Skill',
'python skills/system_skills/skill_alarm.py':'Alarm Skill',
'python skills/system_skills/skill_fallback.py':'SVA Fallback Skill',
'python skill_system.py':'SVA System Skill',
'python skills/system_skills/skill_media.py':'SVA Media Skill',
'python framework/services/output/media_player.py':'Media Player Service',
'python framework/services/intent/intent.py':'Intent Service',
'python framework/services/stt/stt.py':'STT Service',
'python framework/services/tts/tts.py':'TTS Service',
'python3 -m mimic3':'Local TTS Engine',
'python server.py':'Local STT Service',
'MsgBus':'Message Bus',
}
def kill_service(svc):
end_indx = line.find(" ",3)
pid = line[0:end_indx].strip()
os.system("kill %s" % (pid,))
print("%s - Killed %s" % (pid,services[svc]))
# kill user skills first
cmd = 'ps a'
p = Popen(cmd, shell=True, stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True)
output = p.stdout.read()
output = output.decode("utf-8")
print("Kill user skills ...")
lines = output.split("\n")
for line in lines:
if line.find("python __init__.py") > -1:
la = line.split(" ")
pid = la[0].strip()
try:
pid = int( pid )
except:
pid = 0
if pid == 0:
pid = la[1].strip()
try:
pid = int( pid )
except:
pid = 0
if pid == 0:
pid = la[2].strip()
try:
pid = int( pid )
except:
pid = 0
if pid == 0:
pid = la[3].strip()
cmd = "kill %s" % (pid,)
os.system(cmd)
# next kill services
print("Kill system skills and services ...")
lines = output.split("\n")
for line in lines:
for service in services:
if line.find(service) > -1:
kill_service(service)
# clear temp dirs save_audio, save_text and save_tts here!
# last resort