From dcb6b789d69ef6d2819df5f9b97028c3e2b19a87 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 17 Mar 2002 17:19:10 +0000 Subject: [PATCH] zat-skript fixes --- scripts/register/register.py | 4 ++-- scripts/register/warn.py | 6 +++++- scripts/register/zat.py | 30 +++++++++++++++++------------- 3 files changed, 24 insertions(+), 16 deletions(-) diff --git a/scripts/register/register.py b/scripts/register/register.py index 9b57cdf14..e26ca4a11 100755 --- a/scripts/register/register.py +++ b/scripts/register/register.py @@ -130,8 +130,8 @@ else: cursor.execute("INSERT INTO users (firstname, lastname, email, address, city, phone, country, password) "+ "VALUES ('"+firstname+"', '"+lastname+"', '"+email+"', '"+address+"', '"+city+"', '"+phone+"', "+country+", '"+genpasswd()+"')") - cursor.execute("SELECT LAST_INSERT_ID() from dual") - userid=str(int(cursor.fetchone()[0])) + cursor.execute("SELECT LAST_INSERT_ID() from dual") + userid=str(int(cursor.fetchone()[0])) cursor.execute("INSERT INTO subscriptions (user, game, status) "+ "VALUES ("+str(userid)+", 3, 'WAITING')") diff --git a/scripts/register/warn.py b/scripts/register/warn.py index 802655464..27c7f0eda 100755 --- a/scripts/register/warn.py +++ b/scripts/register/warn.py @@ -5,6 +5,9 @@ import smtplib From='accounts@vinyambar.de' dbname=sys.argv[1] +dryrun=0 +if len(sys.argv)>2: + dryrun=1 price=1.25 warnahead=2 db=MySQLdb.connect(db=dbname) @@ -35,7 +38,8 @@ while users > 0: "BLZ 500 502 01 (Frankfurter Sparkasse)\n") try: # print Msg - server.sendmail(From, email, Msg) + if dryrun==0: + server.sendmail(From, email, Msg) except: print "Could not send confirmation to "+email print "Exception is:", sys.exc_type, ":", sys.exc_value diff --git a/scripts/register/zat.py b/scripts/register/zat.py index 4fa2d3757..1344ddac2 100755 --- a/scripts/register/zat.py +++ b/scripts/register/zat.py @@ -17,26 +17,30 @@ if k==0: print "Unbekanntes Spiel" name, patch = cursor.fetchone() -print "Auswertung für " + name + " Patch Level " + str(int(patch)) -while os.access(patchdir+'/patch-'+str(int(patch+1))+'.sql', os.F_OK)==0: - patch=patch+1 - os.system('mysql --table ' + dbname + '-e ' + patchdir+'/patch-'+str(int(patch+1))+'.sql') - cursor.execute('update games set patch='+str(int(patch))+' where game='+str(game)) -k = cursor.execute("UPDATE subscriptions SET user=NULL where status='TRANSFERED' and updated<'"+date+"'" +os.system("mysqldump vinyambar > backup-vinyambar-"+str(int(patch))+".sql") + +k = cursor.execute("SELECT max(lastturn) from subscriptions") +lastturn = int(cursor.fetchone()[0]) + +print "Auswertung für " + name + " Patch Level " + str(int(patch)) + ", Runde "+str(lastturn) +while os.access(patchdir+'/patch-'+str(int(patch+1))+'.sql', os.F_OK): + patch=patch+1 + print " Patching to level "+str(patch) + os.system('mysql ' + dbname + ' < ' + patchdir+'/patch-'+str(int(patch))+'.sql') + cursor.execute('update games set patch='+str(int(patch))+' where id='+str(game)) + +k = cursor.execute("UPDATE subscriptions SET user=0 where game="+str(int(game))+" and status='TRANSFERED' and updated<'"+date+"'") print "Removing "+str(int(k))+" transfered subscriptions." -k = cursor.execute("UPDATE subscriptions SET user=NULL where status='CANCELLED' and updated<'"+date+"'" +k = cursor.execute("UPDATE subscriptions SET user=0 where game="+str(int(game))+" and status='CANCELLED' and updated<'"+date+"'") print "Removing "+str(int(k))+" cancelled subscriptions." -k = cursor.execute("UPDATE subscriptions SET user=NULL where status='DEAD' and updated<'"+date+"'" +k = cursor.execute("UPDATE subscriptions SET user=0 where game="+str(int(game))+" and status='DEAD' and updated<'"+date+"'") print "Removing "+str(int(k))+" dead subscriptions." -k = cursor.execute("SELECT max(lastturn) from subscriptions"); -lastturn = int(cursor.fetchone()[0]) -k = cursor.execute("UPDATE subscriptions SET status='CANCELLED' where lastturn+3<="+str(lastturn) -k = cursor.execute("UPDATE subscriptions SET status='CANCELLED' where NMR>2" -print "Cancelling "+str(int(k))+" subscriptions with 3+ NMRs." +k = cursor.execute("UPDATE subscriptions SET status='CANCELLED' where game="+str(int(game))+" and status='ACTIVE' and lastturn+3<="+str(lastturn)) +print "Cancelling "+str(int(k))+" active subscriptions with 3+ NMRs." k = cursor.execute("SELECT users.id FROM users, subscriptions WHERE users.id=subscriptions.user and subscriptions.status='ACTIVE' and subscriptions.game="+str(game)) while k!=0: