skript update, vereinfachung

This commit is contained in:
Enno Rehling 2002-03-14 19:30:11 +00:00
parent ab43bf92e2
commit fed21e8d06
2 changed files with 23 additions and 20 deletions

View File

@ -11,37 +11,42 @@ From="accounts@vinyambar.de"
server=smtplib.SMTP('localhost') server=smtplib.SMTP('localhost')
cursor=db.cursor() cursor=db.cursor()
records=cursor.execute("SELECT u.id, u.password, u.email, "+ records=cursor.execute("SELECT u.id, u.password, u.email "+
"races.name, "+ "from users u "+
"games.name, games.info, subscriptions.id "+ "where u.status='NEW'")
"from users u, games, subscriptions, races "+
"where u.id = subscriptions.user AND games.id = subscriptions.game "+
"AND races.race = subscriptions.race AND races.locale='de' "+
"AND subscriptions.status='NEW'")
while (records>0): while records>0:
records = records - 1 records = records - 1
customerid, passwd, email, race, gamename, gameinfo, subscription = cursor.fetchone() customerid, passwd, email = cursor.fetchone()
Msg = ("From: "+From+"\nTo: "+email+"\nSubject: Vinyambar Anmeldung angenommen.\n\n"+ Msg = ("From: "+From+"\nTo: "+email+"\nSubject: Vinyambar Anmeldung angenommen.\n\n"+
"Deine Anmeldung für '"+gamename+"' wurde akzeptiert.\n" "Deine Anmeldung für Vinyambar wurde akzeptiert.\n"
"\n"+ "\n"+
gameinfo +"\n"+
"Kundennummer: " + str(int(customerid)) + "\n"+ "Kundennummer: " + str(int(customerid)) + "\n"+
"Auftragsnummer: " + str(int(subscription)) + "\n"+
"Passwort: " + passwd + "\n" + "Passwort: " + passwd + "\n" +
"Rasse: " + race + "\n\n"+ "\n" +
"Bitte bewahre diese Mail sorgfältig auf, da Du deine Kundennummer und das\n"+ "Bitte bewahre diese Mail sorgfältig auf, da Du deine Kundennummer und das\n"+
"Passwort für das Spiel benötigst. Solltest Du noch Fragen zu Deiner \n"+ "Passwort für das Spiel benötigst. Solltest Du noch Fragen zu Deiner \n"+
"Anmeldung haben, wende Dich bitte an accounts@vinyambar.de.\n\n"+ "Anmeldung haben, wende Dich bitte an accounts@vinyambar.de.\n" +
"\n"+
"Die Kundennummer gib bitte bei der Überweisung der Spielgebühren an. \n" +
"Unsere Kontoinformationen lauten:\n" +
" Katja Zedel\n"+
" Kontonummer 1251 886 106 \n"+
" BLZ 500 502 01 (Frankfurter Sparkasse)\n" +
"\n"+
"Zugang zu deinem Konto erhältst Du mit dem Passowrt auf der Webseite\n"+
" http://www.vinyambar.de/accounts.shtml\n"+
"\n"+
"Das Vinyambar-Team") "Das Vinyambar-Team")
try: try:
server.sendmail(From, email, Msg) server.sendmail(From, email, Msg)
print "Sent confirmation to "+email+" for "+gamename+"." print "Sent confirmation to "+email+"."
update=db.cursor() update=db.cursor()
update.execute("UPDATE subscriptions set status='CONFIRMED' WHERE id="+ update.execute("UPDATE users set status='CONFIRMED' WHERE id="+
str(int(subscription))); str(int(customerid)));
except: except:
print "Could not send Error to "+email print "Could not send Error to "+email
print "Reason was: '"+Reason+"'" print "Reason was: '"+Reason+"'"
print "Exception is:", sys.exc_type, ":", sys.exc_value print "Exception is:", sys.exc_type, ":", sys.exc_value
sys.exit()

View File

@ -61,9 +61,7 @@ if len(sys.argv)>4:
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
cursor.execute("select count(*) from users u, transactions t where u.id=t.user group by u.id having sum(t.balance)!=0.0")
count = cursor.fetchone()[0]
cursor.execute("select sum(transactions.balance) from transactions") cursor.execute("select sum(transactions.balance) from transactions")
balance = cursor.fetchone()[0] balance = cursor.fetchone()[0]
print str(balance)+ " EUR (" + str(balance*1.955830)+ " DEM) in " + str(int(count)) + " Konten" print str(balance)+ " EUR (" + str(balance*1.955830)+ " DEM)"