清理 app.yaml 及对应的文件
[gaetalk.git] / usermaintainer.py
blob230c02782bddeb2da7c52a7e34ab18e69aaba678
1 #!/usr/bin/env python2
2 # vim:fileencoding=utf-8
4 import lilytalk
5 import logging
6 from google.appengine.ext import webapp
7 from google.appengine.ext.webapp.util import run_wsgi_app
9 class Userdedup(webapp.RequestHandler):
10 def get(self):
11 users = {}
12 for u in lilytalk.User.all():
13 if u.jid in users:
14 users[u.jid].append(u)
15 else:
16 users[u.jid] = [u]
17 for k, v in users.items():
18 if len(v) == 1:
19 continue
20 v.sort(key=lambda u: lilytalk.STATUS_LIST.index(u.avail))
21 logging.error(' '.join([x.avail for x in v]))
22 for i in v[1:]:
23 l = lilytalk.Log(msg=u'删除重复用户', jid=i.jid,
24 nick=i.nick, type='misc')
25 l.put()
26 i.delete()
27 self.response.out.write(u'OK.'.encode('utf-8'))
29 application = webapp.WSGIApplication(
31 ('/_admin/userdedup', Userdedup),
33 debug=True)
35 def main():
36 run_wsgi_app(application)
38 if __name__ == "__main__":
39 main()