-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.py
More file actions
executable file
·36 lines (26 loc) · 790 Bytes
/
Copy pathcli.py
File metadata and controls
executable file
·36 lines (26 loc) · 790 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env python3
from argparse import ArgumentParser
from getpass import getpass
from web import db
from models.user import User
parser = ArgumentParser()
parser.add_argument('--create-admin', help='Create an admin account.',
action='store_true')
args = parser.parse_args()
if not args.create_admin:
print('error: no action')
exit(0)
if args.create_admin:
username = input('Username: ')
password = getpass('Password: ')
password2 = getpass('Repeat password: ')
if password != password2:
print('error: passwords do not match')
exit(1)
user = User()
user.username = username
user.set_password(password)
db.session.add(user)
db.session.commit()
print('admin account was created.')
exit(0)