uiautodev 0.5.0__py3-none-any.whl → 0.6.0__py3-none-any.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.

Potentially problematic release.


This version of uiautodev might be problematic. Click here for more details.

uiautodev/model.py CHANGED
@@ -33,13 +33,17 @@ class Rect(BaseModel):
33
33
 
34
34
  class Node(BaseModel):
35
35
  key: str
36
- name: str
36
+ name: str # can be seen as description
37
37
  bounds: Optional[Tuple[float, float, float, float]] = None
38
38
  rect: Optional[Rect] = None
39
- properties: Dict[str, Union[str, bool]] = []
39
+ properties: Dict[str, Union[str, bool]] = {}
40
40
  children: List[Node] = []
41
41
 
42
42
 
43
+ class OCRNode(Node):
44
+ confidence: float
45
+
46
+
43
47
  class WindowSize(typing.NamedTuple):
44
48
  width: int
45
49
  height: int
uiautodev/provider.py CHANGED
@@ -12,6 +12,7 @@ import adbutils
12
12
 
13
13
  from uiautodev.driver.android import AndroidDriver
14
14
  from uiautodev.driver.base_driver import BaseDriver
15
+ from uiautodev.driver.harmony import HarmonyDriver, HDC
15
16
  from uiautodev.driver.ios import IOSDriver
16
17
  from uiautodev.driver.mock import MockDriver
17
18
  from uiautodev.exceptions import UiautoException
@@ -27,7 +28,7 @@ class BaseProvider(abc.ABC):
27
28
  @abc.abstractmethod
28
29
  def get_device_driver(self, serial: str) -> BaseDriver:
29
30
  raise NotImplementedError()
30
-
31
+
31
32
  def get_single_device_driver(self) -> BaseDriver:
32
33
  """ debug use """
33
34
  devs = self.list_devices()
@@ -66,11 +67,25 @@ class IOSProvider(BaseProvider):
66
67
  @lru_cache
67
68
  def get_device_driver(self, serial: str) -> BaseDriver:
68
69
  return IOSDriver(serial)
69
-
70
+
71
+
72
+ class HarmonyProvider(BaseProvider):
73
+ def __init__(self):
74
+ super().__init__()
75
+ self.hdc = HDC()
76
+
77
+ def list_devices(self) -> list[DeviceInfo]:
78
+ devices = self.hdc.list_device()
79
+ return [DeviceInfo(serial=d, model=self.hdc.get_model(d), name=self.hdc.get_model(d)) for d in devices]
80
+
81
+ @lru_cache
82
+ def get_device_driver(self, serial: str) -> HarmonyDriver:
83
+ return HarmonyDriver(self.hdc, serial)
84
+
70
85
 
71
86
  class MockProvider(BaseProvider):
72
87
  def list_devices(self) -> list[DeviceInfo]:
73
88
  return [DeviceInfo(serial="mock-serial", model="mock-model", name="mock-name")]
74
89
 
75
90
  def get_device_driver(self, serial: str) -> BaseDriver:
76
- return MockDriver(serial)
91
+ return MockDriver(serial)
@@ -28,7 +28,7 @@ def make_router(provider: BaseProvider) -> APIRouter:
28
28
 
29
29
  @router.get("/list")
30
30
  def _list() -> List[DeviceInfo]:
31
- """List of Android devices"""
31
+ """List devices"""
32
32
  try:
33
33
  return provider.list_devices()
34
34
  except NotImplementedError as e:
uiautodev/utils/common.py CHANGED
@@ -5,11 +5,12 @@ import json as sysjson
5
5
  import platform
6
6
  import re
7
7
  import socket
8
+ import subprocess
8
9
  import sys
9
10
  import typing
10
11
  import uuid
11
12
  from http.client import HTTPConnection, HTTPResponse
12
- from typing import Optional, TypeVar, Union
13
+ from typing import List, Optional, TypeVar, Union
13
14
 
14
15
  from pydantic import BaseModel
15
16
  from pygments import formatters, highlight, lexers
@@ -61,10 +62,11 @@ def print_json(buf, colored=None, default=default_json_encoder):
61
62
  print(colorful_json)
62
63
  else:
63
64
  print(formatted_json)
64
-
65
+
65
66
 
66
67
  _T = TypeVar("_T")
67
68
 
69
+
68
70
  def convert_to_type(value: str, _type: _T) -> _T:
