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