You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
557 B
24 lines
557 B
2 years ago
|
#!/usr/bin/env python3
|
||
|
|
||
|
import argparse
|
||
|
from hra.util import hash_passwd
|
||
|
from sqlalchemy import exc, update
|
||
|
import sys
|
||
|
|
||
|
import hra.db as db
|
||
|
|
||
|
parser = argparse.ArgumentParser()
|
||
|
parser.add_argument("username", help="Username")
|
||
|
parser.add_argument("passwd", help="Password")
|
||
|
|
||
|
args = parser.parse_args()
|
||
|
|
||
|
u = db.User(org=True, username=args.username, passwd=hash_passwd(args.passwd))
|
||
|
try:
|
||
|
db.get_session().add(u)
|
||
|
db.get_session().commit()
|
||
|
except exc.IntegrityError:
|
||
|
print("Uživatelské jméno již existuje")
|
||
|
sys.exit(1)
|
||
|
print("Přidán nový uživatel.")
|