Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(4)  |  Call(2)  |  Derive(0)  |  Import(2)
Autodiscovers the pif IP checkers in checkers directory.

        def autodiscover():
    """
    Autodiscovers the pif IP checkers in checkers directory.
    """
    IP_CHECKERS_DIR = get_setting('IP_CHECKERS_DIR')
    IP_CHECKER_MODULE_NAME = get_setting('IP_CHECKER_MODULE_NAME')
    DEBUG = get_setting('DEBUG')

    for app_path in os.listdir(PROJECT_DIR(IP_CHECKERS_DIR)):
        full_app_path = [IP_CHECKERS_DIR]
        full_app_path.append(app_path)
        if os.path.isdir(PROJECT_DIR(full_app_path)):
            try:
                import_module(
                    "pif.%s.%s.%s" % (IP_CHECKERS_DIR, app_path, IP_CHECKER_MODULE_NAME)
                    )
            except ImportError as e:
                if DEBUG:
                    logger.debug(str(e))
            except Exception as e:
                if DEBUG:
                    logger.debug(str(e))
        else:
            pass
        


src/p/i/pif-0.6/src/pif/utils.py   pif(Download)
 
from pif.base import registry
from pif.discover import autodiscover
 
def ensure_autodiscover():
    """
    Ensures the IP checkers are discovered.
    """
    if not registry._registry:
        autodiscover()

src/p/i/pif-0.6/src/pif/tests.py   pif(Download)
import unittest
 
from pif.discover import autodiscover
from pif.utils import get_public_ip, list_checkers
from pif.base import registry, BasePublicIPChecker
    def test_01_autodiscover(self):
        """
        Test ``autodiscover``.
        """
        autodiscover()