本文整理匯總了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()