uiautodev 0.4.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,21 @@ 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
- height: int
49
+ height: int
50
+
51
+
52
+ class AppInfo(BaseModel):
53
+ packageName: str
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)
@@ -6,9 +6,10 @@
6
6
 
7
7
  import io
8
8
  import logging
9
- from typing import Any, List
9
+ from typing import Any, Dict, List
10
10
 
11
11
  from fastapi import APIRouter, Response
12
+ from fastapi.responses import StreamingResponse
12
13
  from pydantic import BaseModel
13
14
 
14
15
  from uiautodev import command_proxy
@@ -27,7 +28,7 @@ def make_router(provider: BaseProvider) -> APIRouter:
27
28
 
28
29
  @router.get("/list")
29
30
  def _list() -> List[DeviceInfo]:
30
- """List of Android devices"""
31
+ """List devices"""
31
32
  try:
32
33
  return provider.list_devices()
33
34
  except NotImplementedError as e:
@@ -102,14 +103,25 @@ def make_router(provider: BaseProvider) -> APIRouter:
102
103
  return command_proxy.app_current(driver)
103
104
 
104
105
  @router.post('/{serial}/command/{command}')
105
- def _command_proxy_other(serial: str, command: Command, params: Any = None):
106
+ def _command_proxy_other(serial: str, command: Command, params: Dict[str, Any] = None):
106
107
  """Run a command on the device"""
107
108
  driver = provider.get_device_driver(serial)
108
- func = command_proxy.COMMANDS[command]
109
- if params is None:
110
- response = func(driver)
111
- else:
112
- response = func(driver, params)
109
+ response = command_proxy.send_command(driver, command, params)
113
110
  return response
111
+
112
+ @router.get('/{serial}/backupApp')
113
+ def _backup_app(serial: str, packageName: str):
114
+ """Backup app
115
+
116
+ Added in 0.5.0
117
+ """
118
+ driver = provider.get_device_driver(serial)
119
+ file_name = f"{packageName}.apk"
120
+ headers = {
121
+ 'Content-Disposition': f'attachment; filename="{file_name}"'
122
+ }
123
+ return StreamingResponse(driver.open_app_file(packageName), headers=headers)
124
+
125
+
114
126
 
115
127
  return router
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.4.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,13 +13,11 @@ 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
17
- Provides-Extra: appium
16
+ Classifier: Programming Language :: Python :: 3.13
18
17
  Requires-Dist: adbutils (>=2.7.0,<3.0.0)
19
- Requires-Dist: appium-python-client (>=4.0.0,<5.0.0) ; extra == "appium"
20
18
  Requires-Dist: click (>=8.1.7,<9.0.0)
21
19
  Requires-Dist: construct
22
20
  Requires-Dist: fastapi (>=0.111.0,<0.112.0)
23
- Requires-Dist: httpretty (>=1.1.4,<2.0.0)
24
21
  Requires-Dist: httpx
25
22
  Requires-Dist: lxml
26
23
  Requires-Dist: pillow
@@ -30,6 +27,7 @@ Requires-Dist: pygments (>=2)
30
27
  Requires-Dist: uiautomator2 (>=2)
31
28
  Requires-Dist: uvicorn[standard]
32
29
  Requires-Dist: wdapy (>=0.2.2,<0.3.0)
30
+ Project-URL: Homepage, https://uiauto.dev
33
31
  Description-Content-Type: text/markdown
34
32
 
35
33
  # uiautodev
@@ -38,6 +36,8 @@ Description-Content-Type: text/markdown
38
36
 
39
37
  https://uiauto.dev
40
38
 
39
+ > backup site: https://uiauto.devsleep.com
40
+
41
41
  UI Inspector for Android and iOS, help inspector element properties, and auto generate XPath, script.
42
42
 
43
43
  # Install
@@ -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=qyg24JoYZ2bIaFcBNFyeZA8faOTV87Gk978H-l29GWE,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=VBs5wDfmdBIyQQ8Nda0ACe84RRIAd8KRttrjAxm9YJc,6234
7
- uiautodev/command_proxy.py,sha256=87n1s27xoslKKJ0jkfGWHuUhsJsCANAYx6v_plgKDW0,5007
8
- uiautodev/command_types.py,sha256=Kf_55jrUr2nxrrZorg4urlruKx0cnsuXQBEzKeUXpJA,1736
9
- uiautodev/common.py,sha256=t1jmG7S0LVXAigtg86J3vM2XXf1xYPfDV_HwSwyl3OI,552
10
- uiautodev/driver/android.py,sha256=xtMAPWHrc53MbZyRj1d9mqaqaL1eyVI6ORv3BEd0Epg,7207
11
- uiautodev/driver/appium.py,sha256=U3TGpOXmu3tEa3E1ttTFoXehOfFyjavJQ3XA4CtqeBE,5308
12
- uiautodev/driver/base_driver.py,sha256=f-C8vfE1F6EgDTUeBsv7UBTynmqhYq5BNMi4wawUIvM,2517
13
- uiautodev/driver/ios.py,sha256=U0zozuYs-hCqKCb9O5-Vyuku08gkgQuoUF4-xVWkg1U,4238
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=qDKJyssJYIv_7IJwYHUtFbk-qF7ZquTaNAnhm6J8WcE,827
19
- uiautodev/provider.py,sha256=HDD_Jj-cJVfBceunzCYU9zJvGVya7Jd35GG9h85BY-0,2370
20
- uiautodev/router/device.py,sha256=lbHmoV--qBDP-lV9UVDYKF669WwxMZCDp-OCpoQJKQU,4425
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.4.0.dist-info/LICENSE,sha256=RyeW676gBYO7AVVP2zQgfEx5rPSt46vR47xXZe7TlX4,1068
27
- uiautodev-0.4.0.dist-info/METADATA,sha256=tY-frsy05wnBaJfTOmISViH1v20e7xq8xPnw6LmtzYE,2404
28
- uiautodev-0.4.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
29
- uiautodev-0.4.0.dist-info/entry_points.txt,sha256=zBY8GgseYAAzPFA5Cf4rCCS9ivdyWsNxMVVYIaGAHJU,88
30
- uiautodev-0.4.0.dist-info/RECORD,,