MaaFw 2.1.0__py3-none-manylinux2014_x86_64.whl → 5.4.0b1__py3-none-manylinux2014_x86_64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- maa/__init__.py +7 -5
- maa/agent/__init__.py +12 -0
- maa/agent/agent_server.py +350 -0
- maa/agent_client.py +291 -0
- maa/bin/libMaaAdbControlUnit.so +0 -0
- maa/bin/libMaaAgentClient.so +0 -0
- maa/bin/libMaaAgentServer.so +0 -0
- maa/bin/libMaaCustomControlUnit.so +0 -0
- maa/bin/libMaaFramework.so +0 -0
- maa/bin/libMaaToolkit.so +0 -0
- maa/bin/libMaaUtils.so +0 -0
- maa/bin/libc++.so.1 +0 -0
- maa/bin/libc++abi.so.1 +0 -0
- maa/bin/libfastdeploy_ppocr.so +0 -0
- maa/bin/{libopencv_world4.so.408 → libonnxruntime.so.1} +0 -0
- maa/bin/{libonnxruntime.so.1.18.0 → libopencv_world4.so.411} +0 -0
- maa/bin/libunwind.so.1 +0 -0
- maa/bin/plugins/libMaaPluginDemo.so +0 -0
- maa/buffer.py +297 -153
- maa/context.py +449 -34
- maa/controller.py +760 -113
- maa/custom_action.py +46 -3
- maa/custom_recognition.py +69 -11
- maa/define.py +539 -42
- maa/event_sink.py +103 -0
- maa/job.py +95 -36
- maa/library.py +182 -53
- maa/pipeline.py +509 -0
- maa/resource.py +598 -71
- maa/tasker.py +696 -156
- maa/toolkit.py +125 -165
- maafw-5.4.0b1.dist-info/METADATA +297 -0
- maafw-5.4.0b1.dist-info/RECORD +35 -0
- maafw-5.4.0b1.dist-info/WHEEL +4 -0
- MaaFw-2.1.0.dist-info/METADATA +0 -166
- MaaFw-2.1.0.dist-info/RECORD +0 -26
- MaaFw-2.1.0.dist-info/WHEEL +0 -4
- MaaFw-2.1.0.dist-info/top_level.txt +0 -1
- maa/bin/libMaaDbgControlUnit.so +0 -0
- maa/notification_handler.py +0 -191
- {MaaFw-2.1.0.dist-info → maafw-5.4.0b1.dist-info/licenses}/LICENSE.md +0 -0
maa/notification_handler.py
DELETED
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
import ctypes
|
|
2
|
-
import json
|
|
3
|
-
from abc import ABC
|
|
4
|
-
from typing import Optional, Tuple
|
|
5
|
-
from enum import Enum
|
|
6
|
-
from dataclasses import dataclass
|
|
7
|
-
|
|
8
|
-
from .define import MaaNotificationCallback
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
# class NotificationEvent(Enum):
|
|
12
|
-
# ResourceLoading = 1
|
|
13
|
-
# ControllerAction = 2
|
|
14
|
-
# TaskerTask = 3
|
|
15
|
-
# TaskNextList = 4
|
|
16
|
-
# TaskRecognition = 5
|
|
17
|
-
# TaskAction = 6
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
class NotificationType(Enum):
|
|
21
|
-
Unknown = 0
|
|
22
|
-
Starting = 1
|
|
23
|
-
Succeeded = 2
|
|
24
|
-
Failed = 3
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
class NotificationHandler(ABC):
|
|
28
|
-
|
|
29
|
-
@dataclass
|
|
30
|
-
class ResourceLoadingDetail:
|
|
31
|
-
res_id: int
|
|
32
|
-
hash: str
|
|
33
|
-
path: str
|
|
34
|
-
|
|
35
|
-
def on_resource_loading(
|
|
36
|
-
self, noti_type: NotificationType, detail: ResourceLoadingDetail
|
|
37
|
-
):
|
|
38
|
-
pass
|
|
39
|
-
|
|
40
|
-
@dataclass
|
|
41
|
-
class ControllerActionDetail:
|
|
42
|
-
ctrl_id: int
|
|
43
|
-
uuid: str
|
|
44
|
-
action: str
|
|
45
|
-
|
|
46
|
-
def on_controller_action(
|
|
47
|
-
self, noti_type: NotificationType, detail: ControllerActionDetail
|
|
48
|
-
):
|
|
49
|
-
pass
|
|
50
|
-
|
|
51
|
-
@dataclass
|
|
52
|
-
class TaskerTaskDetail:
|
|
53
|
-
task_id: int
|
|
54
|
-
entry: str
|
|
55
|
-
uuid: str
|
|
56
|
-
hash: str
|
|
57
|
-
|
|
58
|
-
def on_tasker_task(self, noti_type: NotificationType, detail: TaskerTaskDetail):
|
|
59
|
-
pass
|
|
60
|
-
|
|
61
|
-
@dataclass
|
|
62
|
-
class TaskNextListDetail:
|
|
63
|
-
task_id: int
|
|
64
|
-
name: str
|
|
65
|
-
next_list: list[str]
|
|
66
|
-
|
|
67
|
-
def on_task_next_list(
|
|
68
|
-
self, noti_type: NotificationType, detail: TaskNextListDetail
|
|
69
|
-
):
|
|
70
|
-
pass
|
|
71
|
-
|
|
72
|
-
@dataclass
|
|
73
|
-
class TaskRecognitionDetail:
|
|
74
|
-
task_id: int
|
|
75
|
-
reco_id: int
|
|
76
|
-
name: str
|
|
77
|
-
|
|
78
|
-
def on_task_recognition(
|
|
79
|
-
self, noti_type: NotificationType, detail: TaskRecognitionDetail
|
|
80
|
-
):
|
|
81
|
-
pass
|
|
82
|
-
|
|
83
|
-
@dataclass
|
|
84
|
-
class TaskActionDetail:
|
|
85
|
-
task_id: int
|
|
86
|
-
node_id: int
|
|
87
|
-
name: str
|
|
88
|
-
|
|
89
|
-
def on_task_action(self, noti_type: NotificationType, detail: TaskActionDetail):
|
|
90
|
-
pass
|
|
91
|
-
|
|
92
|
-
def on_unknown_notification(self, msg: str, details: dict):
|
|
93
|
-
pass
|
|
94
|
-
|
|
95
|
-
def on_raw_notification(self, msg: str, details: dict):
|
|
96
|
-
|
|
97
|
-
noti_type = NotificationHandler._notification_type(msg)
|
|
98
|
-
|
|
99
|
-
if msg.startswith("Resource.Loading"):
|
|
100
|
-
detail = self.ResourceLoadingDetail(
|
|
101
|
-
res_id=details["res_id"],
|
|
102
|
-
hash=details["hash"],
|
|
103
|
-
path=details["path"],
|
|
104
|
-
)
|
|
105
|
-
self.on_resource_loading(noti_type, detail)
|
|
106
|
-
|
|
107
|
-
elif msg.startswith("Controller.Action"):
|
|
108
|
-
detail = self.ControllerActionDetail(
|
|
109
|
-
ctrl_id=details["ctrl_id"],
|
|
110
|
-
uuid=details["uuid"],
|
|
111
|
-
action=details["action"],
|
|
112
|
-
)
|
|
113
|
-
self.on_controller_action(noti_type, detail)
|
|
114
|
-
|
|
115
|
-
elif msg.startswith("Tasker.Task"):
|
|
116
|
-
detail = self.TaskerTaskDetail(
|
|
117
|
-
task_id=details["task_id"],
|
|
118
|
-
entry=details["entry"],
|
|
119
|
-
uuid=details["uuid"],
|
|
120
|
-
hash=details["hash"],
|
|
121
|
-
)
|
|
122
|
-
self.on_tasker_task(noti_type, detail)
|
|
123
|
-
|
|
124
|
-
elif msg.startswith("Task.NextList"):
|
|
125
|
-
detail = self.TaskNextListDetail(
|
|
126
|
-
task_id=details["task_id"],
|
|
127
|
-
name=details["name"],
|
|
128
|
-
next_list=details["list"],
|
|
129
|
-
)
|
|
130
|
-
self.on_task_next_list(noti_type, detail)
|
|
131
|
-
|
|
132
|
-
elif msg.startswith("Task.Recognition"):
|
|
133
|
-
detail = self.TaskRecognitionDetail(
|
|
134
|
-
task_id=details["task_id"],
|
|
135
|
-
reco_id=details["reco_id"],
|
|
136
|
-
name=details["name"],
|
|
137
|
-
)
|
|
138
|
-
self.on_task_recognition(noti_type, detail)
|
|
139
|
-
|
|
140
|
-
elif msg.startswith("Task.Action"):
|
|
141
|
-
detail = self.TaskActionDetail(
|
|
142
|
-
task_id=details["task_id"],
|
|
143
|
-
node_id=details["node_id"],
|
|
144
|
-
name=details["name"],
|
|
145
|
-
)
|
|
146
|
-
self.on_task_action(noti_type, detail)
|
|
147
|
-
|
|
148
|
-
else:
|
|
149
|
-
self.on_unknown_notification(msg, details)
|
|
150
|
-
|
|
151
|
-
@property
|
|
152
|
-
def c_callback(self) -> MaaNotificationCallback:
|
|
153
|
-
return self._c_notification_agent
|
|
154
|
-
|
|
155
|
-
@property
|
|
156
|
-
def c_callback_arg(self) -> ctypes.c_void_p:
|
|
157
|
-
return ctypes.c_void_p.from_buffer(ctypes.py_object(self))
|
|
158
|
-
|
|
159
|
-
@staticmethod
|
|
160
|
-
def _gen_c_param(
|
|
161
|
-
handler: Optional["NotificationHandler"],
|
|
162
|
-
) -> Tuple[MaaNotificationCallback, ctypes.c_void_p]:
|
|
163
|
-
if handler:
|
|
164
|
-
return handler.c_callback, handler.c_callback_arg
|
|
165
|
-
else:
|
|
166
|
-
return NotificationHandler._c_notification_agent, ctypes.c_void_p()
|
|
167
|
-
|
|
168
|
-
@staticmethod
|
|
169
|
-
def _notification_type(message: str) -> NotificationType:
|
|
170
|
-
if message.endswith(".Starting"):
|
|
171
|
-
return NotificationType.Starting
|
|
172
|
-
elif message.endswith(".Succeeded"):
|
|
173
|
-
return NotificationType.Succeeded
|
|
174
|
-
elif message.endswith(".Failed"):
|
|
175
|
-
return NotificationType.Failed
|
|
176
|
-
else:
|
|
177
|
-
return NotificationType.Unknown
|
|
178
|
-
|
|
179
|
-
@staticmethod
|
|
180
|
-
@MaaNotificationCallback
|
|
181
|
-
def _c_notification_agent(
|
|
182
|
-
msg: ctypes.c_char_p,
|
|
183
|
-
details_json: ctypes.c_char_p,
|
|
184
|
-
callback_arg: ctypes.c_void_p,
|
|
185
|
-
):
|
|
186
|
-
if not callback_arg:
|
|
187
|
-
return
|
|
188
|
-
|
|
189
|
-
self: NotificationHandler = ctypes.cast(callback_arg, ctypes.py_object).value
|
|
190
|
-
|
|
191
|
-
self.on_raw_notification(msg.decode(), json.loads(details_json.decode()))
|
|
File without changes
|