server/process/getfaction.py

33 lines
594 B
Python
Raw Normal View History

2019-01-20 02:48:14 +01:00
#!/usr/bin/env python
import sys, re
from epasswd import EPasswd
2019-01-20 03:06:33 +01:00
if len(sys.argv)<3:
2019-01-20 02:48:14 +01:00
sys.exit(-2)
filename=sys.argv[1]
myfaction=sys.argv[2]
quiet=len(sys.argv)<=3
def log(str):
if not quiet:
print(str)
pw_data = EPasswd()
try:
pw_data.load_database(filename)
log("loaded from db " + filename)
except:
pw_data.load_file(filename)
log("loaded from file " + filename)
if pw_data.fac_exists(myfaction):
print(pw_data.get_email(myfaction))
2019-01-20 03:06:33 +01:00
log("faction found: " + myfaction)
2019-01-20 02:48:14 +01:00
sys.exit(0)
else:
log("faction missing: " + myfaction)
sys.exit(-1)