mirror of
https://github.com/LmeSzinc/AzurLaneAutoScript.git
synced 2025-01-07 07:47:07 +08:00
Add: Error notify
This commit is contained in:
parent
9f2defedfb
commit
c71838b091
21
alas.py
21
alas.py
@ -12,6 +12,7 @@ from module.config.config import AzurLaneConfig, TaskEnd
|
||||
from module.config.utils import deep_get, deep_set
|
||||
from module.exception import *
|
||||
from module.logger import logger
|
||||
from module.notify import handle_notify
|
||||
|
||||
|
||||
class AzurLaneAutoScript:
|
||||
@ -89,6 +90,11 @@ class AzurLaneAutoScript:
|
||||
if self.checker.is_available():
|
||||
logger.critical('Game page unknown')
|
||||
self.save_error_log()
|
||||
handle_notify(
|
||||
self.config.Error_OnePushConfig,
|
||||
title=f"Alas <{self.config_name}> crashed",
|
||||
content=f"<{self.config_name}> GamePageUnknownError",
|
||||
)
|
||||
exit(1)
|
||||
else:
|
||||
self.checker.wait_until_available()
|
||||
@ -96,13 +102,28 @@ class AzurLaneAutoScript:
|
||||
except ScriptError as e:
|
||||
logger.critical(e)
|
||||
logger.critical('This is likely to be a mistake of developers, but sometimes just random issues')
|
||||
handle_notify(
|
||||
self.config.Error_OnePushConfig,
|
||||
title=f"Alas <{self.config_name}> crashed",
|
||||
content=f"<{self.config_name}> ScriptError",
|
||||
)
|
||||
exit(1)
|
||||
except RequestHumanTakeover:
|
||||
logger.critical('Request human takeover')
|
||||
handle_notify(
|
||||
self.config.Error_OnePushConfig,
|
||||
title=f"Alas <{self.config_name}> crashed",
|
||||
content=f"<{self.config_name}> RequestHumanTakeover",
|
||||
)
|
||||
exit(1)
|
||||
except Exception as e:
|
||||
logger.exception(e)
|
||||
self.save_error_log()
|
||||
handle_notify(
|
||||
self.config.Error_OnePushConfig,
|
||||
title=f"Alas <{self.config_name}> crashed",
|
||||
content=f"<{self.config_name}> Exception occured",
|
||||
)
|
||||
exit(1)
|
||||
|
||||
def save_error_log(self):
|
||||
|
@ -16,6 +16,7 @@
|
||||
"Error": {
|
||||
"HandleError": true,
|
||||
"SaveError": true,
|
||||
"OnePushConfig": "{}",
|
||||
"ScreenshotLength": 1
|
||||
},
|
||||
"Optimization": {
|
||||
|
@ -22,4 +22,5 @@ prettytable==2.2.1
|
||||
pypresence==4.2.1
|
||||
rich==11.2.0
|
||||
zerorpc==0.6.3
|
||||
pyzmq==22.3.0
|
||||
pyzmq==22.3.0
|
||||
onepush
|
@ -23,4 +23,5 @@ prettytable==2.2.1
|
||||
pypresence==4.2.1
|
||||
rich==11.2.0
|
||||
zerorpc==0.6.3
|
||||
pyzmq==22.3.0
|
||||
pyzmq==22.3.0
|
||||
onepush
|
@ -1,17 +1,17 @@
|
||||
adbutils==0.11.0
|
||||
scipy
|
||||
pillow
|
||||
opencv-python
|
||||
imageio
|
||||
lz4
|
||||
tqdm
|
||||
uiautomator2==2.16.7
|
||||
adbutils==0.11.0
|
||||
uiautomator2==2.16.17
|
||||
retrying
|
||||
cnocr==1.2.2
|
||||
jellyfish
|
||||
pyyaml
|
||||
inflection
|
||||
pywebio==1.5.2
|
||||
pywebio==1.6.2
|
||||
starlette==0.14.2
|
||||
anyio==1.3.1
|
||||
uvicorn[standard]==0.17.6
|
||||
@ -20,6 +20,7 @@ wrapt==1.13.1
|
||||
prettytable==2.2.1
|
||||
pypresence==4.2.1
|
||||
alas-webapp==0.3.7
|
||||
rich==11.0.0
|
||||
zerorpc
|
||||
atomicwrites
|
||||
rich==11.2.0
|
||||
zerorpc==0.6.3
|
||||
pyzmq==22.3.0
|
||||
onepush
|
@ -134,6 +134,11 @@
|
||||
"type": "checkbox",
|
||||
"value": true
|
||||
},
|
||||
"OnePushConfig": {
|
||||
"type": "textarea",
|
||||
"value": "{}",
|
||||
"mode": "json"
|
||||
},
|
||||
"ScreenshotLength": {
|
||||
"type": "input",
|
||||
"value": 1
|
||||
|
@ -43,6 +43,10 @@ RestartEmulator:
|
||||
Error:
|
||||
HandleError: true
|
||||
SaveError: true
|
||||
OnePushConfig:
|
||||
type: textarea
|
||||
mode: json
|
||||
value: '{}'
|
||||
ScreenshotLength: 1
|
||||
Optimization:
|
||||
ScreenshotInterval: 0.3
|
||||
|
@ -33,6 +33,7 @@ class GeneratedConfig:
|
||||
# Group `Error`
|
||||
Error_HandleError = True
|
||||
Error_SaveError = True
|
||||
Error_OnePushConfig = '{}'
|
||||
Error_ScreenshotLength = 1
|
||||
|
||||
# Group `Optimization`
|
||||
|
@ -412,6 +412,10 @@
|
||||
"name": "Record Exception",
|
||||
"help": "Records exception and log into directory for review or sharing"
|
||||
},
|
||||
"OnePushConfig": {
|
||||
"name": "Error notify config",
|
||||
"help": "When Alas cannot handle exception, send a message through Onepush. Configuration document: \nhttps://github.com/LmeSzinc/AzurLaneAutoScript/wiki/Onepush-configuration-%5BEN%5D"
|
||||
},
|
||||
"ScreenshotLength": {
|
||||
"name": "Record Screenshot(s)",
|
||||
"help": "Number of screenshots saved when exception occurs"
|
||||
|
@ -412,6 +412,10 @@
|
||||
"name": "Error.SaveError.name",
|
||||
"help": "Error.SaveError.help"
|
||||
},
|
||||
"OnePushConfig": {
|
||||
"name": "Error.OnePushConfig.name",
|
||||
"help": "Error.OnePushConfig.help"
|
||||
},
|
||||
"ScreenshotLength": {
|
||||
"name": "Error.ScreenshotLength.name",
|
||||
"help": "Error.ScreenshotLength.help"
|
||||
|
@ -412,6 +412,10 @@
|
||||
"name": "出错时,保存 Log 和截图",
|
||||
"help": ""
|
||||
},
|
||||
"OnePushConfig": {
|
||||
"name": "错误推送设置",
|
||||
"help": "发生无法处理的异常后,使用 Onepush 推送一条错误信息。配置方法见文档:https://github.com/LmeSzinc/AzurLaneAutoScript/wiki/Onepush-configuration-%5BCN%5D"
|
||||
},
|
||||
"ScreenshotLength": {
|
||||
"name": "出错时,保留最后 X 张截图",
|
||||
"help": ""
|
||||
|
@ -412,6 +412,10 @@
|
||||
"name": "出錯時,保存 Log 和截圖",
|
||||
"help": ""
|
||||
},
|
||||
"OnePushConfig": {
|
||||
"name": "錯誤推送設定",
|
||||
"help": "發生無法處理的异常後,使用 Onepush 推送错误消息。設定參考文檔:https://github.com/LmeSzinc/AzurLaneAutoScript/wiki/Onepush-configuration-%5BCN%5D"
|
||||
},
|
||||
"ScreenshotLength": {
|
||||
"name": "出錯時,保留最後 X 張截圖",
|
||||
"help": ""
|
||||
|
@ -224,17 +224,17 @@ class AlasGUI(Frame):
|
||||
put_html('<hr class="hr-group">')
|
||||
|
||||
for arg, arg_dict in deep_iter(arg_dict, depth=1):
|
||||
output_kwargs: T_Output_Kwargs = {}
|
||||
output_kwargs: T_Output_Kwargs = arg_dict.copy()
|
||||
|
||||
# Skip hide
|
||||
display: Optional[str] = arg_dict.get("display")
|
||||
display: Optional[str] = output_kwargs.pop("display", None)
|
||||
if display == "hide":
|
||||
continue
|
||||
# Disable
|
||||
elif display == "disabled":
|
||||
output_kwargs["disabled"] = True
|
||||
# Output type
|
||||
output_kwargs["widget_type"] = arg_dict["type"]
|
||||
output_kwargs["widget_type"] = output_kwargs.pop("type")
|
||||
|
||||
arg_name = arg[0] # [arg_name,]
|
||||
# Internal pin widget name
|
||||
@ -244,14 +244,14 @@ class AlasGUI(Frame):
|
||||
|
||||
# Get value from config
|
||||
value = deep_get(
|
||||
config, [task, group_name, arg_name], arg_dict["value"]
|
||||
config, [task, group_name, arg_name], output_kwargs["value"]
|
||||
)
|
||||
# idk
|
||||
value = str(value) if isinstance(value, datetime) else value
|
||||
# Default value
|
||||
output_kwargs["value"] = value
|
||||
# Options
|
||||
output_kwargs["options"] = options = deep_get(arg_dict, "option", [])
|
||||
output_kwargs["options"] = options = output_kwargs.pop("option", [])
|
||||
# Options label
|
||||
options_label = []
|
||||
for opt in options:
|
||||
|
@ -349,7 +349,8 @@ def put_arg_select(kwargs: T_Output_Kwargs) -> Output:
|
||||
|
||||
def put_arg_textarea(kwargs: T_Output_Kwargs) -> Output:
|
||||
name: str = kwargs["name"]
|
||||
kwargs.setdefault("code", {"lineWrapping": True, "lineNumbers": False})
|
||||
mode: str = kwargs.pop("mode", None)
|
||||
kwargs.setdefault("code", {"lineWrapping": True, "lineNumbers": False, "mode": mode})
|
||||
|
||||
return put_scope(
|
||||
f"arg_contianer-textarea-{name}",
|
||||
|
@ -24,4 +24,5 @@ pypresence==4.2.1
|
||||
alas-webapp==0.3.7
|
||||
rich==11.2.0
|
||||
zerorpc==0.6.3
|
||||
pyzmq==22.3.0
|
||||
pyzmq==22.3.0
|
||||
onepush
|
@ -45,6 +45,7 @@ matplotlib==3.4.3 # via gluoncv
|
||||
msgpack==1.0.3 # via zerorpc
|
||||
mxnet==1.6.0 # via -r requirements-in.txt, cnocr
|
||||
numpy==1.16.6 # via -r requirements-in.txt, cnocr, gluoncv, imageio, matplotlib, mxnet, opencv-python, scipy
|
||||
onepush==1.2.0 # via -r requirements-in.txt
|
||||
opencv-python==4.5.3.56 # via -r requirements-in.txt
|
||||
packaging==20.9 # via deprecation, uiautomator2
|
||||
pillow==8.3.2 # via -r requirements-in.txt, cnocr, gluoncv, imageio, matplotlib, uiautomator2
|
||||
@ -63,7 +64,7 @@ pywebio==1.6.2 # via -r requirements-in.txt
|
||||
pywin32==301 # via portalocker
|
||||
pyyaml==5.4.1 # via -r requirements-in.txt, uvicorn
|
||||
pyzmq==22.3.0 # via -r requirements-in.txt, zerorpc
|
||||
requests==2.18.4 # via adbutils, gluoncv, mxnet, uiautomator2
|
||||
requests==2.18.4 # via adbutils, gluoncv, mxnet, onepush, uiautomator2
|
||||
retry==0.9.2 # via adbutils, uiautomator2
|
||||
retrying==1.3.3 # via -r requirements-in.txt
|
||||
rich==11.2.0 # via -r requirements-in.txt
|
||||
|
Loading…
Reference in New Issue
Block a user