-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript_command.py
More file actions
46 lines (38 loc) · 1.22 KB
/
Copy pathscript_command.py
File metadata and controls
46 lines (38 loc) · 1.22 KB
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
37
38
39
40
41
42
43
44
45
46
# coding=utf-8
"""
@author: kaaokou
"""
import random
from datetime import datetime
from flask import current_app
from flask_script import Command
from models import AdminInfo, db
class SuperAdminCommand(Command):
"""创建管理员类"""
def run(self):
"""重写的run方法"""
mobile = input("请输入管理员用户名:")
pwd = input("请输入管理员密码:")
if AdminInfo.query.filter_by(mobile=mobile).count() > 0:
print("管理员%s已存在" % mobile)
return
user = AdminInfo()
user.mobile = mobile
user.nick_name = mobile
user.password = pwd
user.isAdmin = True
try:
db.session.add(user)
db.session.commit()
except:
print("创建管理员用户失败")
return
print("管理员用户创建成功")
class CreateRequest(Command):
"""创建请求情况"""
def run(self):
now = datetime.now()
day_key = "login_log:%d_%02d_%02d" % (now.year, now.month, now.day)
for day in range(8, 20):
current_app.redis_client.hset(day_key, "%02d:15" % day, random.randint(200, 1000))
print("创建访问数据完成")