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

本文整理匯總了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使用的例子?那麽恭喜您, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在模塊django.core.management的用法示例。

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

示例1: runtests

​點讚 6

# 需要導入模塊: 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)

開發者ID:rkhleics,項目名稱:wagtailmenus,代碼行數:23,

示例2: execute_from_command_line

​點讚 6

# 需要導入模塊: 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()

開發者ID:maas,項目名稱:maas,代碼行數:24,

示例3: test_call_cli

​點讚 5

# 需要導入模塊: 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"])

開發者ID:GaretJax,項目名稱:django-click,代碼行數:6,

示例4: test_django_verbosity

​點讚 5

# 需要導入模塊: 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"

開發者ID:GaretJax,項目名稱:django-click,代碼行數:41,

示例5: test_django_help

​點讚 5

# 需要導入模塊: 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 ")

開發者ID:GaretJax,項目名稱:django-click,代碼行數:16,

示例6: test_group_command

​點讚 5

# 需要導入模塊: 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"

開發者ID:GaretJax,項目名稱:django-click,代碼行數:14,

示例7: django_cmd

​點讚 5

# 需要導入模塊: 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)

開發者ID:offensive-hub,項目名稱:black-widow,代碼行數:11,

示例8: run

​點讚 5

# 需要導入模塊: 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()

開發者ID:gojuukaze,項目名稱:DeerU,代碼行數:13,

示例9: run_tests

​點讚 5

# 需要導入模塊: 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()

開發者ID:pennersr,項目名稱:django-trackstats,代碼行數:8,

示例10: execute_django_command

​點讚 5

# 需要導入模塊: 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)

開發者ID:ZedObaia,項目名稱:django-pyqt,代碼行數:15,

示例11: test_command_help

​點讚 5

# 需要導入模塊: 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'])

開發者ID:nesdis,項目名稱:djongo,代碼行數:8,

示例12: run_tests

​點讚 5

# 需要導入模塊: 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()

開發者ID:pennersr,項目名稱:django-actistream,代碼行數:8,

示例13: run_regiond_command

​點讚 5

# 需要導入模塊: 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()

開發者ID:maas,項目名稱:maas,代碼行數:11,

示例14: run_django

​點讚 5

# 需要導入模塊: 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()

開發者ID:maas,項目名稱:maas,代碼行數:38,

示例15: django_admin

​點讚 5

# 需要導入模塊: 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)

開發者ID:google,項目名稱:personfinder,代碼行數:8,

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

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/296939.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

linux脚本多线程,Shell多线程操作及线程数控制实例

前言在业务开发过程中&#xff0c;经常会在后台写一些shell脚本处理数据&#xff0c;但估计很多人不知道shell脚本也可以支持多线程&#xff0c;而且非常简单。本篇文章主要就是介绍shell实现多进程以及进程数量控制。需求为了更好的说明问题&#xff0c;我们结合例子讲解&…

Node.js Undocumented(2)

写这种系列blog&#xff0c;是为了监督自己&#xff0c;不然我估计我不会有动力写完。这一节&#xff0c;我将介绍下Buffer这个module。js本身对文本友好&#xff0c;但是处理二进制数据就不是特别方便&#xff0c;因此node.js提供了Buffer模块来帮助你处理二进制数据&#xff…

注册asp.net 4.0 到iis

如果没有按照正常的先装iis后装.net的顺序&#xff0c;可以使用此命令重新注册一下&#xff1a; 32位的Windows&#xff1a;---------------------------------------------------------------------------1. 运行->cmd 2. cd C:\Windows\Microsoft.NET\Framework\v4.0.30…

公开征集 | 每个人都可以成为 COSCon'21 主论坛的开源明星

“ 点击蓝字 / 关注我们 ”| 作者&#xff1a;COSCon21 组委会| 编辑&#xff1a;钱奕| 设计&#xff1a;朱亿钦| 责编&#xff1a;沈于蓝在开源的世界里&#xff0c;我们常常说 Community &#xff1e; Code&#xff08;社区重于代码&#xff09;&#xff0c;Community 一词在…

python怎么处理异常然后继续_Python异常处理-返回行,继续

通常,在try块内触发异常后,您永远都无法将执行返回到特定的代码段,因为该异常可能在很深的某个地方发生,并受其他线程的其他副作用影响的许多其他状态.尽管您的程序可能不是这种情况,但是鉴于没有通用的解决方案允许在Python中进行此操作,因此使用异常处理基本上不可能实现您想…

linux 编写脚本示范,Linux-scripts-简单脚本和脚本的执行

9.Scripts9.1什么是 Shell scriptsshell script 是利用 shell 的功能所写的一个『程序 (program)』&#xff0c;这个程序是使用纯文本文件&#xff0c;将一些 shell 的语法与指令(含外部指令)写在里面&#xff0c;搭配正规表示法、管线命令与数据流重导向等功能&#xff0c;以达…

SQL server 2000 和2005中怎么让ldf文档变小

SQL server 2005 打开数据库-- 新建查询--输入以下两条命令&#xff1a; Dump transaction databasename with no_log backup log databasename with no log --然后选择数据库--收缩--文件-- 选择日志--选择收缩方式里到xxMB,然后就可以了。 en:chose database--shrink-- file-…

MyEclipse JAVA提示信息配置

