Fix our module import checks.

Review Request #5846 — Created May 20, 2014 and submitted

Information

Review Board
release-2.0.x
767463b...

Reviewers

We have a number of checks to see if we can import certain modules. For
these, we use a combination of import statements and imp.find_module
calls. The reason is that some modules would fail to import on some
systems using imp.find_module.

The reason for that is that imp.find_module doesn't use registered
importers, and therefore can't find modules in zipped eggs. Furthermore,
our usage would cause leaked open file handles, since if the module is
represented by a .pyc file, imp.find_module would pre-import it.

Instead of dealing with all this, I've added a new, single function for
checking if modules can be imported. All checks in the codebase now use
this instead, giving us consistency and fixing the issues with zipped
eggs.

Unit tests pass.

The dev server could be run against Pillow, which wasn't working here before.

Hand-tested some of our modules that are more complex (like the S3 support in
django-storages), with and without the module.

Description From Last Updated

'striptags' imported but unused

reviewbotreviewbot

'checks' imported but unused

reviewbotreviewbot

While there are no strings in here (yet), this should still import unicode_literals.

daviddavid
reviewbot
  1. This is a review from Review Bot.
      Tool: PEP8 Style Checker
      Processed Files:
        reviewboard/admin/checks.py
        reviewboard/manage.py
        reviewboard/admin/import_utils.py
        reviewboard/diffviewer/tests.py
        reviewboard/scmtools/forms.py
      Ignored Files:
    
    
  2. 
      
reviewbot
  1. This is a review from Review Bot.
      Tool: Pyflakes
      Processed Files:
        reviewboard/admin/checks.py
        reviewboard/manage.py
        reviewboard/admin/import_utils.py
        reviewboard/diffviewer/tests.py
        reviewboard/scmtools/forms.py
      Ignored Files:
    
    
  2. reviewboard/manage.py (Diff revision 1)
     
     
    Show all issues
     'striptags' imported but unused
    
  3. reviewboard/manage.py (Diff revision 1)
     
     
    Show all issues
     'checks' imported but unused
    
  4. 
      
chipx86
reviewbot
  1. This is a review from Review Bot.
      Tool: PEP8 Style Checker
      Processed Files:
        reviewboard/admin/checks.py
        reviewboard/manage.py
        reviewboard/admin/import_utils.py
        reviewboard/diffviewer/tests.py
        reviewboard/scmtools/forms.py
      Ignored Files:
    
    
  2. 
      
reviewbot
  1. This is a review from Review Bot.
      Tool: Pyflakes
      Processed Files:
        reviewboard/admin/checks.py
        reviewboard/manage.py
        reviewboard/admin/import_utils.py
        reviewboard/diffviewer/tests.py
        reviewboard/scmtools/forms.py
      Ignored Files:
    
    
  2. 
      
david
  1. 
      
  2. reviewboard/admin/import_utils.py (Diff revision 2)
     
     
    Show all issues

    While there are no strings in here (yet), this should still import unicode_literals.

  3. 
      
chipx86
Review request changed
Status:
Completed
Change Summary:
Pushed to release-2.0.x (8546c5f)