30 lines
891 B
Python
Executable file
30 lines
891 B
Python
Executable file
#!/usr/bin/env python
|
|
|
|
import argparse
|
|
from hashlib import md5
|
|
from uuid import uuid4
|
|
|
|
from SWSCloudCore import models
|
|
|
|
__author__ = 'vanzhiganov'
|
|
|
|
|
|
parser = argparse.ArgumentParser(description='')
|
|
parser.add_argument('--email', dest="email")
|
|
parser.add_argument('--password', dest="password")
|
|
|
|
args = parser.parse_args()
|
|
|
|
admin_id = uuid4()
|
|
# todo: validate admin email
|
|
admin_email = args.email
|
|
admin_password = md5(args.password.encode()).hexdigest()
|
|
|
|
if models.Admins.select().where(models.Admins.email == args.email).count() == 0:
|
|
print("Admin account with email '%s' not exists." % admin_email)
|
|
print('---')
|
|
print('For create a new admin account use command "procdn-admin-add --email <email> --password <password>"')
|
|
else:
|
|
query = models.Admins.update(password=admin_password).where(models.Admins.email == admin_email)
|
|
query.execute()
|
|
print('Password updated.')
|