uiautodev 0.9.0__py3-none-any.whl → 0.10.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/__init__.py CHANGED
@@ -5,4 +5,4 @@
5
5
  """
6
6
 
7
7
  # version is auto managed by poetry
8
- __version__ = "0.9.0"
8
+ __version__ = "0.10.0"
uiautodev/app.py CHANGED
@@ -27,6 +27,7 @@ from uiautodev.provider import AndroidProvider, HarmonyProvider, IOSProvider, Mo
27
27
  from uiautodev.remote.scrcpy import ScrcpyServer
28
28
  from uiautodev.router.android import router as android_device_router
29
29
  from uiautodev.router.device import make_router
30
+ from uiautodev.router.proxy import router as proxy_router
30
31
  from uiautodev.router.xml import router as xml_router
31
32
  from uiautodev.utils.envutils import Environment
32
33
 
@@ -70,7 +71,7 @@ else:
70
71
 
71
72
  app.include_router(xml_router, prefix="/api/xml", tags=["xml"])
72
73
  app.include_router(android_device_router, prefix="/api/android", tags=["android"])
73
-
74
+ app.include_router(proxy_router, prefix="/proxy", tags=["proxy"])
74
75
 
75
76
  @app.get('/api/{platform}/features')
76
77
  def get_features(platform: str) -> Dict[str, bool]:
@@ -0,0 +1,58 @@
1
+ import asyncio
2
+
3
+ import httpx
4
+ import websockets
5
+ from fastapi import APIRouter, HTTPException, Request, WebSocket, WebSocketDisconnect
6
+ from fastapi.responses import Response
7
+ import logging
8
+
9
+
10
+ logger = logging.getLogger(__name__)
11
+ router = APIRouter()
12
+
13
+
14
+ # HTTP 转发
15
+ @router.api_route("/http/{target_url:path}", methods=["GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS"])
16
+ async def proxy_http(request: Request, target_url: str):
17
+ logger.info(f"HTTP target_url: {target_url}")
18
+
19
+ async with httpx.AsyncClient(timeout=httpx.Timeout(30.0)) as client:
20
+ body = await request.body()
21
+ resp = await client.request(
22
+ request.method,
23
+ target_url,
24
+ content=body,
25
+ headers={k: v for k, v in request.headers.items() if k.lower() != "host" and k.lower() != "x-target-url"}
26
+ )
27
+ return Response(content=resp.content, status_code=resp.status_code, headers=dict(resp.headers))
28
+
29
+ # WebSocket 转发
30
+ @router.websocket("/ws/{target_url:path}")
31
+ async def proxy_ws(websocket: WebSocket, target_url: str):
32
+ await websocket.accept()
33
+ logger.info(f"WebSocket target_url: {target_url}")
34
+
35
+ try:
36
+ async with websockets.connect(target_url) as target_ws:
37
+ async def from_client():
38
+ while True:
39
+ msg = await websocket.receive_text()
40
+ await target_ws.send(msg)
41
+
42
+ async def from_server():
43
+ while True:
44
+ msg = await target_ws.recv()
45
+ if isinstance(msg, bytes):
46
+ await websocket.send_bytes(msg)
47
+ elif isinstance(msg, str):
48
+ await websocket.send_text(msg)
49
+ else:
50
+ raise RuntimeError("Unknown message type", msg)
51
+
52
+ await asyncio.gather(from_client(), from_server())
53
+
54
+ except WebSocketDisconnect:
55
+ pass
56
+ except Exception as e:
57
+ logger.error(f"WS Error: {e}")
58
+ await websocket.close()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: uiautodev
3
- Version: 0.9.0
3
+ Version: 0.10.0
4
4
  Summary: Mobile UI Automation, include UI hierarchy inspector, script recorder
5
5
  License: MIT
6
6
  Author: codeskyblue
@@ -18,7 +18,7 @@ Requires-Dist: Pillow
18
18
  Requires-Dist: adbutils (>=2.8.10,<3)
19
19
  Requires-Dist: click (>=8.1.7,<9.0.0)
20
20
  Requires-Dist: construct
21
- Requires-Dist: fastapi (==0.115.12)
21
+ Requires-Dist: fastapi (>=0.115.12,<1)
22
22
  Requires-Dist: httpx
23
23
  Requires-Dist: lxml
24
24
  Requires-Dist: pydantic (>=2.6,<3.0)
@@ -76,31 +76,8 @@ uiauto.dev
76
76
  ```
77
77
 
78
78
  # DEVELOP
79
- ```bash
80
- # install poetry (python package manager)
81
- pip install poetry # pipx install poetry
82
-
83
- # install deps
84
- poetry install
85
-
86
- # format import
87
- make format
88
-
89
- # run server
90
- make dev
91
-
92
- # If you encounter the error NameError: name 'int2byte' is not defined,
93
- # try installing a stable version of the construct package to resolve it:
94
- # and restart: make dev
95
- pip install construct==2.9.45
96
79
 
97
- ```
98
-
99
- 运行测试
100
-
101
- ```sh
102
- make test
103
- ```
80
+ see [DEVELOP.md](DEVELOP.md)
104
81
 
105
82
  # Links
106
83
  - https://app.tangoapp.dev/ 基于webadb的手机远程控制项目
@@ -1,6 +1,6 @@
1
- uiautodev/__init__.py,sha256=xnnSwBwXCdefqGY7chm-k1RRinNr23HzJlgmEtscr4E,164
1
+ uiautodev/__init__.py,sha256=TXoecsIhto8S54V7jn6x4PdNIlhxaTPTQgtpSKQWcq0,165
2
2
  uiautodev/__main__.py,sha256=0WZHyHW-M7FG5RexANNoIB5pkCX8xwQbTnmaOA9Y1kg,176
3
- uiautodev/app.py,sha256=8UBmP__ixvyoOW3ufiy_CwrHqxFym6sJjfEO8_1mwVQ,6477
3
+ uiautodev/app.py,sha256=K3u6WCobH3Q5HmXvrZff0Cq44L0j1J4eBVhSxnSNKiE,6600
4
4
  uiautodev/appium_proxy.py,sha256=yMzPnIDo50hYSaq0g5bXUpgRrFa_849wNa2o7ZpxGNY,1773
5
5
  uiautodev/binaries/scrcpy_server.jar,sha256=ojxWWfNsJg8QXAItJ7yz6v_6JgcOe6qe2mbQE3ehrbo,71200
6
6
  uiautodev/case.py,sha256=Jk2_5X2F-XIPnGuYTCqOVQiwwchwOhF7uKK5oKv5shg,3919
@@ -27,14 +27,15 @@ uiautodev/remote/scrcpy.py,sha256=JNSwC35f4os-IQW4ixx7ky9clpqRWvA8X_obUkwuOh8,74
27
27
  uiautodev/remote/touch_controller.py,sha256=dYl5XTLaYEyZiNJmKwHQpw9QhPSkN3iUetJSaiQJBHg,4255
28
28
  uiautodev/router/android.py,sha256=xwzaZduMRJsyml-7eZjNtQMg_c22ZpFAq6TErc_-tlA,1358
29
29
  uiautodev/router/device.py,sha256=iNJUexRLUmgGT_n1UgWybX8PvRSDinpoUpvKX-NZi10,4298
30
+ uiautodev/router/proxy.py,sha256=Jn9emYCWJCl5nxI6f4lwXNaaZy4kAmfWL-nj9hSKGnA,2007
30
31
  uiautodev/router/xml.py,sha256=MKVLhjMBqE4qbEraQxvdrVp_OBnylEL9Wti5lnmBDk4,891
31
32
  uiautodev/static/demo.html,sha256=qC7qUZP5Af9T3V5EuFGbovzv8mArwiGMWsX_vcs_Bt0,1240
32
33
  uiautodev/utils/common.py,sha256=L1qBBBS6jRgkXlGy5o6Xafo49auLXKRWyX9x8U_IKjc,4821
33
34
  uiautodev/utils/envutils.py,sha256=Clyt2Hz9PXpK_fT0yWbMmixXyGvCaJO3LAgamM7aUVc,197
34
35
  uiautodev/utils/exceptions.py,sha256=lL_G_E41KWvfXnl32-E4Vgr3_HyTboxq_EwzdQMuvK4,637
35
36
  uiautodev/utils/usbmux.py,sha256=LYupLDn7U4KFKhYQJrmIroS-3040gqZQVDRDB_FNDJM,17386
36
- uiautodev-0.9.0.dist-info/LICENSE,sha256=RyeW676gBYO7AVVP2zQgfEx5rPSt46vR47xXZe7TlX4,1068
37
- uiautodev-0.9.0.dist-info/METADATA,sha256=8S_BL5Us0UHrKNVZuzmvMB0ujdCjIOoNX9VYm6I74RI,2936
38
- uiautodev-0.9.0.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
39
- uiautodev-0.9.0.dist-info/entry_points.txt,sha256=zBY8GgseYAAzPFA5Cf4rCCS9ivdyWsNxMVVYIaGAHJU,88
40
- uiautodev-0.9.0.dist-info/RECORD,,
37
+ uiautodev-0.10.0.dist-info/LICENSE,sha256=RyeW676gBYO7AVVP2zQgfEx5rPSt46vR47xXZe7TlX4,1068
38
+ uiautodev-0.10.0.dist-info/METADATA,sha256=w48FCoinwhnidWaoG5UPjAA8IplnMFGcCjFb1uIM384,2555
39
+ uiautodev-0.10.0.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
40
+ uiautodev-0.10.0.dist-info/entry_points.txt,sha256=zBY8GgseYAAzPFA5Cf4rCCS9ivdyWsNxMVVYIaGAHJU,88
41
+ uiautodev-0.10.0.dist-info/RECORD,,