日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程语言 > python >内容正文

python

python execute_command err_Python management.execute_from_command_line方法代碼示例

發(fā)布時間:2023/12/4 python 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python execute_command err_Python management.execute_from_command_line方法代碼示例 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

本文整理匯總了Python中django.core.management.execute_from_command_line方法的典型用法代碼示例。如果您正苦於以下問題:Python management.execute_from_command_line方法的具體用法?Python management.execute_from_command_line怎麼用?Python management.execute_from_command_line使用的例子?那麼恭喜您, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進(jìn)一步了解該方法所在模塊django.core.management的用法示例。

在下文中一共展示了management.execute_from_command_line方法的15個代碼示例,這些例子默認(rèn)根據(jù)受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於我們的係統(tǒng)推薦出更棒的Python代碼示例。

示例1: runtests

?點讚 6

?

# 需要導(dǎo)入模塊: from django.core import management [as 別名]

# 或者: from django.core.management import execute_from_command_line [as 別名]

def runtests():

parsed_args, unparsed_args = parse_args()

only_wagtailmenus = r'^wagtailmenus(\.|$)'

if parsed_args.deprecation == 'all':

# Show all deprecation warnings from all packages

warnings.simplefilter('default', category=DeprecationWarning)

warnings.simplefilter('default', category=PendingDeprecationWarning)

elif parsed_args.deprecation == 'pending':

# Show all deprecation warnings

warnings.filterwarnings('default', category=DeprecationWarning, module=only_wagtailmenus)

warnings.filterwarnings('default', category=PendingDeprecationWarning, module=only_wagtailmenus)

elif parsed_args.deprecation == 'imminent':

# Show only imminent deprecation warnings

warnings.filterwarnings('default', category=DeprecationWarning, module=only_wagtailmenus)

elif parsed_args.deprecation == 'none':

# Deprecation warnings are ignored

pass

argv = [sys.argv[0], 'test'] + unparsed_args

return execute_from_command_line(argv)

開發(fā)者ID:rkhleics,項目名稱:wagtailmenus,代碼行數(shù):23,

示例2: execute_from_command_line

?點讚 6

?

# 需要導(dǎo)入模塊: from django.core import management [as 別名]

# 或者: from django.core.management import execute_from_command_line [as 別名]

def execute_from_command_line():

# Limit concurrency in all thread-pools to ONE.

from maasserver.utils import threads

threads.install_default_pool(maxthreads=1)

threads.install_database_unpool(maxthreads=1)

# Disable all database connections in the reactor.

from maasserver.utils import orm

from twisted.internet import reactor

assert not reactor.running, "The reactor has been started too early."

reactor.callFromThread(orm.disable_all_database_connections)

# Configure logging; Django is no longer responsible for this. Behave as

# if we're always at an interactive terminal (i.e. do not wrap stdout or

# stderr with log machinery).

from provisioningserver import logger

logger.configure(mode=logger.LoggingMode.COMMAND)

# Hand over to Django.

from django.core import management

management.execute_from_command_line()

開發(fā)者ID:maas,項目名稱:maas,代碼行數(shù):24,

示例3: test_call_cli

?點讚 5

?

# 需要導(dǎo)入模塊: from django.core import management [as 別名]

# 或者: from django.core.management import execute_from_command_line [as 別名]

def test_call_cli():

execute_from_command_line(["./manage.py", "testcmd"])

with pytest.raises(RuntimeError):

execute_from_command_line(["./manage.py", "testcmd", "--raise"])

開發(fā)者ID:GaretJax,項目名稱:django-click,代碼行數(shù):6,

示例4: test_django_verbosity

?點讚 5

?

# 需要導(dǎo)入模塊: from django.core import management [as 別名]

# 或者: from django.core.management import execute_from_command_line [as 別名]

def test_django_verbosity(capsys, manage):

# Make sure any command can be called, even if it does not explictly

# accept the --verbosity option

with pytest.raises(RuntimeError):

execute_from_command_line(

["./manage.py", "testcmd", "--raise", "--verbosity", "1"]

)

# Default

execute_from_command_line(["./manage.py", "ctxverbositycmd"])

out, err = capsys.readouterr()

assert out == "1"

# Explicit

execute_from_command_line(["./manage.py", "ctxverbositycmd", "--verbosity", "2"])

out, err = capsys.readouterr()

assert out == "2"

# Invalid

out = manage("ctxverbositycmd", "--verbosity", "4", ignore_errors=True)

out = out.replace(b"'", b'"') # may contain both single and double quotes