1.内容提示 1.1 Windows>Preferences>Java>Editor>Content Assists 找到”auto activation triggers for Java“ 输入框&#xff0c;初始为’.&#xff0c;改为‘.abc. 1.2 Export Preferences配置文件取名为’1.epf,编辑‘1.epf’,找到‘.abc,改为’.abcdefghijk…

被质疑“在开源社区执行微软意愿”,.NET 基金会前董事为其提交的 PR 道歉并辞职...

编译&#xff5c;燕珊.NET基金会最近“不太平”。上周五&#xff0c;.NET 基金会执行董事 Claire Novotny 在其成员反对她对其中一个项目的干预后&#xff0c;为自身的行为道歉并宣布辞去职务。巧合的是一个多月前&#xff0c;董事会成员 Rodney Littles II 因与基金会的目标方…

hadoop扩充磁盘操作记录

记录cloudera扩充磁盘1、4台主机&#xff0c;每台主机增加一块2TB的硬盘2、首先简单说明步骤A、分区&#xff0c;挂载&#xff08;挂载目录&#xff08;名称&#xff0c;路径&#xff09;要一致&#xff09;B、在挂载的分区内&#xff0c;建立对应的文件夹&#xff0c;并授权C、…

linux命令clock,简单了解Linux系统中clock命令的使用方法

clock 命令&#xff1a;设置或者显示硬件时间的近似值必要参数--adjust 自动调整硬件时钟时间--debug 运行时&#xff0c;输出详细的处理过程--directisa 不通过设备文件/etc/rtc&#xff0c;直接对硬件时钟进行存取--getepoch 输出硬件时钟的数值到标准输出--hctosys 时钟同步…

单身两年以上是什么体验?

1 单身两年以上是什么体验&#xff1f;2 这群熊孩子&#xff0c;不当演员可惜了。。3 我要出去&#xff01;我要见园长&#xff01;我为幼儿园立过功&#xff01;我为幼儿园卖过萌&#xff01;4 当心&#xff01;陷阱&#xff01;&#xff01;5 一位主人抓拍下了自家的柴犬宝宝…

wince导航_宁可用手机导航,也不用汽车导航?

很多车主朋友在开车的时候&#xff0c;比较青睐的是手机导航而不是汽车导航。笔者我也是一个车主&#xff0c;我在开车的时候也是比较青睐手机导航而不是汽车导航&#xff0c;我认为主要是有以下几个原因&#xff1a;车载导航的准确性没有手机导航的高。很多车载导航的地图是在…

Hibernate 逆向工程生成POJO类和映射文件

Guestbook.java 代码&#xff1a; package com.b510.examplex; import java.util.Date; public class Guestbook implements java.io.Serializable { private static final long serialVersionUID -7004492417383895995L; private Integer id; private String name; private S…

功能导航设计器

本程序使用C#编写&#xff1b;此模块作用为让程序功能使用人员直观的知道程序功能模块的先后顺序和操作的先后顺序&#xff1b;原理为客户端通过设计器设置程序的功能流程&#xff1b;并保存的文件服务器上&#xff1b;在使用人员程序中可以直观的调出程序模块的图示&#xff1…

.Net Core with 微服务 - 使用 AgileDT 快速实现基于可靠消息的分布式事务

前面对于分布式事务也讲了好几篇了&#xff08;可靠消息最终一致性分布式事务 - TCC分布式事务 - 2PC、3PChttps://github.com/kklldog/AgileDT 开源不易&#xff0c;大家多多 ✨✨✨回顾 前面一篇文章(可靠消息最终一致性 )我们详细介绍了基于可靠消息的分布式事务。为了更好的…

一位汉子的恋爱心得

1 每天早上起床的你。。2 喂&#xff0c;你怎么不理我&#xff01;3 最新防撕家方法。。4 塑料姐妹花&#xff0c;离得远显脸小。。心疼左一&#xff01;5 国外一位汉子的恋爱心得……6 当有人跟你说“追星有什么用&#xff0c;那些人也不认识你”。。你点的每个赞&#xff0c;…

linux windows多任务,windows是多用户多任务系统吗?

关于单用户操作系统包括Microsoft的MS DOS&#xff0c;windows 9X(95&#xff0c;98&#xff0c;ME)&#xff0c;windows 2000。根据在同一时间使用计算机用户的多少&#xff0c;操作系统可分为单用户操作系统和多用户操作系统。单用户操作系统是指一台计算机在同一时间只能由一…

放大器非线性失真研究装置_高效布里渊光纤放大器

来源&#xff1a;PTB新闻 主要适用于以下领域&#xff1a;精确的光频传输&#xff0c;例如用于光学时钟的远距离比较 双向放大器对于在长距离光纤链路上传输超稳定的光频必不可少&#xff0c;它们可以补偿光损耗&#xff0c;大约每100千米20 dB。由德国联邦物理技术研究院(PTB)…

利用“多说”制作留言板、评论系统

留言板和评论系统在网站建设中会经常用到&#xff0c;今天为大家介绍如何利用多说来为自己的网站制作留言板、评论系统&#xff01;注意以下只是介绍一下简单的创建设置&#xff0c;更多功能大家可以自己去探索&#xff01; 1、进入多说网站 http://duoshuo.com/ 并且登录。 2、…