-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8dd3954
commit 0c6b98d
Showing
14 changed files
with
212 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[tool.poetry] | ||
name = "uiviewer" | ||
version = "1.0.0" | ||
version = "1.0.1" | ||
description = "UI hierarchy visualization tool, supporting Android, iOS, HarmonyOS NEXT." | ||
authors = ["codematrixer <[email protected]>"] | ||
license = "MIT" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
import logging | ||
|
||
formatter = logging.Formatter('[%(asctime)s] %(filename)15s[line:%(lineno)4d] \ | ||
[%(levelname)s] %(message)s', | ||
datefmt='%Y-%m-%d %H:%M:%S') | ||
|
||
logger = logging.getLogger('hmdriver2') | ||
logger.setLevel(logging.DEBUG) | ||
|
||
console_handler = logging.StreamHandler() | ||
console_handler.setLevel(logging.DEBUG) | ||
console_handler.setFormatter(formatter) | ||
|
||
logger.addHandler(console_handler) | ||
|
||
|
||
__all__ = ['logger'] | ||
# -*- coding: utf-8 -*- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
import logging | ||
|
||
formatter = logging.Formatter('[%(asctime)s] %(filename)15s[line:%(lineno)4d] \ | ||
[%(levelname)s] %(message)s', | ||
datefmt='%Y-%m-%d %H:%M:%S') | ||
|
||
logger = logging.getLogger('hmdriver2') | ||
logger.setLevel(logging.DEBUG) | ||
|
||
console_handler = logging.StreamHandler() | ||
console_handler.setLevel(logging.DEBUG) | ||
console_handler.setFormatter(formatter) | ||
|
||
logger.addHandler(console_handler) | ||
|
||
|
||
__all__ = ['logger'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
import importlib.metadata | ||
|
||
__version__ = importlib.metadata.version('uiviewer') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# -*- coding: utf-8 -*- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from typing import Union, Optional | ||
|
||
from fastapi import APIRouter, Query | ||
from fastapi.responses import RedirectResponse | ||
|
||
from uiviewer._device import ( | ||
list_serials, | ||
init_device, | ||
cached_devices, | ||
AndroidDevice, | ||
IosDevice, | ||
HarmonyDevice | ||
) | ||
from uiviewer._models import ApiResponse | ||
from uiviewer._version import __version__ | ||
|
||
|
||
router = APIRouter() | ||
|
||
|
||
@router.get("/") | ||
def root(): | ||
return RedirectResponse(url="/static/index.html") | ||
|
||
|
||
@router.get("/health") | ||
def health(): | ||
return "ok" | ||
|
||
|
||
@router.get("/version", response_model=ApiResponse) | ||
def get_version(): | ||
return ApiResponse.doSuccess(__version__) | ||
|
||
|
||
@router.get("/{platform}/serials", response_model=ApiResponse) | ||
def get_serials(platform: str): | ||
serials = list_serials(platform) | ||
return ApiResponse.doSuccess(serials) | ||
|
||
|
||
@router.post("/{platform}/{serial}/connect", response_model=ApiResponse) | ||
def connect( | ||
platform: str, | ||
serial: str, | ||
wdaUrl: Union[str, None] = Query(None), | ||
maxDepth: Union[int, None] = Query(None) | ||
): | ||
ret = init_device(platform, serial, wdaUrl, maxDepth) | ||
return ApiResponse.doSuccess(ret) | ||
|
||
|
||
@router.get("/{platform}/{serial}/screenshot", response_model=ApiResponse) | ||
def screenshot(platform: str, serial: str): | ||
device: Union[AndroidDevice, IosDevice, HarmonyDevice] = cached_devices.get((platform, serial)) | ||
data = device.take_screenshot() | ||
return ApiResponse.doSuccess(data) | ||
|
||
|
||
@router.get("/{platform}/{serial}/hierarchy", response_model=ApiResponse) | ||
def dump_hierarchy(platform: str, serial: str): | ||
device: Union[AndroidDevice, IosDevice, HarmonyDevice] = cached_devices.get((platform, serial)) | ||
data = device.dump_hierarchy() | ||
return ApiResponse.doSuccess(data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.