69
71
  """ usage example:
70
72
  convert_to_type("123", int)
@@ -78,9 +80,9 @@ def convert_to_type(value: str, _type: _T) -> _T:
78
80
  if _type == re.Pattern:
79
81
  return re.compile(value)
80
82
  raise NotImplementedError(f"convert {value} to {_type}")
81
-
82
83
 
83
- def convert_params_to_model(params: list[str], model: BaseModel) -> BaseModel:
84
+
85
+ def convert_params_to_model(params: List[str], model: BaseModel) -> BaseModel:
84
86
  """ used in cli.py """
85
87
  assert len(params) > 0
86
88
  if len(params) == 1:
@@ -114,7 +116,7 @@ class SocketHTTPConnection(HTTPConnection):
114
116
  def __init__(self, conn: socket.socket, timeout: float):
115
117
  super().__init__("localhost", timeout=timeout)
116
118
  self.__conn = conn
117
-
119
+
118
120
  def connect(self):
119
121
  self.sock = self.__conn
120
122
 
@@ -131,7 +133,8 @@ class MySocketHTTPConnection(SocketHTTPConnection):
131
133
  self.sock.settimeout(self.timeout)
132
134
 
133
135
 
134
- def fetch_through_socket(sock: socket.socket, path: str, method: str = "GET", json: Optional[dict] = None, timeout: float = 60) -> bytearray:
136
+ def fetch_through_socket(sock: socket.socket, path: str, method: str = "GET", json: Optional[dict] = None,
137
+ timeout: float = 60) -> bytearray:
135
138
  """ usage example:
136
139
  with socket.create_connection((host, port)) as s:
137
140
  request_through_socket(s, "GET", "/")
@@ -163,4 +166,5 @@ def node_travel(node: Node, dfs: bool = True):
163
166
  for child in node.children:
164
167
  yield from node_travel(child, dfs)
165
168
  if dfs:
166
- yield node
169
+ yield node
170
+
@@ -0,0 +1,9 @@
1
+ import os
2
+
3
+
4
+ def is_enabled(name: str) -> bool:
5
+ return os.getenv(name, "false").lower() in ("true", "1", "on", "yes", "y")
6
+
7
+
8
+ class Environment:
9
+ UIAUTODEV_MOCK = is_enabled("UIAUTODEV_MOCK")
@@ -1,8 +1,7 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.3
2
2
  Name: uiautodev
3
- Version: 0.5.0
3
+ Version: 0.6.0
4
4
  Summary: Mobile UI Automation, include UI hierarchy inspector, script recorder
5
- Home-page: https://uiauto.dev
6
5
  License: MIT
7
6
  Author: codeskyblue
8
7
  Author-email: codeskyblue@gmail.com
@@ -14,6 +13,7 @@ Classifier: Programming Language :: Python :: 3.9
14
13
  Classifier: Programming Language :: Python :: 3.10
15
14
  Classifier: Programming Language :: Python :: 3.11
16
15
  Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Programming Language :: Python :: 3.13
17
17
  Requires-Dist: adbutils (>=2.7.0,<3.0.0)
18
18
  Requires-Dist: click (>=8.1.7,<9.0.0)
19
19
  Requires-Dist: construct
@@ -27,6 +27,7 @@ Requires-Dist: pygments (>=2)
27
27
  Requires-Dist: uiautomator2 (>=2)
28
28
  Requires-Dist: uvicorn[standard]
29
29
  Requires-Dist: wdapy (>=0.2.2,<0.3.0)
30
+ Project-URL: Homepage, https://uiauto.dev
30
31
  Description-Content-Type: text/markdown
31
32
 
32
33
  # uiautodev
