-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_online_users.py
54 lines (42 loc) · 1.36 KB
/
get_online_users.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
#!/usr/bin/env python
# -*- coding: utf-8
# ThePirateWhoSmellsOfSunflowers - https://github.com/ThePirateWhoSmellsOfSunflowers
import Ice
import sys
iceslice = "/usr/share/Ice/slice/Murmur.ice"
iceincludepath = "/usr/share/Ice/slice"
icehost = "127.0.0.1"
iceport = 6502
icesecret = "SheSellsSeashellsOnTheSeeShore"
messagesizemax = "65535"
Ice.loadSlice("--all -I%s %s" % (iceincludepath, iceslice))
props = Ice.createProperties([])
props.setProperty("Ice.MessageSizeMax", str(messagesizemax))
props.setProperty("Ice.ImplicitContext", "Shared")
props.setProperty("Ice.Default.EncodingVersion", "1.0")
id = Ice.InitializationData()
id.properties = props
ice = Ice.initialize(id)
ice.getImplicitContext().put("secret", icesecret)
import Murmur
try:
meta = Murmur.MetaPrx.checkedCast(ice.stringToProxy("Meta:tcp -h %s -p %s" % (icehost, iceport)))
except Ice.ConnectionRefusedException:
print 'Could not connect'
ice.shutdown()
sys.exit(1)
try:
server=meta.getServer(1)
except Murmur.InvalidSecretException:
print 'Ice password is wrong.'
ice.shutdown()
sys.exit(1)
#Get users
onlineusers = server.getUsers()
if len(onlineusers) == 0:
print "No user connected"
sys.exit(0)
print "Users list :"
for key in onlineusers.keys():
print "\t" + onlineusers[key].name + (" (Mute)" if onlineusers[key].selfMute == True else "")
ice.shutdown()