Merge pull request #89 from mjc/fixup-error-handling
Fix broken and greedy default exception handler, and throw meaningful log message when pywin32 is missing
This commit is contained in:
+13
-1
@@ -4,6 +4,7 @@ from os.path import dirname
|
|||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import signal
|
import signal
|
||||||
|
import socket
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
import traceback
|
import traceback
|
||||||
@@ -121,9 +122,20 @@ if __name__ == '__main__':
|
|||||||
pass
|
pass
|
||||||
except SystemExit:
|
except SystemExit:
|
||||||
raise
|
raise
|
||||||
except Exception as (nr, msg):
|
except socket.error as (nr, msg):
|
||||||
|
# log when socket receives SIGINT, but continue.
|
||||||
|
# previous code would have skipped over other types of IO errors too.
|
||||||
if nr != 4:
|
if nr != 4:
|
||||||
try:
|
try:
|
||||||
l.log.critical(traceback.format_exc())
|
l.log.critical(traceback.format_exc())
|
||||||
except:
|
except:
|
||||||
print traceback.format_exc()
|
print traceback.format_exc()
|
||||||
|
raise
|
||||||
|
except:
|
||||||
|
try:
|
||||||
|
# if this fails we will have two tracebacks
|
||||||
|
# one for failing to log, and one for the exception that got us here.
|
||||||
|
l.log.critical(traceback.format_exc())
|
||||||
|
except:
|
||||||
|
print traceback.format_exc()
|
||||||
|
raise
|
||||||
@@ -51,8 +51,13 @@ class Loader(object):
|
|||||||
did_save += self.loadSettings(m, module_name, save = False)
|
did_save += self.loadSettings(m, module_name, save = False)
|
||||||
|
|
||||||
self.loadPlugins(m, plugin.get('name'))
|
self.loadPlugins(m, plugin.get('name'))
|
||||||
except ImportError:
|
except ImportError as e:
|
||||||
log.debug('Import error, remove the empty folder: %s' % plugin.get('module'))
|
# todo:: subclass ImportError for missing requirements.
|
||||||
|
if (e.message.lower().startswith("missing")):
|
||||||
|
log.error(e.message)
|
||||||
|
pass
|
||||||
|
# todo:: this needs to be more descriptive.
|
||||||
|
log.error('Import error, remove the empty folder: %s' % plugin.get('module'))
|
||||||
except:
|
except:
|
||||||
log.error('Can\'t import %s: %s' % (module_name, traceback.format_exc()))
|
log.error('Can\'t import %s: %s' % (module_name, traceback.format_exc()))
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,15 @@ import os
|
|||||||
import string
|
import string
|
||||||
|
|
||||||
if os.name == 'nt':
|
if os.name == 'nt':
|
||||||
import win32file
|
import imp
|
||||||
|
try:
|
||||||
|
imp.find_module('win32file')
|
||||||
|
except:
|
||||||
|
# todo:: subclass ImportError for missing dependencies, vs. broken plugins?
|
||||||
|
raise ImportError("Missing the win32file module, which is a part of the prerequisite \
|
||||||
|
pywin32 package. You can get it from http://sourceforge.net/projects/pywin32/files/pywin32/");
|
||||||
|
else:
|
||||||
|
import win32file
|
||||||
|
|
||||||
class FileBrowser(Plugin):
|
class FileBrowser(Plugin):
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user