From c4a45a17cc9492746ff93e37d5c589801deafa2e Mon Sep 17 00:00:00 2001 From: Phil Date: Tue, 6 Jul 2010 19:30:51 +0200 Subject: [PATCH] Catch exceptions from layers imports and print a warning message instead of crashing --- scapy/layers/all.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scapy/layers/all.py b/scapy/layers/all.py index 6251c2a59..c3e4b82c2 100644 --- a/scapy/layers/all.py +++ b/scapy/layers/all.py @@ -5,6 +5,8 @@ from scapy.config import conf from scapy.error import log_loading +import logging +log = logging.getLogger("scapy.loading") def _import_star(m): mod = __import__(m, globals(), locals()) @@ -13,7 +15,10 @@ def _import_star(m): for _l in conf.load_layers: log_loading.debug("Loading layer %s" % _l) - _import_star(_l) + try: + _import_star(_l) + except Exception,e: + log.warning("can't import layer %s: %s" % (_l,e))