25 lines
		
	
	
	
		
			639 B
		
	
	
	
		
			Python
		
	
	
		
			Executable file
		
	
	
	
	
			
		
		
	
	
			25 lines
		
	
	
	
		
			639 B
		
	
	
	
		
			Python
		
	
	
		
			Executable file
		
	
	
	
	
| #!/usr/bin/env python3
 | |
| 
 | |
| import argparse
 | |
| from hra.util import hash_passwd
 | |
| from sqlalchemy import exc, update
 | |
| import sys
 | |
| 
 | |
| import hra.db as db
 | |
| import hra.lib as lib
 | |
| 
 | |
| parser = argparse.ArgumentParser()
 | |
| parser.add_argument("username", help="Username")
 | |
| parser.add_argument("passwd", help="Password")
 | |
| parser.add_argument("--org", help="Přidělí org prává", action='store_true')
 | |
| 
 | |
| args = parser.parse_args()
 | |
| 
 | |
| try:
 | |
|     u = lib.create_user(args.username, args.passwd, org=args.org)
 | |
| except lib.UsernameExist:
 | |
|    print("Uživatelské jméno již existuje")
 | |
|    sys.exit(1)
 | |
| db.get_session().commit()
 | |
| print("Přidán nový uživatel.")
 | |
| print(u.token)
 |