2015-11-26 23:49:41 +03:00
|
|
|
import argparse
|
|
|
|
from hashlib import md5
|
2016-04-02 00:42:22 +03:00
|
|
|
from uuid import uuid4
|
|
|
|
|
|
|
|
from SWSCloudCore import models
|
2015-11-26 23:49:41 +03:00
|
|
|
|
|
|
|
__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).hexdigest()
|
|
|
|
|
|
|
|
if models.Admins.select().where(models.Admins.email == args.email).count() == 0:
|
|
|
|
models.Admins.create(id=admin_id, email=admin_email, password=admin_password, status=1)
|
|
|
|
else:
|
|
|
|
print "Admin account with email '%s' already exists." % admin_email
|