2002-03-24 12:53:58 +01:00
#!/usr/bin/env python
import MySQLdb
import sys
2002-04-18 02:49:22 +02:00
import string
from whrandom import choice
2002-03-24 12:53:58 +01:00
dbname = sys . argv [ 1 ]
maxnum = int ( sys . argv [ 2 ] )
2002-04-18 02:49:22 +02:00
game_id = 0 # eressea is game 0, tutorial is 1
2002-03-24 12:53:58 +01:00
2002-04-18 02:49:22 +02:00
def genpasswd ( ) :
newpasswd = " "
chars = string . letters + string . digits
for i in range ( 8 ) :
newpasswd = newpasswd + choice ( chars )
return newpasswd
2002-04-21 14:09:21 +02:00
query = " select distinct u.email, s.id, s.password, r.name, u.locale, s.bonus from users u, races r, subscriptions s left join userips i on u.id=i.user left join bannedips b on i.ip=b.ip where s.user=u.id and b.ip is NULL and s.status= ' CONFIRMED ' and r.race=s.race and s.game= " + str ( game_id ) + " and r.locale= ' de ' order by u.id "
2002-03-24 12:53:58 +01:00
db = MySQLdb . connect ( db = dbname )
cursor = db . cursor ( )
2002-04-18 02:49:22 +02:00
c = db . cursor ( )
2002-03-24 12:53:58 +01:00
num = cursor . execute ( query )
if num > maxnum :
num = maxnum
while num :
num = num - 1
2002-04-18 02:49:22 +02:00
email , sid , password , race , locale , bonus = cursor . fetchone ( )
2002-04-15 20:57:16 +02:00
if bonus == None :
bonus = 0
2002-04-18 02:49:22 +02:00
if password == None :
password = genpasswd ( )
c . execute ( " UPDATE subscriptions set password= ' " + password + " ' where id= " + str ( int ( sid ) ) )
2002-04-16 18:01:52 +02:00
print email + " " + race + " " + locale + " " + str ( int ( bonus ) ) + " " + password