From 6d5ada0b05a9a9a23d0dd81abab363ca1a0ac35a Mon Sep 17 00:00:00 2001 From: thsrite Date: Tue, 2 Apr 2024 12:10:09 +0800 Subject: [PATCH] fix bug --- plugins/customcommand/__init__.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/plugins/customcommand/__init__.py b/plugins/customcommand/__init__.py index dba9ebe..2de3079 100644 --- a/plugins/customcommand/__init__.py +++ b/plugins/customcommand/__init__.py @@ -2,16 +2,16 @@ import random import subprocess import time from datetime import datetime, timedelta +from typing import Any, List, Dict, Tuple, Optional import pytz -from app.core.config import settings -from app.plugins import _PluginBase -from typing import Any, List, Dict, Tuple, Optional -from app.log import logger from apscheduler.schedulers.background import BackgroundScheduler from apscheduler.triggers.cron import CronTrigger -from app.schemas import NotificationType, MediaType +from app.core.config import settings +from app.log import logger +from app.plugins import _PluginBase +from app.schemas import NotificationType class CustomCommand(_PluginBase): @@ -112,7 +112,7 @@ class CustomCommand(_PluginBase): result = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) output, errors = result.communicate() logger.info( - f"执行命令:{command} {'成功' if errors else '失败'} 返回值:{errors.decode('utf-8')}") + f"执行命令:{command} 返回值:{errors.decode('utf-8') if errors else output.decode('utf-8')}") if self._notify and self._msgtype: # 发送通知 @@ -122,7 +122,8 @@ class CustomCommand(_PluginBase): self.post_message(title=name, mtype=mtype, - text=errors.decode('utf-8') if errors else "执行失败") + text="执行失败" if not errors and not output else errors.decode( + 'utf-8') if errors else output.decode('utf-8')) def __update_config(self): self.update_config({