-
Notifications
You must be signed in to change notification settings - Fork 0
/
reset8080.py
41 lines (36 loc) · 999 Bytes
/
reset8080.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
import subprocess
import os
from threading import Thread
import time
def ossT(msg):
os.system(msg)
# print("############################")
# print("############################")
print("############################")
print(msg)
print("############################")
# print("############################")
# print("############################")
def oss(msg):
t = Thread(target = ossT, args = [msg,])
t.start()
# print("@@@@@@@@@@@")
proc = ""
try:
proc = subprocess.check_output("lsof -i:8080", shell=True);
except:
pass
# print("@@@@@@@@@@@")
if len(str(proc).split("\\n"))>=2:
# print("@@@@@@@@@@@")
line = str(proc).split("\\n")[1]
while(" " in line):
line = line.replace(" "," ")
line = line.split(" ")
print(line)
if "python" in line[0].lower() or "sams" in line[0].lower():
oss("kill "+line[1])
# xproc = subprocess.check_output("kill "+line[1], shell=True);
print("CLOSED PREVIOUS PROC",line[1],":::::::::::")#,xproc)
time.sleep(1)
# print("@@@@@@@@@@@#")