本文整理汇总了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()