Skip to content

Commit

Permalink
chore: revert python property
Browse files Browse the repository at this point in the history
  • Loading branch information
MistEO committed Oct 30, 2024
1 parent 673c7d0 commit 97982fd
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 29 deletions.
5 changes: 0 additions & 5 deletions source/binding/Python/maa/define.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,23 +347,18 @@ def __init__(self, status: Union[MaaStatus, MaaStatusEnum, int]):
else:
self._status = MaaStatusEnum(status)

@property
def done(self) -> bool:
return self._status in [MaaStatusEnum.succeeded, MaaStatusEnum.failed]

@property
def succeeded(self) -> bool:
return self._status == MaaStatusEnum.succeeded

@property
def failed(self) -> bool:
return self._status == MaaStatusEnum.failed

@property
def pending(self) -> bool:
return self._status == MaaStatusEnum.pending

@property
def running(self) -> bool:
return self._status == MaaStatusEnum.running

Expand Down
17 changes: 5 additions & 12 deletions source/binding/Python/maa/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,37 +9,30 @@ def __init__(self, job_id: MaaId, status_func, wait_func):
self._status_func = status_func
self._wait_func = wait_func

@property
def job_id(self) -> int:
return int(self._job_id)

def wait(self) -> "Job":
self._wait_func(self._job_id)
return self

@property
def status(self) -> Status:
return Status(self._status_func(self._job_id))

@property
def done(self) -> bool:
return self.status.done
return self.status().done()

@property
def succeeded(self) -> bool:
return self.status.succeeded
return self.status().succeeded()

@property
def failed(self) -> bool:
return self.status.failed
return self.status().failed()

@property
def pending(self) -> bool:
return self.status.pending
return self.status().pending()

@property
def running(self) -> bool:
return self.status.running
return self.status().running()


class JobWithResult(Job):
Expand Down
22 changes: 11 additions & 11 deletions test/python/binding_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,20 +187,20 @@ def custom_ctrl_test():
print("test_custom_controller")

controller = MyController(MyNotificationHandler())
ret = controller.post_connection().wait().succeeded
ret = controller.post_connection().wait().succeeded()
uuid = controller.uuid
ret &= controller.post_start_app("custom_aaa").wait().succeeded
ret &= controller.post_stop_app("custom_bbb").wait().succeeded
ret &= controller.post_start_app("custom_aaa").wait().succeeded()
ret &= controller.post_stop_app("custom_bbb").wait().succeeded()
image_job = controller.post_screencap().wait()
ret &= image_job.succeeded
ret &= image_job.succeeded()
print(f"image: {image_job.get().shape}")
ret &= controller.post_click(100, 200).wait().succeeded
ret &= controller.post_swipe(100, 200, 300, 400, 200).wait().succeeded
ret &= controller.post_touch_down(1, 100, 100, 0).wait().succeeded
ret &= controller.post_touch_move(1, 200, 200, 0).wait().succeeded
ret &= controller.post_touch_up(1).wait().succeeded
ret &= controller.post_press_key(32).wait().succeeded
ret &= controller.post_input_text("Hello World!").wait().succeeded
ret &= controller.post_click(100, 200).wait().succeeded()
ret &= controller.post_swipe(100, 200, 300, 400, 200).wait().succeeded()
ret &= controller.post_touch_down(1, 100, 100, 0).wait().succeeded()
ret &= controller.post_touch_move(1, 200, 200, 0).wait().succeeded()
ret &= controller.post_touch_up(1).wait().succeeded()
ret &= controller.post_press_key(32).wait().succeeded()
ret &= controller.post_input_text("Hello World!").wait().succeeded()

print(f"controller.count: {controller.count}, ret: {ret}")
if controller.count != 11 or not ret:
Expand Down
2 changes: 1 addition & 1 deletion tools/ImageCropper/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def parse_args() -> Controller:
controller = parse_args()
if controller:
set_screenshot_target_side(controller)
if controller.post_connection().failed:
if controller.post_connection().failed():
print(f"Failed to connect device({device_serial}).")

# 初始化 Roi
Expand Down

0 comments on commit 97982fd

Please sign in to comment.