@@ -0,0 +1,33 @@
1
+ uiautodev/__init__.py,sha256=nCGwaTL1ifIZD9hnH2Gl14g3cUbMyEWFZmTebRCLGrs,164
2
+ uiautodev/__main__.py,sha256=0WZHyHW-M7FG5RexANNoIB5pkCX8xwQbTnmaOA9Y1kg,176
3
+ uiautodev/app.py,sha256=U0aDW2dwNEVy5kSBAbTCo2CAVyzaEZrJFBzQsCSoV3c,3215
4
+ uiautodev/appium_proxy.py,sha256=yMzPnIDo50hYSaq0g5bXUpgRrFa_849wNa2o7ZpxGNY,1773
5
+ uiautodev/case.py,sha256=Jk2_5X2F-XIPnGuYTCqOVQiwwchwOhF7uKK5oKv5shg,3919
6
+ uiautodev/cli.py,sha256=K4CEvGJSDWLAFR5tvls2Qp4evQ2lApLoUxA-4DI2-Sc,6235
7
+ uiautodev/command_proxy.py,sha256=C9z-dITMED4k5na45NMdEWAXlLh3Ll921mKuefFyk78,5226
8
+ uiautodev/command_types.py,sha256=pWdnCS4FRnEIiR1ynd4cjXX8zeFndjPztacBlukt61E,1761
9
+ uiautodev/common.py,sha256=1A0kXfxVrp_i5mc_aRjuqSDWFFZ7DwZR9qpRLu2GMMg,1488
10
+ uiautodev/driver/android.py,sha256=LOOF2d7Fg8crzA7G0rjBMQ63PQlCtLNCWfR20YEhrSE,6394
11
+ uiautodev/driver/appium.py,sha256=U3TGpOXmu3tEa3E1ttTFoXehOfFyjavJQ3XA4CtqeBE,5308
12
+ uiautodev/driver/base_driver.py,sha256=neoVS9T8MN5RXvW6vvqXSc6pcBW_fqujJurjUrlt0OA,2816
13
+ uiautodev/driver/harmony.py,sha256=93pwlg04wazey8MQM6DEvcBkr52REYVw4bwz321fK38,8031
14
+ uiautodev/driver/ios.py,sha256=EOi9k-Y4qQS6Htdz_ycBf5jYCnOkruB-mR0Sc8J-coo,4204
15
+ uiautodev/driver/mock.py,sha256=0VtxBkZRMbHiQGHjqm8Ih2Ld6baXiVxX8yUTwWJQlnE,2422
16
+ uiautodev/driver/testdata/layout.json,sha256=0z9jGJteXuGwkOhO_iINYPoDp1kCq-EaQds_iZkmiPQ,276538
17
+ uiautodev/driver/udt/appium-uiautomator2-v5.12.4-light.apk,sha256=cKUVKpqEiGRXODeqpwzVWllyjdSLyowFm94a6jDTvhI,3675062
18
+ uiautodev/driver/udt/udt.py,sha256=p6opbUtYxEGTINIX83F6m2CtzB42iSSBYRv1SjXCEFg,8351
19
+ uiautodev/exceptions.py,sha256=TuRD5SWQk5N2_KjrcDuXG_p84LBhLa2QEEXyFNFm0yQ,465
20
+ uiautodev/model.py,sha256=hziSYyh7ufaKbQrMmRMcIVeZ0x-pwkLMHljrI-qu184,950
21
+ uiautodev/provider.py,sha256=oElv04fsxrBBBm1FZ6VyNqquSQbhJXD25ApC7UgDsVI,2862
22
+ uiautodev/router/device.py,sha256=GHW83L63MxnjAEmTwhpetGatiu8iO0AOYr74UyFuF24,4835
23
+ uiautodev/router/xml.py,sha256=MKVLhjMBqE4qbEraQxvdrVp_OBnylEL9Wti5lnmBDk4,891
24
+ uiautodev/static/demo.html,sha256=qC7qUZP5Af9T3V5EuFGbovzv8mArwiGMWsX_vcs_Bt0,1240
25
+ uiautodev/utils/common.py,sha256=L1qBBBS6jRgkXlGy5o6Xafo49auLXKRWyX9x8U_IKjc,4821
26
+ uiautodev/utils/envutils.py,sha256=Clyt2Hz9PXpK_fT0yWbMmixXyGvCaJO3LAgamM7aUVc,197
27
+ uiautodev/utils/exceptions.py,sha256=lL_G_E41KWvfXnl32-E4Vgr3_HyTboxq_EwzdQMuvK4,637
28
+ uiautodev/utils/usbmux.py,sha256=LYupLDn7U4KFKhYQJrmIroS-3040gqZQVDRDB_FNDJM,17386
29
+ uiautodev-0.6.0.dist-info/LICENSE,sha256=RyeW676gBYO7AVVP2zQgfEx5rPSt46vR47xXZe7TlX4,1068
30
+ uiautodev-0.6.0.dist-info/METADATA,sha256=BmJOpByP-LzY61Q5-DUfH7eq3VnIXSHZ1viCbbCK4Qs,2373
31
+ uiautodev-0.6.0.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
32
+ uiautodev-0.6.0.dist-info/entry_points.txt,sha256=zBY8GgseYAAzPFA5Cf4rCCS9ivdyWsNxMVVYIaGAHJU,88
33
+ uiautodev-0.6.0.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 1.9.0
2
+ Generator: poetry-core 2.1.2
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -1,30 +0,0 @@
1
- uiautodev/__init__.py,sha256=uBLcbZ_b1lvAbHh0kXPeO4VWJvl-Zc4XvUMhg6PmzyY,164
2
- uiautodev/__main__.py,sha256=0WZHyHW-M7FG5RexANNoIB5pkCX8xwQbTnmaOA9Y1kg,176
3
- uiautodev/app.py,sha256=R7AV5uuh4VLkrF9Kl_JJWUiPQnuIeJ02CN1W7tNGPKE,2498
4
- uiautodev/appium_proxy.py,sha256=yMzPnIDo50hYSaq0g5bXUpgRrFa_849wNa2o7ZpxGNY,1773
5
- uiautodev/case.py,sha256=Jk2_5X2F-XIPnGuYTCqOVQiwwchwOhF7uKK5oKv5shg,3919
6
- uiautodev/cli.py,sha256=K4CEvGJSDWLAFR5tvls2Qp4evQ2lApLoUxA-4DI2-Sc,6235
7
- uiautodev/command_proxy.py,sha256=gP4oTCjA1uKteWq5NOcHQLrI34el0ag5LUHNEq_j7Ko,5280
8
- uiautodev/command_types.py,sha256=pWdnCS4FRnEIiR1ynd4cjXX8zeFndjPztacBlukt61E,1761
9
- uiautodev/common.py,sha256=t1jmG7S0LVXAigtg86J3vM2XXf1xYPfDV_HwSwyl3OI,552
10
- uiautodev/driver/android.py,sha256=aKx6mW0eUMejv2uItkvDQg6o5nxtAOJ3m0gqomRXC_g,6394
11
- uiautodev/driver/appium.py,sha256=U3TGpOXmu3tEa3E1ttTFoXehOfFyjavJQ3XA4CtqeBE,5308
12
- uiautodev/driver/base_driver.py,sha256=8uo7DgEKfgW_wf-HpkmFxjNRkElpFEDjjg45Q2pgiWA,2816
13
- uiautodev/driver/ios.py,sha256=EOi9k-Y4qQS6Htdz_ycBf5jYCnOkruB-mR0Sc8J-coo,4204
14
- uiautodev/driver/mock.py,sha256=0VtxBkZRMbHiQGHjqm8Ih2Ld6baXiVxX8yUTwWJQlnE,2422
15
- uiautodev/driver/udt/appium-uiautomator2-v5.12.4-light.apk,sha256=cKUVKpqEiGRXODeqpwzVWllyjdSLyowFm94a6jDTvhI,3675062
16
- uiautodev/driver/udt/udt.py,sha256=p6opbUtYxEGTINIX83F6m2CtzB42iSSBYRv1SjXCEFg,8351
17
- uiautodev/exceptions.py,sha256=TuRD5SWQk5N2_KjrcDuXG_p84LBhLa2QEEXyFNFm0yQ,465
18
- uiautodev/model.py,sha256=ij9Ct_OboSygyU_cQHoXzQ9czcwGogoezwXjyY-Cr0U,876
19
- uiautodev/provider.py,sha256=HDD_Jj-cJVfBceunzCYU9zJvGVya7Jd35GG9h85BY-0,2370
20
- uiautodev/router/device.py,sha256=9lLN7L1lExWUZ39uKz3fd56s3dkgdTfrKgcs9jQDD0I,4846
21
- uiautodev/router/xml.py,sha256=MKVLhjMBqE4qbEraQxvdrVp_OBnylEL9Wti5lnmBDk4,891
22
- uiautodev/static/demo.html,sha256=qC7qUZP5Af9T3V5EuFGbovzv8mArwiGMWsX_vcs_Bt0,1240
23
- uiautodev/utils/common.py,sha256=HuXJvipkg1QQg6vCD7OxH6JQtqbSVbXNzI1X2OVcEcU,4785
24
- uiautodev/utils/exceptions.py,sha256=lL_G_E41KWvfXnl32-E4Vgr3_HyTboxq_EwzdQMuvK4,637
25
- uiautodev/utils/usbmux.py,sha256=LYupLDn7U4KFKhYQJrmIroS-3040gqZQVDRDB_FNDJM,17386
26
- uiautodev-0.5.0.dist-info/LICENSE,sha256=RyeW676gBYO7AVVP2zQgfEx5rPSt46vR47xXZe7TlX4,1068
27
- uiautodev-0.5.0.dist-info/METADATA,sha256=jcCkmA85d8iUEKD7yO-JbHnykMP-gkiSy6zHHCULv34,2310
28
- uiautodev-0.5.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
29
- uiautodev-0.5.0.dist-info/entry_points.txt,sha256=zBY8GgseYAAzPFA5Cf4rCCS9ivdyWsNxMVVYIaGAHJU,88
30
- uiautodev-0.5.0.dist-info/RECORD,,