提交 0c8d478e5ebf9bdf4accfb07004e7fc4254fe2e1
Merge branch 'master' of http://gitlab.ctune.cn/weijunh/DMapManager
正在显示
3 个修改的文件
包含
21 行增加
和
18 行删除
| @@ -14,6 +14,8 @@ import configure | @@ -14,6 +14,8 @@ import configure | ||
| 14 | from app.decorators.auth_decorator import auth_decorator | 14 | from app.decorators.auth_decorator import auth_decorator |
| 15 | import time | 15 | import time |
| 16 | from app.models import SM3, AESHelper | 16 | from app.models import SM3, AESHelper |
| 17 | +from app.util.component.StructurePrint import StructurePrint | ||
| 18 | +import traceback | ||
| 17 | 19 | ||
| 18 | 20 | ||
| 19 | def current_user(): | 21 | def current_user(): |
| @@ -184,26 +186,29 @@ class DataManager(BlueprintApi): | @@ -184,26 +186,29 @@ class DataManager(BlueprintApi): | ||
| 184 | @staticmethod | 186 | @staticmethod |
| 185 | @bp.route("/init", methods=["GET"]) | 187 | @bp.route("/init", methods=["GET"]) |
| 186 | def init(): | 188 | def init(): |
| 187 | - username = 'admin' | ||
| 188 | - password = SM3.encode('DMap@123') | ||
| 189 | - if not User.query.filter_by(username=username).one_or_none(): | ||
| 190 | - user = User(username=username, password=password, role='admin', | ||
| 191 | - phone='', company='', position='', email='', | ||
| 192 | - create_time=time.strftime( | ||
| 193 | - "%Y-%m-%d %H:%M:%S", time.localtime()), | ||
| 194 | - update_time=time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())) | ||
| 195 | - db.sesion.add(user) | ||
| 196 | - db.session.commit() | ||
| 197 | - return "创建默认用户成功" | ||
| 198 | - else: | ||
| 199 | - return "默认用户已存在" | ||
| 200 | - | 189 | + try: |
| 190 | + username = 'admin' | ||
| 191 | + password = SM3.encode('DMap@123') | ||
| 192 | + if not User.query.filter_by(username=username).one_or_none(): | ||
| 193 | + user = User(username=username, password=password, role='admin', | ||
| 194 | + phone='', company='', position='', email='', | ||
| 195 | + create_time=time.strftime( | ||
| 196 | + "%Y-%m-%d %H:%M:%S", time.localtime()), | ||
| 197 | + update_time=time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())) | ||
| 198 | + db.session.add(user) | ||
| 199 | + db.session.commit() | ||
| 200 | + return "创建默认用户成功" | ||
| 201 | + else: | ||
| 202 | + return "默认用户已存在" | ||
| 203 | + except Exception as e: | ||
| 204 | + StructurePrint().print(e.__str__()+":" + traceback.format_exc(), "error") | ||
| 205 | + | ||
| 201 | @staticmethod | 206 | @staticmethod |
| 202 | @bp.route("/translate", methods=["GET"]) | 207 | @bp.route("/translate", methods=["GET"]) |
| 203 | def translate(): | 208 | def translate(): |
| 204 | - password = ['esri@123','admin','DMap@123','passwd'] | 209 | + password = ['esri@123', 'admin', 'DMap@123', 'passwd'] |
| 205 | result = {} | 210 | result = {} |
| 206 | for p in password: | 211 | for p in password: |
| 207 | new_pwd = SM3.encode(p) | 212 | new_pwd = SM3.encode(p) |
| 208 | result[p] = new_pwd | 213 | result[p] = new_pwd |
| 209 | - return result | ||
| 214 | + return result |
| @@ -38,7 +38,6 @@ class Api(ApiTemplate): | @@ -38,7 +38,6 @@ class Api(ApiTemplate): | ||
| 38 | res["msg"] = "获取clients集合成功" | 38 | res["msg"] = "获取clients集合成功" |
| 39 | res["result"] = True | 39 | res["result"] = True |
| 40 | except Exception as e: | 40 | except Exception as e: |
| 41 | - db.session.rollback() | ||
| 42 | raise e | 41 | raise e |
| 43 | return res | 42 | return res |
| 44 | 43 |
| @@ -5,7 +5,6 @@ | @@ -5,7 +5,6 @@ | ||
| 5 | 5 | ||
| 6 | # import schedule | 6 | # import schedule |
| 7 | from flask import json | 7 | from flask import json |
| 8 | -from sqlalchemy import true | ||
| 9 | from .models import MonitorHost, MonitorInfo | 8 | from .models import MonitorHost, MonitorInfo |
| 10 | from datetime import datetime, timedelta | 9 | from datetime import datetime, timedelta |
| 11 | import math | 10 | import math |
请
注册
或
登录
后发表评论