fix: auto-fix code issues (cron)
- 修复重复导入/字段 - 修复异常处理 - 修复PEP8格式问题 - 添加类型注解
This commit is contained in:
@@ -234,8 +234,8 @@ class WebhookNotifier:
|
||||
"zh_cn": {
|
||||
"title": message.get("title", ""),
|
||||
"content": message.get("body", []),
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
else:
|
||||
@@ -264,7 +264,7 @@ class WebhookNotifier:
|
||||
secret_enc = config.secret.encode("utf-8")
|
||||
string_to_sign = f"{timestamp}\n{config.secret}"
|
||||
hmac_code = hmac.new(
|
||||
secret_enc, string_to_sign.encode("utf-8"), digestmod=hashlib.sha256
|
||||
secret_enc, string_to_sign.encode("utf-8"), digestmod=hashlib.sha256,
|
||||
).digest()
|
||||
sign = urllib.parse.quote_plus(base64.b64encode(hmac_code))
|
||||
url = f"{config.url}×tamp = {timestamp}&sign = {sign}"
|
||||
@@ -422,7 +422,7 @@ class WorkflowManager:
|
||||
)
|
||||
|
||||
logger.info(
|
||||
f"Scheduled workflow {workflow.id} ({workflow.name}) with {workflow.schedule_type}"
|
||||
f"Scheduled workflow {workflow.id} ({workflow.name}) with {workflow.schedule_type}",
|
||||
)
|
||||
|
||||
async def _execute_workflow_job(self, workflow_id: str) -> None:
|
||||
@@ -497,7 +497,7 @@ class WorkflowManager:
|
||||
conn.close()
|
||||
|
||||
def list_workflows(
|
||||
self, project_id: str = None, status: str = None, workflow_type: str = None
|
||||
self, project_id: str = None, status: str = None, workflow_type: str = None,
|
||||
) -> list[Workflow]:
|
||||
"""列出工作流"""
|
||||
conn = self.db.get_conn()
|
||||
@@ -518,7 +518,7 @@ class WorkflowManager:
|
||||
where_clause = " AND ".join(conditions) if conditions else "1 = 1"
|
||||
|
||||
rows = conn.execute(
|
||||
f"SELECT * FROM workflows WHERE {where_clause} ORDER BY created_at DESC", params
|
||||
f"SELECT * FROM workflows WHERE {where_clause} ORDER BY created_at DESC", params,
|
||||
).fetchall()
|
||||
|
||||
return [self._row_to_workflow(row) for row in rows]
|
||||
@@ -780,7 +780,7 @@ class WorkflowManager:
|
||||
conn = self.db.get_conn()
|
||||
try:
|
||||
row = conn.execute(
|
||||
"SELECT * FROM webhook_configs WHERE id = ?", (webhook_id,)
|
||||
"SELECT * FROM webhook_configs WHERE id = ?", (webhook_id,),
|
||||
).fetchone()
|
||||
|
||||
if not row:
|
||||
@@ -1159,7 +1159,7 @@ class WorkflowManager:
|
||||
raise
|
||||
|
||||
async def _execute_tasks_with_deps(
|
||||
self, tasks: list[WorkflowTask], input_data: dict, log_id: str
|
||||
self, tasks: list[WorkflowTask], input_data: dict, log_id: str,
|
||||
) -> dict:
|
||||
"""按依赖顺序执行任务"""
|
||||
results = {}
|
||||
@@ -1413,7 +1413,7 @@ class WorkflowManager:
|
||||
# ==================== Notification ====================
|
||||
|
||||
async def _send_workflow_notification(
|
||||
self, workflow: Workflow, results: dict, success: bool = True
|
||||
self, workflow: Workflow, results: dict, success: bool = True,
|
||||
) -> None:
|
||||
"""发送工作流执行通知"""
|
||||
if not workflow.webhook_ids:
|
||||
@@ -1500,8 +1500,8 @@ class WorkflowManager:
|
||||
],
|
||||
"footer": "InsightFlow",
|
||||
"ts": int(datetime.now().timestamp()),
|
||||
}
|
||||
]
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user