Skip to content

Commit

Permalink
release v0.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
wuranxu committed May 13, 2022
1 parent 0165748 commit a0fc438
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 12 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ $ pip install -r requirements.txt
6. 启动服务

```bash
$ python runserver.py
$ python pity.py
```

7. 注册用户
Expand Down
2 changes: 1 addition & 1 deletion README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ $ pip install -r requirements.txt
6. start server

```bash
$ python runserver.py
$ python pity.py
```

7. registry
Expand Down
25 changes: 24 additions & 1 deletion app/crud/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import json
import os
import sys
from collections import defaultdict
from copy import deepcopy
from datetime import datetime
from typing import Tuple, List
Expand Down Expand Up @@ -429,6 +430,29 @@ async def delete_by_id(cls, id):
raise Exception(f"删除记录失败")


# from app.models.user import User
# from app.models.project import Project
# from app.models.project_role import ProjectRole
# from app.models.environment import Environment
# from app.models.constructor import Constructor
# from app.models.address import PityGateway
# from app.models.broadcast_read_user import PityBroadcastReadUser
# from app.models.testplan_follow_user import PityTestPlanFollowUserRel
# from app.models.database import PityDatabase
# from app.models.gconfig import GConfig
# from app.models.notification import PityNotification
# from app.models.operation_log import PityOperationLog
# from app.models.oss_file import PityOssFile
# from app.models.result import PityTestResult
# from app.models.test_case import TestCase
# from app.models.test_plan import PityTestPlan
# from app.models.testcase_asserts import TestCaseAsserts
# from app.models.testcase_data import PityTestcaseData
# from app.models.redis_config import PityRedis
# from app.models.testcase_directory import PityTestcaseDirectory
# from app.models.report import PityReport


def get_dao_path():
"""获取dao目录下所有的xxxDao.py"""
dao_path_list = []
Expand All @@ -437,7 +461,6 @@ def get_dao_path():
file_path = os.path.join(Config.DAO_PATH, file)
# 判断过滤, 取有效目录
if os.path.isdir(file_path) and '__pycache__' not in file:
from collections import defaultdict
path_dict = defaultdict(list)
# 获取目录下所有的xxxDao.py
for py_file in os.listdir(file_path):
Expand Down
4 changes: 2 additions & 2 deletions app/routers/auth/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,13 @@ async def update_user_info(user_info: UserUpdateForm, user=Depends(Permission(Co


@router.get("/query")
async def update_user_info(token: str):
async def query_user_info(token: str):
try:
if not token:
raise AuthException(status.HTTP_200_OK, "token不存在")
user_info = UserToken.parse_token(token)
user = await UserDao.query_user(user_info['id'])
return PityResponse.success(user, exclude=("password"))
return PityResponse.success(user, exclude=("password",))
except Exception as e:
raise AuthException(status.HTTP_200_OK, e)

Expand Down
6 changes: 3 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,15 @@ async def init_redis():
:return:
"""
try:
await RedisHelper.ping()
logger.bind(name=None).success("redis connected success. ✔")
except Exception as e:
if not Config.REDIS_ON:
logger.bind(name=None).warning(
f"Redis is not selected, So we can't ensure that the task is not executed repeatedly. 🚫")
return
await RedisHelper.ping()
except Exception as e:
logger.bind(name=None).error(f"Redis connect failed, Please check config.py for redis config. ❌")
raise e
logger.bind(name=None).success("redis connected success. ✔")


@pity.on_event('startup')
Expand Down
9 changes: 9 additions & 0 deletions pity.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import uvicorn
import aiomysql

from config import Config
from main import pity

if __name__ == "__main__":
# uvicorn.run("main:pity", host="0.0.0.0", port=7777, reload=False)
uvicorn.run(pity, host="0.0.0.0", port=Config.SERVER_PORT, reload=False)
4 changes: 0 additions & 4 deletions runserver.py

This file was deleted.

0 comments on commit a0fc438

Please sign in to comment.