当前位置: 首页>>代码示例>>Python>>正文


Python util.import_module方法代码示例

本文整理汇总了Python中gunicorn.util.import_module方法的典型用法代码示例。如果您正苦于以下问题:Python util.import_module方法的具体用法?Python util.import_module怎么用?Python util.import_module使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gunicorn.util的用法示例。


在下文中一共展示了util.import_module方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: load

# 需要导入模块: from gunicorn import util [as 别名]
# 或者: from gunicorn.util import import_module [as 别名]
def load(self):
        # chdir to the configured path before loading,
        # default is the current dir
        os.chdir(self.cfg.chdir)

        # set settings
        make_default_env(self.cfg)

        # load wsgi application and return it.
        mod = util.import_module("gunicorn.app.django_wsgi")
        return mod.make_wsgi_application() 
开发者ID:RoseOu,项目名称:flasky,代码行数:13,代码来源:djangoapp.py

示例2: get_config_from_module_name

# 需要导入模块: from gunicorn import util [as 别名]
# 或者: from gunicorn.util import import_module [as 别名]
def get_config_from_module_name(self, module_name):
        return util.import_module(module_name).__dict__ 
开发者ID:RoseOu,项目名称:flasky,代码行数:4,代码来源:base.py

示例3: get_config_from_module_name

# 需要导入模块: from gunicorn import util [as 别名]
# 或者: from gunicorn.util import import_module [as 别名]
def get_config_from_module_name(self, module_name):
        return vars(util.import_module(module_name)) 
开发者ID:Agentscreech,项目名称:ShelbySearch,代码行数:4,代码来源:base.py

示例4: load

# 需要导入模块: from gunicorn import util [as 别名]
# 或者: from gunicorn.util import import_module [as 别名]
def load(self):
        # chdir to the configured path before loading,
        # default is the current dir
        os.chdir(self.cfg.chdir)

        # set settings
        make_default_env(self.cfg)

        # load wsgi application and return it.
        mod = util.import_module("gunicorn.app.django_wsgi")
        return mod.make_command_wsgi_application(self.admin_media_path) 
开发者ID:Jeremy-Friedman,项目名称:metrics,代码行数:13,代码来源:djangoapp.py

示例5: reload_django_settings

# 需要导入模块: from gunicorn import util [as 别名]
# 或者: from gunicorn.util import import_module [as 别名]
def reload_django_settings():
        mod = util.import_module(os.environ['DJANGO_SETTINGS_MODULE'])

        # Reload module.
        reload(mod)

        # Reload settings.
        # Use code from django.settings.Settings module.

        # Settings that should be converted into tuples if they're mistakenly entered
        # as strings.
        tuple_settings = ("INSTALLED_APPS", "TEMPLATE_DIRS")

        for setting in dir(mod):
            if setting == setting.upper():
                setting_value = getattr(mod, setting)
                if setting in tuple_settings and type(setting_value) == str:
                    setting_value = (setting_value,)  # In case the user forgot the comma.
                setattr(settings, setting, setting_value)

        # Expand entries in INSTALLED_APPS like "django.contrib.*" to a list
        # of all those apps.
        new_installed_apps = []
        for app in settings.INSTALLED_APPS:
            if app.endswith('.*'):
                app_mod = util.import_module(app[:-2])
                appdir = os.path.dirname(app_mod.__file__)
                app_subdirs = os.listdir(appdir)
                name_pattern = re.compile(r'[a-zA-Z]\w*')
                for d in sorted(app_subdirs):
                    if (name_pattern.match(d) and
                            os.path.isdir(os.path.join(appdir, d))):
                        new_installed_apps.append('%s.%s' % (app[:-2], d))
            else:
                new_installed_apps.append(app)
        setattr(settings, "INSTALLED_APPS", new_installed_apps)

        if hasattr(time, 'tzset') and settings.TIME_ZONE:
            # When we can, attempt to validate the timezone. If we can't find
            # this file, no check happens and it's harmless.
            zoneinfo_root = '/usr/share/zoneinfo'
            if (os.path.exists(zoneinfo_root) and not
                    os.path.exists(os.path.join(zoneinfo_root,
                        *(settings.TIME_ZONE.split('/'))))):
                raise ValueError("Incorrect timezone setting: %s" %
                        settings.TIME_ZONE)
            # Move the time zone info into os.environ. See ticket #2315 for why
            # we don't do this unconditionally (breaks Windows).
            os.environ['TZ'] = settings.TIME_ZONE
            time.tzset()

        # Settings are configured, so we can set up the logger if required
        if getattr(settings, 'LOGGING_CONFIG', False):
            # First find the logging configuration function ...
            logging_config_path, logging_config_func_name = settings.LOGGING_CONFIG.rsplit('.', 1)
            logging_config_module = util.import_module(logging_config_path)
            logging_config_func = getattr(logging_config_module, logging_config_func_name)

            # ... then invoke it with the logging settings
            logging_config_func(settings.LOGGING) 
开发者ID:RoseOu,项目名称:flasky,代码行数:62,代码来源:django_wsgi.py


注:本文中的gunicorn.util.import_module方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。