MCPcopy
hub / github.com/YelpArchive/elastalert / get_module

Function get_module

elastalert/util.py:20–31  ·  view source on GitHub ↗

Loads a module and returns a specific object. module_name should 'module.file.object'. Returns object or raises EAException on error.

(module_name)

Source from the content-addressed store, hash-verified

18
19
20def get_module(module_name):
21 """ Loads a module and returns a specific object.
22 module_name should 'module.file.object'.
23 Returns object or raises EAException on error. """
24 sys.path.append(os.getcwd())
25 try:
26 module_path, module_class = module_name.rsplit('.', 1)
27 base_module = __import__(module_path, globals(), locals(), [module_class])
28 module = getattr(base_module, module_class)
29 except (ImportError, AttributeError, ValueError) as e:
30 raise EAException("Could not import module %s: %s" % (module_name, e)).with_traceback(sys.exc_info()[2])
31 return module
32
33
34def new_get_event_ts(ts_field):

Callers 3

load_confFunction · 0.85
load_modulesMethod · 0.85
create_alertMethod · 0.85

Calls 2

EAExceptionClass · 0.85
appendMethod · 0.80

Tested by

no test coverage detected