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


Python environ.Env方法代码示例

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


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

示例1: create_watchedforks

# 需要导入模块: import environ [as 别名]
# 或者: from environ import Env [as 别名]
def create_watchedforks(apps, schema_editor):

        env = environ.Env()

        WatchedPullRequest = apps.get_model('pr_watch', 'WatchedPullRequest')
        WatchedFork = apps.get_model('pr_watch', 'WatchedFork')

        if WatchedPullRequest.objects.count() == 0:
            # This Ocim instance isn't used yet to watch PRs, so we should keep that feature disabled, therefore
            # we don't create any fork to watch
            return

        # To make all PR keep working, we try to use the old "watched fork name" and "watched organization" defined in
        # the .env file if they are still there (this will be the case when migrating instances which had PRs watcher).
        # After WATCH_FORK and WATCH_ORGANIZATION are removed from .env, we fall back to other sensible defaults
        fork_name = env("WATCH_FORK", default=getattr(settings, 'DEFAULT_FORK', None) or 'edx/edx-platform')
        organization = env("WATCH_ORGANIZATION", default='edx')
        default_fork = WatchedFork.objects.create(
            enabled=True,
            fork=fork_name,
            organization=organization,
        )
        for pr in WatchedPullRequest.objects.all():
            pr.watched_fork = default_fork
            pr.save() 
开发者ID:open-craft,项目名称:opencraft,代码行数:27,代码来源:0004_auto_20171108_1805.py


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