forked from openlp/openlp
Logging clean ups
This commit is contained in:
parent
8b71ff765c
commit
5b4bff29fe
@ -81,7 +81,7 @@ class PowerpointController(PresentationController):
|
|||||||
if app_version >= 12:
|
if app_version >= 12:
|
||||||
self.also_supports = ['odp']
|
self.also_supports = ['odp']
|
||||||
except (OSError, ValueError):
|
except (OSError, ValueError):
|
||||||
log.warning('Detection of powerpoint version using registry failed.')
|
log.exception('Detection of powerpoint version using registry failed.')
|
||||||
return True
|
return True
|
||||||
except OSError:
|
except OSError:
|
||||||
pass
|
pass
|
||||||
@ -109,9 +109,8 @@ class PowerpointController(PresentationController):
|
|||||||
if self.process.Presentations.Count > 0:
|
if self.process.Presentations.Count > 0:
|
||||||
return
|
return
|
||||||
self.process.Quit()
|
self.process.Quit()
|
||||||
except (AttributeError, pywintypes.com_error) as e:
|
except (AttributeError, pywintypes.com_error):
|
||||||
log.exception('Exception caught while killing powerpoint process')
|
log.exception('Exception caught while killing powerpoint process')
|
||||||
log.exception(e)
|
|
||||||
trace_error_handler(log)
|
trace_error_handler(log)
|
||||||
self.process = None
|
self.process = None
|
||||||
|
|
||||||
@ -154,9 +153,8 @@ class PowerpointDocument(PresentationDocument):
|
|||||||
if len(ScreenList().screen_list) > 1:
|
if len(ScreenList().screen_list) > 1:
|
||||||
Registry().get('main_window').activateWindow()
|
Registry().get('main_window').activateWindow()
|
||||||
return True
|
return True
|
||||||
except (AttributeError, pywintypes.com_error) as e:
|
except (AttributeError, pywintypes.com_error):
|
||||||
log.exception('Exception caught while loading Powerpoint presentation')
|
log.exception('Exception caught while loading Powerpoint presentation')
|
||||||
log.exception(e)
|
|
||||||
trace_error_handler(log)
|
trace_error_handler(log)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@ -192,9 +190,8 @@ class PowerpointDocument(PresentationDocument):
|
|||||||
if self.presentation:
|
if self.presentation:
|
||||||
try:
|
try:
|
||||||
self.presentation.Close()
|
self.presentation.Close()
|
||||||
except (AttributeError, pywintypes.com_error) as e:
|
except (AttributeError, pywintypes.com_error):
|
||||||
log.exception('Caught exception while closing powerpoint presentation')
|
log.exception('Caught exception while closing powerpoint presentation')
|
||||||
log.exception(e)
|
|
||||||
trace_error_handler(log)
|
trace_error_handler(log)
|
||||||
self.presentation = None
|
self.presentation = None
|
||||||
self.controller.remove_doc(self)
|
self.controller.remove_doc(self)
|
||||||
@ -210,9 +207,8 @@ class PowerpointDocument(PresentationDocument):
|
|||||||
try:
|
try:
|
||||||
if self.controller.process.Presentations.Count == 0:
|
if self.controller.process.Presentations.Count == 0:
|
||||||
return False
|
return False
|
||||||
except (AttributeError, pywintypes.com_error) as e:
|
except (AttributeError, pywintypes.com_error):
|
||||||
log.exception('Caught exception while in is_loaded')
|
log.exception('Caught exception while in is_loaded')
|
||||||
log.exception(e)
|
|
||||||
trace_error_handler(log)
|
trace_error_handler(log)
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
@ -229,9 +225,8 @@ class PowerpointDocument(PresentationDocument):
|
|||||||
return False
|
return False
|
||||||
if self.presentation.SlideShowWindow.View is None:
|
if self.presentation.SlideShowWindow.View is None:
|
||||||
return False
|
return False
|
||||||
except (AttributeError, pywintypes.com_error) as e:
|
except (AttributeError, pywintypes.com_error):
|
||||||
log.exception('Caught exception while in is_active')
|
log.exception('Caught exception while in is_active')
|
||||||
log.exception(e)
|
|
||||||
trace_error_handler(log)
|
trace_error_handler(log)
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
@ -249,9 +244,8 @@ class PowerpointDocument(PresentationDocument):
|
|||||||
self.presentation.SlideShowWindow.View.GotoSlide(self.index_map[self.blank_slide], False)
|
self.presentation.SlideShowWindow.View.GotoSlide(self.index_map[self.blank_slide], False)
|
||||||
if self.blank_click:
|
if self.blank_click:
|
||||||
self.presentation.SlideShowWindow.View.GotoClick(self.blank_click)
|
self.presentation.SlideShowWindow.View.GotoClick(self.blank_click)
|
||||||
except (AttributeError, pywintypes.com_error) as e:
|
except (AttributeError, pywintypes.com_error):
|
||||||
log.exception('Caught exception while in unblank_screen')
|
log.exception('Caught exception while in unblank_screen')
|
||||||
log.exception(e)
|
|
||||||
trace_error_handler(log)
|
trace_error_handler(log)
|
||||||
self.show_error_msg()
|
self.show_error_msg()
|
||||||
# Stop powerpoint from flashing in the taskbar
|
# Stop powerpoint from flashing in the taskbar
|
||||||
@ -273,9 +267,8 @@ class PowerpointDocument(PresentationDocument):
|
|||||||
self.blank_click = self.presentation.SlideShowWindow.View.GetClickIndex()
|
self.blank_click = self.presentation.SlideShowWindow.View.GetClickIndex()
|
||||||
# ppSlideShowBlackScreen = 3
|
# ppSlideShowBlackScreen = 3
|
||||||
self.presentation.SlideShowWindow.View.State = 3
|
self.presentation.SlideShowWindow.View.State = 3
|
||||||
except (AttributeError, pywintypes.com_error) as e:
|
except (AttributeError, pywintypes.com_error):
|
||||||
log.exception('Caught exception while in blank_screen')
|
log.exception('Caught exception while in blank_screen')
|
||||||
log.exception(e)
|
|
||||||
trace_error_handler(log)
|
trace_error_handler(log)
|
||||||
self.show_error_msg()
|
self.show_error_msg()
|
||||||
|
|
||||||
@ -288,9 +281,8 @@ class PowerpointDocument(PresentationDocument):
|
|||||||
try:
|
try:
|
||||||
# ppSlideShowBlackScreen = 3
|
# ppSlideShowBlackScreen = 3
|
||||||
return self.presentation.SlideShowWindow.View.State == 3
|
return self.presentation.SlideShowWindow.View.State == 3
|
||||||
except (AttributeError, pywintypes.com_error) as e:
|
except (AttributeError, pywintypes.com_error):
|
||||||
log.exception('Caught exception while in is_blank')
|
log.exception('Caught exception while in is_blank')
|
||||||
log.exception(e)
|
|
||||||
trace_error_handler(log)
|
trace_error_handler(log)
|
||||||
self.show_error_msg()
|
self.show_error_msg()
|
||||||
else:
|
else:
|
||||||
@ -303,9 +295,8 @@ class PowerpointDocument(PresentationDocument):
|
|||||||
log.debug('stop_presentation')
|
log.debug('stop_presentation')
|
||||||
try:
|
try:
|
||||||
self.presentation.SlideShowWindow.View.Exit()
|
self.presentation.SlideShowWindow.View.Exit()
|
||||||
except (AttributeError, pywintypes.com_error) as e:
|
except (AttributeError, pywintypes.com_error):
|
||||||
log.exception('Caught exception while in stop_presentation')
|
log.exception('Caught exception while in stop_presentation')
|
||||||
log.exception(e)
|
|
||||||
trace_error_handler(log)
|
trace_error_handler(log)
|
||||||
self.show_error_msg()
|
self.show_error_msg()
|
||||||
|
|
||||||
@ -328,9 +319,8 @@ class PowerpointDocument(PresentationDocument):
|
|||||||
ppt_window = None
|
ppt_window = None
|
||||||
try:
|
try:
|
||||||
ppt_window = self.presentation.SlideShowSettings.Run()
|
ppt_window = self.presentation.SlideShowSettings.Run()
|
||||||
except (AttributeError, pywintypes.com_error) as e:
|
except (AttributeError, pywintypes.com_error):
|
||||||
log.exception('Caught exception while in start_presentation')
|
log.exception('Caught exception while in start_presentation')
|
||||||
log.exception(e)
|
|
||||||
trace_error_handler(log)
|
trace_error_handler(log)
|
||||||
self.show_error_msg()
|
self.show_error_msg()
|
||||||
if ppt_window and not Settings().value('presentations/powerpoint control window'):
|
if ppt_window and not Settings().value('presentations/powerpoint control window'):
|
||||||
@ -339,9 +329,8 @@ class PowerpointDocument(PresentationDocument):
|
|||||||
ppt_window.Height = size.height() * 72 / dpi
|
ppt_window.Height = size.height() * 72 / dpi
|
||||||
ppt_window.Left = size.x() * 72 / dpi
|
ppt_window.Left = size.x() * 72 / dpi
|
||||||
ppt_window.Width = size.width() * 72 / dpi
|
ppt_window.Width = size.width() * 72 / dpi
|
||||||
except AttributeError as e:
|
except AttributeError:
|
||||||
log.exception('AttributeError while in start_presentation')
|
log.exception('AttributeError while in start_presentation')
|
||||||
log.exception(e)
|
|
||||||
# Find the presentation window and save the handle for later
|
# Find the presentation window and save the handle for later
|
||||||
self.presentation_hwnd = None
|
self.presentation_hwnd = None
|
||||||
if ppt_window:
|
if ppt_window:
|
||||||
@ -399,9 +388,8 @@ class PowerpointDocument(PresentationDocument):
|
|||||||
ret = next((key for key, slidenum in self.index_map.items() if slidenum == ret), None)
|
ret = next((key for key, slidenum in self.index_map.items() if slidenum == ret), None)
|
||||||
else:
|
else:
|
||||||
ret = self.presentation.SlideShowWindow.View.CurrentShowPosition
|
ret = self.presentation.SlideShowWindow.View.CurrentShowPosition
|
||||||
except (AttributeError, pywintypes.com_error) as e:
|
except (AttributeError, pywintypes.com_error):
|
||||||
log.exception('Caught exception while in get_slide_number')
|
log.exception('Caught exception while in get_slide_number')
|
||||||
log.exception(e)
|
|
||||||
trace_error_handler(log)
|
trace_error_handler(log)
|
||||||
self.show_error_msg()
|
self.show_error_msg()
|
||||||
return ret
|
return ret
|
||||||
@ -431,9 +419,8 @@ class PowerpointDocument(PresentationDocument):
|
|||||||
self.next_step()
|
self.next_step()
|
||||||
else:
|
else:
|
||||||
self.presentation.SlideShowWindow.View.GotoSlide(self.index_map[slide_no])
|
self.presentation.SlideShowWindow.View.GotoSlide(self.index_map[slide_no])
|
||||||
except (AttributeError, pywintypes.com_error) as e:
|
except (AttributeError, pywintypes.com_error):
|
||||||
log.exception('Caught exception while in goto_slide')
|
log.exception('Caught exception while in goto_slide')
|
||||||
log.exception(e)
|
|
||||||
trace_error_handler(log)
|
trace_error_handler(log)
|
||||||
self.show_error_msg()
|
self.show_error_msg()
|
||||||
|
|
||||||
@ -445,9 +432,8 @@ class PowerpointDocument(PresentationDocument):
|
|||||||
try:
|
try:
|
||||||
self.presentation.SlideShowWindow.Activate()
|
self.presentation.SlideShowWindow.Activate()
|
||||||
self.presentation.SlideShowWindow.View.Next()
|
self.presentation.SlideShowWindow.View.Next()
|
||||||
except (AttributeError, pywintypes.com_error) as e:
|
except (AttributeError, pywintypes.com_error):
|
||||||
log.exception('Caught exception while in next_step')
|
log.exception('Caught exception while in next_step')
|
||||||
log.exception(e)
|
|
||||||
trace_error_handler(log)
|
trace_error_handler(log)
|
||||||
self.show_error_msg()
|
self.show_error_msg()
|
||||||
return
|
return
|
||||||
@ -468,9 +454,8 @@ class PowerpointDocument(PresentationDocument):
|
|||||||
log.debug('previous_step')
|
log.debug('previous_step')
|
||||||
try:
|
try:
|
||||||
self.presentation.SlideShowWindow.View.Previous()
|
self.presentation.SlideShowWindow.View.Previous()
|
||||||
except (AttributeError, pywintypes.com_error) as e:
|
except (AttributeError, pywintypes.com_error):
|
||||||
log.exception('Caught exception while in previous_step')
|
log.exception('Caught exception while in previous_step')
|
||||||
log.exception(e)
|
|
||||||
trace_error_handler(log)
|
trace_error_handler(log)
|
||||||
self.show_error_msg()
|
self.show_error_msg()
|
||||||
|
|
||||||
@ -503,8 +488,8 @@ class PowerpointDocument(PresentationDocument):
|
|||||||
slide = self.presentation.Slides(self.index_map[num + 1])
|
slide = self.presentation.Slides(self.index_map[num + 1])
|
||||||
try:
|
try:
|
||||||
text = slide.Shapes.Title.TextFrame.TextRange.Text
|
text = slide.Shapes.Title.TextFrame.TextRange.Text
|
||||||
except Exception as e:
|
except Exception:
|
||||||
log.exception(e)
|
log.exception('Exception raised when getting title text')
|
||||||
text = ''
|
text = ''
|
||||||
titles.append(text.replace('\n', ' ').replace('\x0b', ' ') + '\n')
|
titles.append(text.replace('\n', ' ').replace('\x0b', ' ') + '\n')
|
||||||
note = _get_text_from_shapes(slide.NotesPage.Shapes)
|
note = _get_text_from_shapes(slide.NotesPage.Shapes)
|
||||||
@ -519,9 +504,8 @@ class PowerpointDocument(PresentationDocument):
|
|||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
self.presentation.SlideShowWindow.View.Exit()
|
self.presentation.SlideShowWindow.View.Exit()
|
||||||
except (AttributeError, pywintypes.com_error) as e:
|
except (AttributeError, pywintypes.com_error):
|
||||||
log.exception('Failed to exit Powerpoint presentation after error')
|
log.exception('Failed to exit Powerpoint presentation after error')
|
||||||
log.exception(e)
|
|
||||||
critical_error_message_box(UiStrings().Error, translate('PresentationPlugin.PowerpointDocument',
|
critical_error_message_box(UiStrings().Error, translate('PresentationPlugin.PowerpointDocument',
|
||||||
'An error occurred in the PowerPoint integration '
|
'An error occurred in the PowerPoint integration '
|
||||||
'and the presentation will be stopped. '
|
'and the presentation will be stopped. '
|
||||||
@ -540,7 +524,6 @@ def _get_text_from_shapes(shapes):
|
|||||||
if shape.PlaceholderFormat.Type == 2: # 2 from is enum PpPlaceholderType.ppPlaceholderBody
|
if shape.PlaceholderFormat.Type == 2: # 2 from is enum PpPlaceholderType.ppPlaceholderBody
|
||||||
if shape.HasTextFrame and shape.TextFrame.HasText:
|
if shape.HasTextFrame and shape.TextFrame.HasText:
|
||||||
text += shape.TextFrame.TextRange.Text + '\n'
|
text += shape.TextFrame.TextRange.Text + '\n'
|
||||||
except pywintypes.com_error as e:
|
except pywintypes.com_error:
|
||||||
log.warning('Failed to extract text from powerpoint slide')
|
log.exception('Failed to extract text from powerpoint slide')
|
||||||
log.exception(e)
|
|
||||||
return text
|
return text
|
||||||
|
Loading…
Reference in New Issue
Block a user