[fixbug] 取消maa部分和git部分的proxy

This commit is contained in:
2026-01-24 12:21:07 +08:00
parent 070eedd1f8
commit 6ed6823204
2 changed files with 55 additions and 11 deletions
+54 -10
View File
@@ -16,13 +16,34 @@ fprint("-------------------------------------------------------")
time.sleep(1)
class CommandProcessor:
def Command(self,s:str) -> int:
def Command(self, s: str) -> int:
fprint("_> " + s)
if (t:=os.system(s))!=0:
if (t := os.system(s)) != 0:
fprint("Fatal Error: Command Failed:" + s)
fprint("Error Number: " + str(t))
return t
return 0
def CommandWithNoProxy(self, s: str) -> int:
fprint("_> " + s)
# 保存并删除
old_http = os.environ.pop('http_proxy', None)
old_https = os.environ.pop('https_proxy', None)
t = os.system(s)
# 立即恢复
if old_http:
os.environ['http_proxy'] = old_http
if old_https:
os.environ['https_proxy'] = old_https
if t != 0:
fprint("Fatal Error: Command Failed:" + s)
fprint("Error Number: " + str(t))
return t
def RetryCommand(self,s:str,retry:int=3) -> int:
result = 0
while retry > 0:
@@ -33,6 +54,15 @@ class CommandProcessor:
time.sleep(1)
return result
def RetryCommandWithNoProxy(self,s:str,retry:int=3) -> int:
result = 0
while retry > 0:
result = cp.CommandWithNoProxy(s)
if result == 0:
break
retry-=1
time.sleep(1)
return result
async def AsyncCommand(self,command:str,regex:str):
self._asyncCommand = command
@@ -67,9 +97,23 @@ def TaskFailRetry(command:str)->int:
cp.RetryCommand("maa closedown")
cp.RetryCommand("maa run startup")
return result
def TaskFailRetryWithNoProxy(command:str)->int:
retry = 3
result = 0
while retry > 0:
retry -= 1
result = cp.RetryCommandWithNoProxy(command)
if result == 0:
return 0
fprint(f"Task Command is {command}, ret code is {result}")
fprint("Task Failed, retrying...")
cp.RetryCommand("maa closedown")
cp.RetryCommand("maa run startup")
return result
# update
cp.Command("maa update")
cp.Command("maa self update")
cp.CommandWithNoProxy("maa update")
cp.CommandWithNoProxy("maa self update")
# fire it up
cp.Command("docker stop redroid")
redroid_path = os.getenv('redroid_path', "/home/lichx/.config/redroid-rk3588/")
@@ -81,12 +125,12 @@ time.sleep(15)
cp.RetryCommand(f"adb connect {adb_address}")
cp.RetryCommand(f"adb -s {adb_address} shell am start --windowingMode 4 com.hypergryph.arknights/com.u8.sdk.U8UnityContext")
# run maa
haveError |= TaskFailRetry("maa run startup") != 0
haveError |= TaskFailRetry("maa run recruit") != 0
haveError |= TaskFailRetry("maa run infrast") != 0
haveError |= TaskFailRetry("maa run fight") != 0
haveError |= TaskFailRetry("maa run mall") != 0
haveError |= TaskFailRetry("maa run award") != 0
haveError |= TaskFailRetryWithNoProxy("maa run startup") != 0
haveError |= TaskFailRetryWithNoProxy("maa run recruit") != 0
haveError |= TaskFailRetryWithNoProxy("maa run infrast") != 0
haveError |= TaskFailRetryWithNoProxy("maa run fight") != 0
haveError |= TaskFailRetryWithNoProxy("maa run mall") != 0
haveError |= TaskFailRetryWithNoProxy("maa run award") != 0
# storage error log
if haveError:
cp.Command(f"cp {log_dir}/maa_pyshell.log {log_dir}/maa_pyshell.{datetime.now().strftime('%Y-%m-%d-%H-%M-%S')}.log")