Source

pida-main / tools / check-importable.py

Full commit
import py.path

pida_root = py.path.local(__file__).dirpath().dirpath()
subdirs = 'pida pida-plugins tests'.split()
plugin_dirs = 'pida/services', 'pida-plugins'

for subdir in subdirs:
    path = pida_root/subdir

    for pyfile in path.visit('*.py'):
        try:
            print pyfile.relto(pida_root),
            pyfile.pyimport()
        except Exception, e:
            print 'not importable', e

from pida.core.service import Service

for plugdir in plugin_dirs:
    path = pida_root/plugdir
    for plugin in path.listdir():
        init = plugin/'__init__.py'
        if not init.check():
            break
        try:
            service = init.pyimport().Service
        except Exception:
            pass  #we already checked that
        else:
            if not issubclass(service, Service):
                print plugin.relto(pida_root), 'broken plugin'