From 069d5119c39197bf6ce016281ea2249365bf377b Mon Sep 17 00:00:00 2001 From: lichx Date: Wed, 22 Jan 2025 21:25:04 +0800 Subject: [PATCH] =?UTF-8?q?[feature]=20=E6=9B=B4=E6=96=B0log=E7=9B=B8?= =?UTF-8?q?=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ArknightsMaaConfig/maa.py | 5 +++-- run_all.sh | 6 ++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/ArknightsMaaConfig/maa.py b/ArknightsMaaConfig/maa.py index 4ff9cf3..1335164 100755 --- a/ArknightsMaaConfig/maa.py +++ b/ArknightsMaaConfig/maa.py @@ -52,7 +52,7 @@ class CommandProcessor: # cp.Command("command") # cp.RetryCommand("command",retry_time:int) # asyncio.run(cp.AsyncCommand("command","stop track regex")) -script_dir = os.path.dirname((os.path.abspath(__file__))) +# script_dir = os.path.dirname((os.path.abspath(__file__))) cp = CommandProcessor() haveError = False def TaskFailRetry(command:str)->int: @@ -75,6 +75,7 @@ cp.Command("maa self update") cp.Command("docker stop redroid") redroid_path = os.getenv('redroid_path', "/home/lichx/.config/redroid-rk3588/") adb_address = os.getenv('adb_address', "localhost:5555") +log_dir = os.getenv('MAA_LOG', "/home/lichx/.config/redroid-rk3588/log/") os.chdir(redroid_path) cp.Command("docker compose up -d") time.sleep(15) @@ -89,7 +90,7 @@ haveError |= TaskFailRetry("maa run mall") != 0 haveError |= TaskFailRetry("maa run award") != 0 # storage error log if haveError: - cp.Command(f"cp {script_dir}/pyshell.log {script_dir}/pyshell.{datetime.now().strftime('%Y-%m-%d-%H-%M-%S')}.log") + cp.Command(f"cp {log_dir}/pyshell.log {log_dir}/pyshell.{datetime.now().strftime('%Y-%m-%d-%H-%M-%S')}.log") # shutdown cp.RetryCommand("maa closedown") cp.Command("docker stop redroid") diff --git a/run_all.sh b/run_all.sh index c85f557..ffde96a 100755 --- a/run_all.sh +++ b/run_all.sh @@ -1,9 +1,11 @@ #!/usr/bin/env bash + SCRIPT_DIR=$(dirname $(readlink -f "$0")) MAA_PY="$SCRIPT_DIR/ArknightsMaaConfig/maa.py" +MAA_LOG_DIR="${MAA_LOG:-/var/log/maa.log}" if [ -x "$MAA_PY" ]; then - "$MAA_PY" + "$MAA_PY" > "$MAA_LOG_DIR" 2>&1 else - python3 "$MAA_PY" + python3 "$MAA_PY" > "$MAA_LOG_DIR" 2>&1 fi \ No newline at end of file