-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtools.py
48 lines (32 loc) · 1.28 KB
/
tools.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
import subprocess
import objects
#call a cmd
def runCmd(cmd):
ret=""
p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
for line in p.stdout.readlines():
p.wait()
ret+=line.decode("utf-8")
return ret[:-1]#cut \n
#get all registered users
def read_Registered_UsersV2():
mRegistered_users=[]
query= "sqlite3 /var/lib/mumble-server/mumble-server.sqlite 'SELECT name, lastchannel,last_active FROM users'"
p = subprocess.Popen(query, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
for line in p.stdout.readlines():
p.wait()
line=line[:-1]#cut \n at the end
line_array= str.split(line.decode('utf-8'),'|')#decode byte to str
new_user = objects.User(line_array[0],line_array[1],line_array[2],0)
mRegistered_users.append(new_user)
return mRegistered_users
def read_channels():
channels={}
query= "sqlite3 /var/lib/mumble-server/mumble-server.sqlite 'SELECT channel_id,name FROM channels'"
p = subprocess.Popen(query, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
for line in p.stdout.readlines():
p.wait()
line=line[:-1]#cut \n at the end
line_array= str.split(line.decode('utf-8'),'|')#decode byte to string
channels[line_array[0]]=line_array[1]
return channels