Use importlib to check for elasticsearch instead of import statement

Review Request #9099 — Created July 24, 2017 and submitted

Information

Review Board
release-3.0.x
d1dd8ee...

Reviewers

The import elasticsearch statement in elasticsearch.py was
succeeding if the module was not installed because it would find
./elasticsearch.py (itself) and import that instead. We now use
import_module to do the dependency check, which checks for
system-level modules and not local ones.

With this patch applied, I cannot enable elasticsearch when it is not
installed.

david
  1. Ship It!
  2. 
      
chipx86
  1. Where does ./elasticsearch.py come from?

    1. I assume it's reviewboard/search/search_backends/elasticsearch.py. We could also use from __future__ import absolute_import (perhaps we want to add that to our standard header?).

    2. You are correct. The file was importing itself

  2. 
      
brennie
Review request changed
Status:
Completed
Change Summary:
Pushed to release-3.0.x (b33922b)