本文整理匯總了Python中os.environ.setdefault方法的典型用法代碼示例。如果您正苦於以下問題:Python environ.setdefault方法的具體用法?Python environ.setdefault怎麽用?Python environ.setdefault使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類os.environ
的用法示例。
在下文中一共展示了environ.setdefault方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: run
# 需要導入模塊: from os import environ [as 別名]
# 或者: from os.environ import setdefault [as 別名]
def run(self):
environ.setdefault("DJANGO_SETTINGS_MODULE", "byro.settings")
try:
import django
except ImportError: # Move to ModuleNotFoundError once we drop Python 3.5
return
django.setup()
from django.conf import settings
from django.core import management
settings.COMPRESS_ENABLED = True
settings.COMPRESS_OFFLINE = True
management.call_command("compilemessages", verbosity=1)
management.call_command("collectstatic", verbosity=1, interactive=False)
management.call_command("compress", verbosity=1)
build.run(self)
示例2: upgrade
# 需要導入模塊: from os import environ [as 別名]
# 或者: from os.environ import setdefault [as 別名]
def upgrade(pargs):
environ['DJANGO_SETTINGS_MODULE'] = 'teamvault.settings'
environ.setdefault("TEAMVAULT_CONFIG_FILE", "/etc/teamvault.cfg")
print("\n### Running migrations...\n")
execute_from_command_line(["", "migrate", "--noinput", "-v", "3", "--traceback"])
print("\n### Gathering static files...\n")
from django.conf import settings
try:
rmtree(settings.STATIC_ROOT)
except FileNotFoundError:
pass
mkdir(settings.STATIC_ROOT)
execute_from_command_line(["", "collectstatic", "--noinput"])
print("\n### Updating search index...\n")
execute_from_command_line(["", "update_search_index"])
示例3: set_debug_flag
# 需要導入模塊: from os import environ [as 別名]
# 或者: from os.environ import setdefault [as 別名]
def set_debug_flag(debug):
global FLASK_DEBUG
FLASK_DEBUG = debug
environ.setdefault('FLASK_DEBUG', '1' if FLASK_DEBUG else '0')
config_flask['debug'] = 'on' if debug else 'off'
示例4: pytest_sessionstart
# 需要導入模塊: from os import environ [as 別名]
# 或者: from os.environ import setdefault [as 別名]
def pytest_sessionstart(session): # pylint: disable=unused-argument
environ.setdefault("OPENTELEMETRY_PYTHON_DJANGO_INSTRUMENT", "True")
示例5: plumbing
# 需要導入模塊: from os import environ [as 別名]
# 或者: from os.environ import setdefault [as 別名]
def plumbing(pargs):
environ['DJANGO_SETTINGS_MODULE'] = 'teamvault.settings'
environ.setdefault("TEAMVAULT_CONFIG_FILE", "/etc/teamvault.cfg")
execute_from_command_line([""] + pargs.plumbing_command[0].split(" "))
示例6: setup
# 需要導入模塊: from os import environ [as 別名]
# 或者: from os.environ import setdefault [as 別名]
def setup(pargs):
environ.setdefault("TEAMVAULT_CONFIG_FILE", "/etc/teamvault.cfg")
create_default_config(environ['TEAMVAULT_CONFIG_FILE'])