assert out == (

b"Usage: manage.py ctxverbositycmd [OPTIONS]\n"

b"\n"

b'Error: Invalid value for "-v" / "--verbosity": 4 is not in the '

b"valid range of 0 to 3.\n"

)

# Default (option)

execute_from_command_line(["./manage.py", "argverbositycommand"])

out, err = capsys.readouterr()

assert out == "1"

# Explicit (option)

execute_from_command_line(

["./manage.py", "argverbositycommand", "--verbosity", "2"]

)

out, err = capsys.readouterr()

assert out == "2"

開發(fā)者ID:GaretJax,項目名稱:django-click,代碼行數(shù):41,

示例5: test_django_help

?點讚 5

?

# 需要導(dǎo)入模塊: from django.core import management [as 別名]

# 或者: from django.core.management import execute_from_command_line [as 別名]

def test_django_help(manage):

# The -h/--help switches cause the program to exit. Invoking the command

# through execute_from_command_line would cause the test suite to exit as

# well... this means that we have to call it in a subprocess.

helps = [

manage("helpcmd", "-h"),

manage("helpcmd", "--help"),

manage("help", "helpcmd"),

]

assert len(set(helps)) == 1

help_text = helps[0]

assert b"HELP_CALLED" not in help_text

assert help_text.startswith(b"Usage: manage.py helpcmd ")

開發(fā)者ID:GaretJax,項目名稱:django-click,代碼行數(shù):16,

示例6: test_group_command

?點讚 5

?

# 需要導(dǎo)入模塊: from django.core import management [as 別名]

# 或者: from django.core.management import execute_from_command_line [as 別名]

def test_group_command(capsys):

execute_from_command_line(["./manage.py", "groupcmd"])

out, err = capsys.readouterr()

assert out == "group_command\n"

execute_from_command_line(["./manage.py", "groupcmd", "subcmd1"])

out, err = capsys.readouterr()

assert out == "group_command\nSUB1\n"

execute_from_command_line(["./manage.py", "groupcmd", "subcmd3"])

out, err = capsys.readouterr()

assert out == "group_command\nSUB2\n"

開發(fā)者ID:GaretJax,項目名稱:django-click,代碼行數(shù):14,

示例7: django_cmd

?點讚 5

?

# 需要導(dǎo)入模塊: from django.core import management [as 別名]

# 或者: from django.core.management import execute_from_command_line [as 別名]

def django_cmd(args: list):

if 'runserver' not in args:

# cd to "web" directory

os.chdir(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'web'))

elif len(args) <= 1:

bind_host = _get_bind_socket()

args.append(bind_host)

os.environ.setdefault("DJANGO_SETTINGS_MODULE", WEB_PACKAGE + ".settings")

management.execute_from_command_line([EXEC_PATH + ' --django', ] + args)

開發(fā)者ID:offensive-hub,項目名稱:black-widow,代碼行數(shù):11,

示例8: run

?點讚 5

?

# 需要導(dǎo)入模塊: from django.core import management [as 別名]

# 或者: from django.core.management import execute_from_command_line [as 別名]

def run():

settings_path = os.path.join(os.getcwd(), 'deeru')

settings_py = os.path.join(settings_path, 'settings.py')

if os.path.exists(settings_py):

sys.path.insert(0, os.getcwd())

os.environ['DJANGO_SETTINGS_MODULE'] = 'deeru.settings'

else:

settings.configure(INSTALLED_APPS=['deeru_cmd.apps.DeerUCmdConfig'])

management.execute_from_command_line()

開發(fā)者ID:gojuukaze,項目名稱:DeerU,代碼行數(shù):13,

示例9: run_tests

?點讚 5

?

# 需要導(dǎo)入模塊: from django.core import management [as 別名]

# 或者: from django.core.management import execute_from_command_line [as 別名]

def run_tests(self):

from django.core import management

DSM = 'DJANGO_SETTINGS_MODULE'

if DSM not in os.environ:

os.environ[DSM] = 'trackstats.tests.settings'

management.execute_from_command_line()

開發(fā)者ID:pennersr,項目名稱:django-trackstats,代碼行數(shù):8,

示例10: execute_django_command

?點讚 5

?

# 需要導(dǎo)入模塊: from django.core import management [as 別名]

# 或者: from django.core.management import execute_from_command_line [as 別名]

def execute_django_command(cmd):

command = ['manage.py']

command.extend(cmd)

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'settings')

try:

from django.core.management import execute_from_command_line

except ImportError as exc:

raise ImportError(

"Couldn't import Django. Are you sure it's installed and "

"available on your PYTHONPATH environment variable? Did you "

"forget to activate a virtual environment?"

) from exc

return execute_from_command_line(command)

