diff options
author | Nagappan Alagappan <nagappan@gmail.com> | 2013-09-28 22:03:48 -0700 |
---|---|---|
committer | Nagappan Alagappan <nagappan@gmail.com> | 2013-09-28 22:03:48 -0700 |
commit | 004ee6865f21c087629157ec8ec8601ed431cb97 (patch) | |
tree | 550adf19fc7830ff2715daf8c3a1d01e89a2a69b | |
parent | b3e5b1c79e344c6a11e9e4cace8c9e109c986695 (diff) |
Update traceback to log file, if LDTP_DEBUG_FILE environment variable is set
-rw-r--r-- | ldtpd/utils.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/ldtpd/utils.py b/ldtpd/utils.py index 761f48c..86f591b 100644 --- a/ldtpd/utils.py +++ b/ldtpd/utils.py @@ -175,6 +175,7 @@ class Utils: self._custom_logger = _custom_logger self._desktop = pyatspi.Registry.getDesktop(0) self._ldtp_debug = os.environ.get('LDTP_DEBUG', None) + self._ldtp_debug_file = os.environ.get('LDTP_DEBUG_FILE', None) # Initialize atspi2 version to False self._atspi2_ver = False if Utils.cached_apps is None: @@ -315,6 +316,9 @@ class Utils: except: if self._ldtp_debug: print(traceback.format_exc()) + if self._ldtp_debug_file: + with open(self._ldtp_debug_file, "a") as fp: + fp.write(traceback.format_exc()) def _atspi2_workaround(self): if not hasattr(pyatspi, 'Accessible'): @@ -403,6 +407,9 @@ class Utils: # Let us not throw exception, instead continue if self._ldtp_debug: print(traceback.format_exc()) + if self._ldtp_debug_file: + with open(self._ldtp_debug_file, "a") as fp: + fp.write(traceback.format_exc()) continue try: role = acc.getRole() @@ -895,6 +902,9 @@ class Utils: gui.getIndexInParent()) if self._ldtp_debug: print('Window name has #', window_name, obj_index) + if self._ldtp_debug_file: + with open(self._ldtp_debug_file, "a") as fp: + fp.write('Window name has # %s %d', window_name, obj_index) if window_name == obj_index: if self._ldtp_debug: print('Window found', gui, name) @@ -994,7 +1004,7 @@ class Utils: # Traversing object role and appmap role doesn't match if self._ldtp_debug: print("Traversing object role and appmap role " \ - "doesn't match", obj.getRoleName(), _appmap_role) + "doesn't match", obj.getRoleName(), _appmap_role) return None break obj = tmp_obj |