zat-skript fixes

This commit is contained in:
Enno Rehling 2002-03-17 17:19:10 +00:00
parent d1e574877a
commit dcb6b789d6
3 changed files with 24 additions and 16 deletions

View File

@ -130,8 +130,8 @@ else:
cursor.execute("INSERT INTO users (firstname, lastname, email, address, city, phone, country, password) "+ cursor.execute("INSERT INTO users (firstname, lastname, email, address, city, phone, country, password) "+
"VALUES ('"+firstname+"', '"+lastname+"', '"+email+"', '"+address+"', '"+city+"', '"+phone+"', "+country+", '"+genpasswd()+"')") "VALUES ('"+firstname+"', '"+lastname+"', '"+email+"', '"+address+"', '"+city+"', '"+phone+"', "+country+", '"+genpasswd()+"')")
cursor.execute("SELECT LAST_INSERT_ID() from dual") cursor.execute("SELECT LAST_INSERT_ID() from dual")
userid=str(int(cursor.fetchone()[0])) userid=str(int(cursor.fetchone()[0]))
cursor.execute("INSERT INTO subscriptions (user, game, status) "+ cursor.execute("INSERT INTO subscriptions (user, game, status) "+
"VALUES ("+str(userid)+", 3, 'WAITING')") "VALUES ("+str(userid)+", 3, 'WAITING')")

View File

@ -5,6 +5,9 @@ import smtplib
From='accounts@vinyambar.de' From='accounts@vinyambar.de'
dbname=sys.argv[1] dbname=sys.argv[1]
dryrun=0
if len(sys.argv)>2:
dryrun=1
price=1.25 price=1.25
warnahead=2 warnahead=2
db=MySQLdb.connect(db=dbname) db=MySQLdb.connect(db=dbname)
@ -35,7 +38,8 @@ while users > 0:
"BLZ 500 502 01 (Frankfurter Sparkasse)\n") "BLZ 500 502 01 (Frankfurter Sparkasse)\n")
try: try:
# print Msg # print Msg
server.sendmail(From, email, Msg) if dryrun==0:
server.sendmail(From, email, Msg)
except: except:
print "Could not send confirmation to "+email print "Could not send confirmation to "+email
print "Exception is:", sys.exc_type, ":", sys.exc_value print "Exception is:", sys.exc_type, ":", sys.exc_value

View File

@ -17,26 +17,30 @@ if k==0:
print "Unbekanntes Spiel" print "Unbekanntes Spiel"
name, patch = cursor.fetchone() 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." 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." 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." print "Removing "+str(int(k))+" dead subscriptions."
k = cursor.execute("SELECT max(lastturn) from subscriptions"); k = cursor.execute("UPDATE subscriptions SET status='CANCELLED' where game="+str(int(game))+" and status='ACTIVE' and lastturn+3<="+str(lastturn))
lastturn = int(cursor.fetchone()[0]) print "Cancelling "+str(int(k))+" active subscriptions with 3+ NMRs."
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("SELECT users.id FROM users, subscriptions WHERE users.id=subscriptions.user and subscriptions.status='ACTIVE' and subscriptions.game="+str(game)) 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: while k!=0: