def work(self, s, returns_queue, c):
     try:
         self.do_work(s, returns_queue, c)
     except Exception as err:
         logger.exception("NRPE: Got an unhandled exception: %s", err)
         # Ok I die now
         raise
예제 #2
0
 def try_very_bad_load(cls, mod_dir):
     prev_module = sys.modules.get('module')  # cache locally any previously imported 'module' ..
     logger.warning(
         "Trying to load %r as an (very-)old-style shinken \"module\" : "
         "by adding its path to sys.path. This can be (very) bad in case "
         "of name conflicts within the files part of %s and others "
         "top-level python modules; I'll try to limit that.",
         # by removing the mod_dir from sys.path after while.
         mod_dir, mod_dir
     )
     sys.path.insert(0, mod_dir)
     try:
         return importlib.import_module('module')
     except Exception as err:
         logger.exception("Could not import bare 'module.py' from %s : %s", mod_dir, err)
         return
     finally:
         sys.path.remove(mod_dir)
         if prev_module is not None:  # and restore it after we have loaded our one (or not)
             sys.modules['module'] = prev_module
예제 #3
0
 def try_very_bad_load(cls, mod_dir):
     prev_module = sys.modules.get(
         'module')  # cache locally any previously imported 'module' ..
     logger.warning(
         "Trying to load %r as an (very-)old-style shinken \"module\" : "
         "by adding its path to sys.path. This can be (very) bad in case "
         "of name conflicts within the files part of %s and others "
         "top-level python modules; I'll try to limit that.",
         # by removing the mod_dir from sys.path after while.
         mod_dir,
         mod_dir)
     sys.path.insert(0, mod_dir)
     try:
         return importlib.import_module('module')
     except Exception as err:
         logger.exception("Could not import bare 'module.py' from %s : %s",
                          mod_dir, err)
         return
     finally:
         sys.path.remove(mod_dir)
         if prev_module is not None:  # and restore it after we have loaded our one (or not)
             sys.modules['module'] = prev_module