forked from lilydjwg/gaetalk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
usermaintainer.py
executable file
·40 lines (34 loc) · 964 Bytes
/
usermaintainer.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
#!/usr/bin/env python2
# vim:fileencoding=utf-8
import gaetalk
import logging
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
class Userdedup(webapp.RequestHandler):
def get(self):
users = {}
for u in gaetalk.User.all():
if u.jid in users:
users[u.jid].append(u)
else:
users[u.jid] = [u]
for k, v in users.items():
if len(v) == 1:
continue
v.sort(key=lambda u: gaetalk.STATUS_LIST.index(u.avail))
logging.error(' '.join([x.avail for x in v]))
for i in v[1:]:
l = gaetalk.Log(msg=u'删除重复用户', jid=i.jid,
nick=i.nick, type='misc')
l.put()
i.delete()
self.response.out.write(u'OK.'.encode('utf-8'))
application = webapp.WSGIApplication(
[
('/_admin/userdedup', Userdedup),
],
debug=True)
def main():
run_wsgi_app(application)
if __name__ == "__main__":
main()