fix use of new database for sendreport et al

This commit is contained in:
Enno Rehling 2018-10-09 19:40:26 +02:00
parent 3327e996e5
commit ef3ccc8d10
5 changed files with 30 additions and 11 deletions

1
.gitignore vendored
View File

@ -25,6 +25,7 @@ ipch/
*.user *.user
*~ *~
*.pyc
*.bak *.bak
bin/ bin/
build*/ build*/

View File

@ -1,7 +1,7 @@
install(PROGRAMS create-orders backup-eressea run-turn send-zip-report install(PROGRAMS create-orders backup-eressea run-turn send-zip-report
send-bz2-report compress.py compress.sh epasswd.py orders-process send-bz2-report compress.py compress.sh epasswd.py orders-process
process-orders.py accept-orders.py process-orders.py accept-orders.py getemail.py checkpasswd.py
checkpasswd.py sendreport.sh sendreports.sh orders-accept DESTINATION bin) sendreport.sh sendreports.sh orders-accept DESTINATION bin)
install(DIRECTORY cron/ DESTINATION bin USE_SOURCE_PERMISSIONS install(DIRECTORY cron/ DESTINATION bin USE_SOURCE_PERMISSIONS
FILES_MATCHING PATTERN "*.cron") FILES_MATCHING PATTERN "*.cron")

View File

@ -35,7 +35,7 @@ class EPasswd:
def __init__(self): def __init__(self):
self.data = {} self.data = {}
def set_data(no, email, passwd): def set_data(self, no, email, passwd):
lc_id = lower(no) lc_id = lower(no)
self.data[lc_id] = {} self.data[lc_id] = {}
self.data[lc_id]["id"] = no self.data[lc_id]["id"] = no

22
process/getemail.py Executable file
View File

@ -0,0 +1,22 @@
#!/usr/bin/env python
import sys, re
from epasswd import EPasswd
if len(sys.argv)<3:
sys.exit(-2)
filename=sys.argv[1]
myfaction=sys.argv[2]
pw_data = EPasswd()
try:
pw_data.load_database(filename)
except:
pw_data.load_file(filename)
if pw_data.fac_exists(myfaction):
email = pw_data.get_email(myfaction)
print(email)
sys.exit(0)
sys.exit(-1)

View File

@ -45,12 +45,8 @@ fi
bash "${FACTION}.sh" "$EMAIL" || reply "Unbekannte Partei $FACTION" bash "${FACTION}.sh" "$EMAIL" || reply "Unbekannte Partei $FACTION"
if [ -e "$ERESSEA/game-$GAME/eressea.db" ]; then OWNER=$(getfaction.py "$PWFILE" "$FACTION")
SQL="select email from faction f left join faction_data fd on fd.faction_id=f.id where f.game_id=$GAME AND fd.code='$FACTION' and fd.turn=(select max(turn) from faction_data fx where fx.faction_id=f.id)" if [ ! -z "$OWNER" ]; then
OWNER=$(sqlite3 "$ERESSEA/game-$GAME/eressea.db" "$SQL") echo "Der Report Deiner Partei wurde an ${EMAIL} gesandt." \
if [ ! -z "$OWNER" ]; then | mutt -s "Reportnachforderung Partei ${FACTION}" "$OWNER"
echo "Der Report Deiner Partei wurde an ${EMAIL} gesandt." \
| mutt -s "Reportnachforderung Partei ${FACTION}" "$OWNER"
fi
fi fi