Added logging of full stacktraces

This commit is contained in:
Tomas Groth 2014-06-24 09:01:41 +02:00
parent fee8a1c4a3
commit 788ab206f9

View File

@ -138,12 +138,14 @@ class PowerpointDocument(PresentationDocument):
try: try:
self.presentation.Application.WindowState = 2 self.presentation.Application.WindowState = 2
except: except:
log.error(u'Failed to minimize main powerpoint window') log.exception(u'Failed to minimize main powerpoint window')
exc_type, exc_value, exc_traceback = sys.exc_info()
log.exception(''.join(traceback.format_exception(exc_type, exc_value, exc_traceback)))
return True return True
except pywintypes.com_error as e: except pywintypes.com_error:
log.error(u'PPT open failed') log.exception(u'PPT open failed')
log.error(e) exc_type, exc_value, exc_traceback = sys.exc_info()
log.exception(''.join(traceback.format_exception(exc_type, exc_value, exc_traceback)))
return False return False
def create_thumbnails(self): def create_thumbnails(self):
@ -228,9 +230,10 @@ class PowerpointDocument(PresentationDocument):
self.presentation.SlideShowWindow.View.GotoSlide(slide) self.presentation.SlideShowWindow.View.GotoSlide(slide)
if click: if click:
self.presentation.SlideShowWindow.View.GotoClick(click) self.presentation.SlideShowWindow.View.GotoClick(click)
except pywintypes.com_error as e: except pywintypes.com_error:
log.error(u'COM error while in unblank_screen') log.exception(u'COM error while in unblank_screen')
log.error(e) exc_type, exc_value, exc_traceback = sys.exc_info()
log.exception(''.join(traceback.format_exception(exc_type, exc_value, exc_traceback)))
self.show_error_msg() self.show_error_msg()
def blank_screen(self): def blank_screen(self):
@ -240,9 +243,10 @@ class PowerpointDocument(PresentationDocument):
log.debug(u'blank_screen') log.debug(u'blank_screen')
try: try:
self.presentation.SlideShowWindow.View.State = 3 self.presentation.SlideShowWindow.View.State = 3
except pywintypes.com_error as e: except pywintypes.com_error:
log.error(u'COM error while in blank_screen') log.exception(u'COM error while in blank_screen')
log.error(e) exc_type, exc_value, exc_traceback = sys.exc_info()
log.exception(''.join(traceback.format_exception(exc_type, exc_value, exc_traceback)))
self.show_error_msg() self.show_error_msg()
def is_blank(self): def is_blank(self):
@ -253,9 +257,10 @@ class PowerpointDocument(PresentationDocument):
if self.is_active(): if self.is_active():
try: try:
return self.presentation.SlideShowWindow.View.State == 3 return self.presentation.SlideShowWindow.View.State == 3
except pywintypes.com_error as e: except pywintypes.com_error:
log.error(u'COM error while in is_blank') log.exception(u'COM error while in is_blank')
log.error(e) exc_type, exc_value, exc_traceback = sys.exc_info()
log.exception(''.join(traceback.format_exception(exc_type, exc_value, exc_traceback)))
return False return False
else: else:
return False return False
@ -268,9 +273,9 @@ class PowerpointDocument(PresentationDocument):
try: try:
self.presentation.SlideShowWindow.View.Exit() self.presentation.SlideShowWindow.View.Exit()
except pywintypes.com_error as e: except pywintypes.com_error as e:
log.error(u'COM error while in stop_presentation') log.exception(u'COM error while in stop_presentation')
log.error(e) exc_type, exc_value, exc_traceback = sys.exc_info()
log.exception(''.join(traceback.format_exception(exc_type, exc_value, exc_traceback)))
if os.name == u'nt': if os.name == u'nt':
def start_presentation(self): def start_presentation(self):
""" """
@ -297,14 +302,17 @@ class PowerpointDocument(PresentationDocument):
ppt_window.Left = rect.x() * 72 / dpi ppt_window.Left = rect.x() * 72 / dpi
ppt_window.Width = rect.width() * 72 / dpi ppt_window.Width = rect.width() * 72 / dpi
except AttributeError as e: except AttributeError as e:
log.error(u'AttributeError while in start_presentation') log.exception(u'AttributeError while in start_presentation')
log.error(e) exc_type, exc_value, exc_traceback = sys.exc_info()
log.exception(''.join(traceback.format_exception(exc_type, exc_value, exc_traceback)))
# Powerpoint 2013 pops up when starting a file, so we minimize it again # Powerpoint 2013 pops up when starting a file, so we minimize it again
if self.presentation.Application.Version == u'15.0': if self.presentation.Application.Version == u'15.0':
try: try:
self.presentation.Application.WindowState = 2 self.presentation.Application.WindowState = 2
except: except:
log.error(u'Failed to minimize main powerpoint window') log.exception(u'Failed to minimize main powerpoint window')
exc_type, exc_value, exc_traceback = sys.exc_info()
log.exception(''.join(traceback.format_exception(exc_type, exc_value, exc_traceback)))
def get_slide_number(self): def get_slide_number(self):
""" """
@ -315,8 +323,9 @@ class PowerpointDocument(PresentationDocument):
ret = self.presentation.SlideShowWindow.View.CurrentShowPosition ret = self.presentation.SlideShowWindow.View.CurrentShowPosition
except pywintypes.com_error as e: except pywintypes.com_error as e:
ret = 0 ret = 0
log.error(u'COM error while in get_slide_number') log.exception(u'COM error while in get_slide_number')
log.error(e) exc_type, exc_value, exc_traceback = sys.exc_info()
log.exception(''.join(traceback.format_exception(exc_type, exc_value, exc_traceback)))
self.show_error_msg() self.show_error_msg()
return ret return ret
@ -329,8 +338,9 @@ class PowerpointDocument(PresentationDocument):
ret = self.presentation.Slides.Count ret = self.presentation.Slides.Count
except pywintypes.com_error as e: except pywintypes.com_error as e:
ret = 0 ret = 0
log.error(u'COM error while in get_slide_count') log.exception(u'COM error while in get_slide_count')
log.error(e) exc_type, exc_value, exc_traceback = sys.exc_info()
log.exception(''.join(traceback.format_exception(exc_type, exc_value, exc_traceback)))
self.show_error_msg() self.show_error_msg()
return ret return ret
@ -342,8 +352,9 @@ class PowerpointDocument(PresentationDocument):
try: try:
self.presentation.SlideShowWindow.View.GotoSlide(slideno) self.presentation.SlideShowWindow.View.GotoSlide(slideno)
except pywintypes.com_error as e: except pywintypes.com_error as e:
log.error(u'COM error while in goto_slide') log.exception(u'COM error while in goto_slide')
log.error(e) exc_type, exc_value, exc_traceback = sys.exc_info()
log.exception(''.join(traceback.format_exception(exc_type, exc_value, exc_traceback)))
self.show_error_msg() self.show_error_msg()
def next_step(self): def next_step(self):
@ -354,8 +365,9 @@ class PowerpointDocument(PresentationDocument):
try: try:
self.presentation.SlideShowWindow.View.Next() self.presentation.SlideShowWindow.View.Next()
except pywintypes.com_error as e: except pywintypes.com_error as e:
log.error(u'COM error while in next_step') log.exception(u'COM error while in next_step')
log.error(e) exc_type, exc_value, exc_traceback = sys.exc_info()
log.exception(''.join(traceback.format_exception(exc_type, exc_value, exc_traceback)))
self.show_error_msg() self.show_error_msg()
return return
if self.get_slide_number() > self.get_slide_count(): if self.get_slide_number() > self.get_slide_count():
@ -369,8 +381,9 @@ class PowerpointDocument(PresentationDocument):
try: try:
self.presentation.SlideShowWindow.View.Previous() self.presentation.SlideShowWindow.View.Previous()
except pywintypes.com_error as e: except pywintypes.com_error as e:
log.error(u'COM error while in previous_step') log.exception(u'COM error while in previous_step')
log.error(e) exc_type, exc_value, exc_traceback = sys.exc_info()
log.exception(''.join(traceback.format_exception(exc_type, exc_value, exc_traceback)))
self.show_error_msg() self.show_error_msg()
def get_slide_text(self, slide_no): def get_slide_text(self, slide_no):