Skip to content

Commit

Permalink
add HTTPTimeoutError
Browse files Browse the repository at this point in the history
  • Loading branch information
codeskyblue committed Aug 9, 2024
1 parent c099bbc commit 75fe286
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1229,6 +1229,8 @@ d.settings['operation_delay'] = (.5, 1)
# 其中 double_click, long_click 都对应click
d.settings['operation_delay_methods'] = ['click', 'swipe', 'drag', 'press']
d.settings['wait_timeout'] = 20.0 # 默认控件等待时间(原生操作,xpath插件的等待时间)
d.settings['max_depth'] = 50 # 默认50,限制dump_hierarchy返回的元素层级
```
对于随着版本升级,设置过期的配置时,会提示Deprecated,但是不会抛异常。
Expand Down
4 changes: 3 additions & 1 deletion uiautomator2/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import adbutils
import requests

from uiautomator2.exceptions import RPCInvalidError, RPCStackOverflowError, UiAutomationNotConnectedError, HTTPError, LaunchUiAutomationError, UiObjectNotFoundError, RPCUnknownError, APKSignatureError, AccessibilityServiceAlreadyRegisteredError
from uiautomator2.exceptions import HTTPTimeoutError, RPCInvalidError, RPCStackOverflowError, UiAutomationNotConnectedError, HTTPError, LaunchUiAutomationError, UiObjectNotFoundError, RPCUnknownError, APKSignatureError, AccessibilityServiceAlreadyRegisteredError
from uiautomator2.abstract import AbstractUiautomatorServer
from uiautomator2.utils import is_version_compatiable
from uiautomator2.version import __apk_version__
Expand Down Expand Up @@ -111,6 +111,8 @@ def _http_request(dev: adbutils.AdbDevice, method: str, path: str, data: Dict[st
print(response.text.rstrip())
print(f"<<< END timed_used = %.3f\n" % (end_time - start_time).total_seconds())
return response
except requests.Timeout as e:
raise HTTPTimeoutError(f"HTTP request timeout: {e}") from e
except requests.RequestException as e:
raise HTTPError(f"HTTP request failed: {e}") from e

Expand Down
1 change: 1 addition & 0 deletions uiautomator2/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class DeviceError(BaseException): ...
class AdbShellError(DeviceError):...
class ConnectError(DeviceError):...
class HTTPError(DeviceError):...
class HTTPTimeoutError(HTTPError):...
class AdbBroadcastError(DeviceError):...

class UiAutomationError(DeviceError):...
Expand Down

0 comments on commit 75fe286

Please sign in to comment.