開發(fā)者ID:ZedObaia,項目名稱:django-pyqt,代碼行數(shù):15,

示例11: test_command_help

?點讚 5

?

# 需要導(dǎo)入模塊: from django.core import management [as 別名]

# 或者: from django.core.management import execute_from_command_line [as 別名]

def test_command_help(self):

with captured_stdout(), captured_stderr():

# `call_command` bypasses the parser; by calling

# `execute_from_command_line` with the help subcommand we

# ensure that there are no issues with the parser itself.

execute_from_command_line(['django-admin', 'help', 'makemessages'])

開發(fā)者ID:nesdis,項目名稱:djongo,代碼行數(shù):8,

示例12: run_tests

?點讚 5

?

# 需要導(dǎo)入模塊: from django.core import management [as 別名]

# 或者: from django.core.management import execute_from_command_line [as 別名]

def run_tests(self):

from django.core import management

DSM = 'DJANGO_SETTINGS_MODULE'

if DSM not in os.environ:

os.environ[DSM] = 'actistream.tests.settings'

management.execute_from_command_line()

開發(fā)者ID:pennersr,項目名稱:django-actistream,代碼行數(shù):8,

示例13: run_regiond_command

?點讚 5

?

# 需要導(dǎo)入模塊: from django.core import management [as 別名]

# 或者: from django.core.management import execute_from_command_line [as 別名]

def run_regiond_command(management, parser):

"""Called to run the regiond command.

The command itself is sys.argv[1] so that is not passed into this function.

"""

# At present, only root should execute regiond commands

if os.getuid() != 0:

raise SystemExit("You can only '%s' as root." % sys.argv[1])

management.execute_from_command_line()

開發(fā)者ID:maas,項目名稱:maas,代碼行數(shù):11,

示例14: run_django

?點讚 5

?

# 需要導(dǎo)入模塊: from django.core import management [as 別名]

# 或者: from django.core.management import execute_from_command_line [as 別名]

def run_django(is_snap, is_devenv):

# Force the production MAAS Django configuration.

if is_snap:

snap_data = os.environ["SNAP_DATA"]

os.environ.update(

{

"DJANGO_SETTINGS_MODULE": "maasserver.djangosettings.snappy",

"MAAS_PATH": os.environ["SNAP"],

"MAAS_ROOT": snap_data,

"MAAS_DATA": os.path.join(os.environ["SNAP_COMMON"], "maas"),

"MAAS_REGION_CONFIG": os.path.join(snap_data, "regiond.conf"),

"MAAS_DNS_CONFIG_DIR": os.path.join(snap_data, "bind"),

"MAAS_PROXY_CONFIG_DIR": os.path.join(snap_data, "proxy"),

"MAAS_SYSLOG_CONFIG_DIR": os.path.join(snap_data, "syslog"),

"MAAS_IMAGES_KEYRING_FILEPATH": (

"/snap/maas/current/usr/share/keyrings/"

"ubuntu-cloudimage-keyring.gpg"

),

"MAAS_THIRD_PARTY_DRIVER_SETTINGS": os.path.join(

os.environ["SNAP"], "etc/maas/drivers.yaml"

),

}

)

elif is_devenv:

os.environ[

"DJANGO_SETTINGS_MODULE"

] = "maasserver.djangosettings.development"

else:

os.environ[

"DJANGO_SETTINGS_MODULE"

] = "maasserver.djangosettings.settings"

# Let Django do the rest.

from django.core import management

management.execute_from_command_line()

開發(fā)者ID:maas,項目名稱:maas,代碼行數(shù):38,

示例15: django_admin

?點讚 5

?

# 需要導(dǎo)入模塊: from django.core import management [as 別名]

# 或者: from django.core.management import execute_from_command_line [as 別名]

def django_admin(*args):

"""Executes a django admin tool from the app directory."""

cwd = os.getcwd()

os.chdir(os.environ['APP_DIR'])

management.execute_from_command_line(['django-admin.py'] + list(args))

os.chdir(cwd)

開發(fā)者ID:google,項目名稱:personfinder,代碼行數(shù):8,

注:本文中的django.core.management.execute_from_command_line方法示例整理自Github/MSDocs等源碼及文檔管理平臺,相關(guān)代碼片段篩選自各路編程大神貢獻(xiàn)的開源項目,源碼版權(quán)歸原作者所有,傳播和使用請參考對應(yīng)項目的License;未經(jīng)允許,請勿轉(zhuǎn)載。

總結(jié)

以上是生活随笔為你收集整理的python execute_command err_Python management.execute_from_command_line方法代碼示例的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。