From 9351f0fb09e6aa9b12efd428c44c9a750911801c Mon Sep 17 00:00:00 2001 From: twoyang0917 Date: Wed, 20 Mar 2024 14:43:16 +0800 Subject: [PATCH] catch exception when _run_watchers (#898) * catch exception when _run_watchers * update setup.cfg --------- Co-authored-by: yangyang --- setup.cfg | 8 ++++---- uiautomator2/watcher.py | 8 ++++++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/setup.cfg b/setup.cfg index be7f21d1..cf1f5cb9 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,11 +1,11 @@ [metadata] name = uiautomator2 author = codeskyblue -author-email = codeskyblue@gmail.com +author_email = codeskyblue@gmail.com summary = Python Wrapper for Google Android UiAutomator2 test tool license = MIT -description-file = ABOUT.rst -home-page = https://github.com/openatx/uiautomator2 +description_file = ABOUT.rst +home_page = https://github.com/openatx/uiautomator2 # all classifier can be found in https://pypi.python.org/pypi?%3Aaction=list_classifiers classifier = Development Status :: 4 - Beta @@ -32,5 +32,5 @@ image = [entry_points] # https://docs.openstack.org/pbr/3.1.1/#entry-points -console_scripts = +console_scripts = uiautomator2 = uiautomator2.__main__:main diff --git a/uiautomator2/watcher.py b/uiautomator2/watcher.py index f66ed949..770db565 100644 --- a/uiautomator2/watcher.py +++ b/uiautomator2/watcher.py @@ -53,7 +53,7 @@ def wait_stable(self, seconds: float = 5.0, timeout: float = 60.0): Args: seconds: stable seconds timeout: raise error when wait stable timeout - + Raises: TimeoutError """ @@ -236,7 +236,11 @@ def run(self, source: Optional[str] = None): """ if self.triggering: # avoid to run watcher when run watcher return False - return self._run_watchers(source=source) + try: + return self._run_watchers(source=source) + except Exception as e: + self.logger.warning("_run_watchers exception: %s", e) + return False def _run_watchers(self, source=None) -> bool: """