-
Notifications
You must be signed in to change notification settings - Fork 568
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(qd): 🦄 优化代码和 logger 格式和静态类型 (#496)
* refactor(libs&main): 🦄 优化代码和 logger 格式和静态类型 by pylint/flake8/mypy * Bugfix(logger): 🐛 修复部分日志不显示错误详情 #491 需打开 config.traceback_print 开关 * Change(libs): 📝 修改解析Url方式 * refactor(db&web): 🦄 优化代码和 logger 格式和静态类型 * refactor(web): 🦄 合并 logger 和错误栈打印 * Typo(web): ✏️ 修复输出文本显示 * Change(web): 📝 优化 for 循环调试显示 * Bugfix(web): 🐛 修复无法跳转发布项详情 * Bugfix(web): 🐛 发布模板时会在循环内修改模板 * Bugfix(web): 🐛 删除公开模板时自动取消发布请求 * Bugfix(web): 🐛 修复任务定时开关设置 * Change(config): 📝 运行自定义单用户拥有记事本最大数量配置
- Loading branch information
Showing
55 changed files
with
3,485 additions
and
3,077 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[flake8] | ||
max-line-length = 120 | ||
ignore = E203, E266, E501, W503 | ||
exclude = .git, __pycache__, venv, dist, build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
# Author: Binux<[email protected]> | ||
# http://binux.me | ||
# Created on 2014-08-09 11:39:25 | ||
# pylint: disable=broad-exception-raised | ||
|
||
import sqlite3 | ||
|
||
|
@@ -127,30 +128,29 @@ def new(self, userid, maindb): | |
`notepadid` INTEGER NOT NULL , | ||
`content` TEXT NULL | ||
); | ||
''' ) | ||
''') | ||
|
||
# 获取数据库信息 | ||
userid = int(userid) | ||
user = maindb.db.user.get(id=userid, fields=('id', 'email', 'email_verified', 'password', 'password_md5', 'userkey', 'nickname', 'role', 'ctime', 'mtime', 'atime', 'cip', | ||
'mip', 'aip', 'skey', 'barkurl', 'wxpusher', 'noticeflg', 'logtime', 'status', 'notepad', 'diypusher', 'qywx_token', 'tg_token', 'dingding_token', 'qywx_webhook', 'push_batch')) | ||
userkey = maindb.db.user.__getuserkey(user['env']) | ||
# user = maindb.db.user.get(id=userid, fields=('id', 'email', 'email_verified', 'password', 'password_md5', 'userkey', 'nickname', 'role', 'ctime', 'mtime', 'atime', 'cip', | ||
# 'mip', 'aip', 'skey', 'barkurl', 'wxpusher', 'noticeflg', 'logtime', 'status', 'notepad', 'diypusher', 'qywx_token', 'tg_token', 'dingding_token', 'qywx_webhook', 'push_batch')) | ||
# userkey = maindb.db.user.__getuserkey(user['env']) | ||
tpls = [] | ||
for tpl in maindb.db.tpl.list(fields=('id', 'userid', 'siteurl', 'sitename', 'banner', 'disabled', 'public', 'lock', 'fork', 'har', 'tpl', 'variables', 'interval', 'note', 'success_count', 'failed_count', 'last_success', 'ctime', 'mtime', 'atime', 'tplurl', 'updateable', '_groups', 'init_env'), limit=None): | ||
if tpl['userid'] == userid: | ||
tpls.append(tpl) | ||
tasks = [] | ||
tasklogs = [] | ||
for task in maindb.db.task.list(userid, fields=('id', 'tplid', 'userid', 'note', 'disabled', 'init_env', 'env', 'session', 'retry_count', 'retry_interval', 'last_success', 'success_count', | ||
'failed_count', 'last_failed', 'next', 'last_failed_count', 'ctime', 'mtime', 'ontimeflg', 'ontime', '_groups', 'pushsw', 'newontime'), limit=None): | ||
'failed_count', 'last_failed', 'next', 'last_failed_count', 'ctime', 'mtime', 'ontimeflg', 'ontime', '_groups', 'pushsw', 'newontime'), limit=None): | ||
if task['userid'] == userid: | ||
tasks.append(task) | ||
for tasklog in maindb.db.tasklog.list(taskid = task['id'], fields=('id', "taskid", "success", "ctime", "msg")): | ||
for tasklog in maindb.db.tasklog.list(taskid=task['id'], fields=('id', "taskid", "success", "ctime", "msg")): | ||
tasklogs.append(tasklog) | ||
|
||
c.close() | ||
conn.close() | ||
|
||
|
||
except Exception as e: | ||
raise Exception("backup database error") | ||
raise Exception("backup database error") from e | ||
print("OK") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,16 +10,20 @@ | |
""" | ||
|
||
import asyncio | ||
import logging | ||
import sys | ||
|
||
import db | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
def usage(): | ||
print('Usage: python3 %s <email> [role]' % sys.argv[0]) | ||
print('Example: python3 %s [email protected] admin' % sys.argv[0]) | ||
print(f'Usage: python3 {sys.argv[0]} <email> [role]') | ||
print(f'Example: python3 {sys.argv[0]} [email protected] admin') | ||
sys.exit(1) | ||
|
||
|
||
async def main(): | ||
email = sys.argv[1] | ||
role = sys.argv[2] if len(sys.argv) == 3 else '' | ||
|
@@ -31,9 +35,9 @@ async def main(): | |
sys.exit(1) | ||
rowcount = await userdb.mod(user['id'], role=role) | ||
if rowcount >= 1: | ||
print("role of {} changed to {}".format(email, role or '[empty]')) | ||
logger.info("role of %s changed to %s", email, role or '[empty]') | ||
else: | ||
print("role of {} not changed".format(email)) | ||
logger.warning("role of %s not changed", email) | ||
|
||
|
||
if __name__ == '__main__': | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.