Browse Source

if exists utf8 string name user found can't syncdb and more action

because DBus/Ice don't same charset DBus is unicode Ice is UTF-8
Natenom/support-murmur-13-1446181288462
withgod 16 years ago
parent
commit
424859c488
  1. 21
      pyweb/mumble/MumbleCtlIce.py
  2. 11
      pyweb/mumble/mctl.py

21
pyweb/mumble/MumbleCtlIce.py

@ -43,7 +43,7 @@ class MumbleCtlIce(MumbleCtlBase):
ret = [] ret = []
for user in users: for user in users:
ret.append([user.playerid, unicode(user.name), unicode(user.email), unicode(user.pw)])
ret.append([user.playerid, MumbleCtlIce.setUnicodeFlag(user.name), MumbleCtlIce.setUnicodeFlag(user.email), MumbleCtlIce.setUnicodeFlag(user.pw)])
return ret return ret
@ -53,7 +53,7 @@ class MumbleCtlIce(MumbleCtlBase):
for x in chans: for x in chans:
chan = chans[x] chan = chans[x]
ret.append([chan.id, unicode(chan.name), chan.parent, chan.links])
ret.append([chan.id, MumbleCtlIce.setUnicodeFlag(chan.name), chan.parent, chan.links])
return ret return ret
@ -63,7 +63,7 @@ class MumbleCtlIce(MumbleCtlBase):
for x in users: for x in users:
user = users[x] user = users[x]
ret.append([user.session, user.mute, user.deaf, user.suppressed, user.selfMute, user.selfDeaf, user.channel, user.playerid, unicode(user.name), user.onlinesecs, user.bytespersec])
ret.append([user.session, user.mute, user.deaf, user.suppressed, user.selfMute, user.selfDeaf, user.channel, user.playerid, MumbleCtlIce.setUnicodeFlag(user.name), user.onlinesecs, user.bytespersec])
return ret return ret
@ -76,9 +76,9 @@ class MumbleCtlIce(MumbleCtlBase):
tmp = [] tmp = []
for y in x: for y in x:
if y.__class__ is Murmur.ACL: if y.__class__ is Murmur.ACL:
tmp.append([y.applyHere, y.applySubs, y.inherited, y.playerid, unicode(y.group), y.allow, y.deny])
tmp.append([y.applyHere, y.applySubs, y.inherited, y.playerid, MumbleCtlIce.setUnicodeFlag(y.group), y.allow, y.deny])
elif y.__class__ is Murmur.Group: elif y.__class__ is Murmur.Group:
tmp.append([unicode(y.name), y.inherited, y.inherit, y.inheritable, y.add, y.remove, y.members])
tmp.append([MumbleCtlIce.setUnicodeFlag(y.name), y.inherited, y.inherit, y.inheritable, y.add, y.remove, y.members])
ret.append(tmp) ret.append(tmp)
else: else:
@ -202,8 +202,13 @@ class MumbleCtlIce(MumbleCtlBase):
@staticmethod @staticmethod
def setUnicodeFlag(data): def setUnicodeFlag(data):
ret = {}
for key in data.keys():
ret[unicode(key)] = unicode(data[key])
ret = ''
if isinstance(data, tuple) or isinstance(data, list) or isinstance(data, dict):
ret = {}
for key in data.keys():
ret[MumbleCtlIce.setUnicodeFlag(key)] = MumbleCtlIce.setUnicodeFlag(data[key])
else:
ret = unicode(data, 'utf-8')
return ret return ret

11
pyweb/mumble/mctl.py

@ -97,7 +97,6 @@ if __name__ == "__main__":
x = int(sys.argv[1]) x = int(sys.argv[1])
dbusCtl = MumbleCtlDbus() dbusCtl = MumbleCtlDbus()
iceCtl = MumbleCtlIce() iceCtl = MumbleCtlIce()
"""
print "equal test ---" print "equal test ---"
print "getBootedServers [%s]" % (dbusCtl.getBootedServers() == iceCtl.getBootedServers()) print "getBootedServers [%s]" % (dbusCtl.getBootedServers() == iceCtl.getBootedServers())
print "getChannels [%s]" % (dbusCtl.getChannels(x) == iceCtl.getChannels(x)) print "getChannels [%s]" % (dbusCtl.getChannels(x) == iceCtl.getChannels(x))
@ -106,9 +105,11 @@ if __name__ == "__main__":
print "getAllServers [%s]" % (dbusCtl.getAllServers() == iceCtl.getAllServers()) print "getAllServers [%s]" % (dbusCtl.getAllServers() == iceCtl.getAllServers())
print "getDefaultConf [%s]" % (dbusCtl.getDefaultConf() == iceCtl.getDefaultConf()) print "getDefaultConf [%s]" % (dbusCtl.getDefaultConf() == iceCtl.getDefaultConf())
print "getAllConf(x) [%s]" % (dbusCtl.getAllConf(x) == iceCtl.getAllConf(x)) print "getAllConf(x) [%s]" % (dbusCtl.getAllConf(x) == iceCtl.getAllConf(x))
print dbusCtl.getRegisteredPlayers(x)
#print dbusCtl.getRegisteredPlayers(x)[3][1]
print iceCtl.getRegisteredPlayers(x)
#print iceCtl.getRegisteredPlayers(x)[3][1]
print "getRegisteredPlayers(x) [%s]" % (dbusCtl.getRegisteredPlayers(x) == iceCtl.getRegisteredPlayers(x)) print "getRegisteredPlayers(x) [%s]" % (dbusCtl.getRegisteredPlayers(x) == iceCtl.getRegisteredPlayers(x))
print "getTexture(2, 30) [%s]" % (dbusCtl.getTexture(2, 30) == iceCtl.getTexture(2, 30))
"""
dbusCtl.getTexture(2, 30).__class__
iceCtl.getTexture(2, 30).__class__
#print "getTexture(2, 30) [%s]" % (dbusCtl.getTexture(2, 30) == iceCtl.getTexture(2, 30))
#print dbusCtl.getTexture(2, 30).__class__ #print dbusCtl.getTexture(2, 30).__class__
Loading…
Cancel
Save