当前位置: 首页>>代码示例>>Python>>正文


Python ManagementUtility.execute方法代码示例

本文整理汇总了Python中django.core.management.ManagementUtility.execute方法的典型用法代码示例。如果您正苦于以下问题:Python ManagementUtility.execute方法的具体用法?Python ManagementUtility.execute怎么用?Python ManagementUtility.execute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在django.core.management.ManagementUtility的用法示例。


在下文中一共展示了ManagementUtility.execute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: start

# 需要导入模块: from django.core.management import ManagementUtility [as 别名]
# 或者: from django.core.management.ManagementUtility import execute [as 别名]
def start (args):
    # if a specific conf has been provided (which it
    # will be), if we're inside the django reloaded
    if "RAPIDSMS_INI" in os.environ:
        ini = os.environ["RAPIDSMS_INI"]
    
    # use a local ini (for development)
    # if one exists, to avoid everyone
    # having their own rapidsms.ini
    elif os.path.isfile("local.ini"):
        ini = "local.ini"
    
    # otherwise, fall back
    else: ini = "rapidsms.ini"

    # add the ini path to the environment, so we can
    # access it globally, including any subprocesses
    # spawned by django
    os.environ["RAPIDSMS_INI"] = ini
    os.environ["DJANGO_SETTINGS_MODULE"] = "rapidsms.webui.settings"

    # read the config, which is shared
    # between the back and frontend
    conf = Config(ini)
    
    # if we found a config ini, try to configure Django
    if conf.sources:
        # This builds the django config from rapidsms.config, in a 
        # round-about way.
        # Can't do it until env[RAPIDSMS_INI] is defined
        from rapidsms.webui import settings 
        
        import_local_settings(settings, ini)

        # whatever we're doing, we'll need to call
        # django's setup_environ, to configure the ORM
        
        from django.core.management import setup_environ, execute_manager
        setup_environ(settings)
    else:
        settings = None

    # if one or more arguments were passed, we're
    # starting up django -- copied from manage.py
    if len(args) < 2:
        print "Commands: route, startproject <name>, startapp <name>"
        sys.exit(1)

    if hasattr(Manager, args[1]):
        handler = getattr(Manager(), args[1])
        handler(conf, *args[2:])
    elif settings:
        # none of the commands were recognized,
        # so hand off to Django
        
        from django.core.management import ManagementUtility
        # The following is equivalent to django's "execute_manager(settings)"
        # only without overriding RapidSMS webui settings
        utility = ManagementUtility()
        utility.execute()
开发者ID:ITIDO,项目名称:rapidsms,代码行数:62,代码来源:manager.py

示例2: manage

# 需要导入模块: from django.core.management import ManagementUtility [as 别名]
# 或者: from django.core.management.ManagementUtility import execute [as 别名]
def manage(command, args=None, as_thread=False):
    """
    Run a django command on the kalite project

    :param command: The django command string identifier, e.g. 'runserver'
    :param args: List of options to parse to the django management command
    :param as_thread: Runs command in thread and returns immediately
    """

    if not args:
        args = []

    args = update_default_args(["--traceback"], args)

    if not as_thread:
        utility = ManagementUtility([os.path.basename(sys.argv[0]), command] + args)
        # This ensures that 'kalite' is printed in help menus instead of
        # 'kalite' or 'kalite.__main__' (a part from the top most text in `kalite manage help`
        utility.prog_name = 'kalite manage'
        utility.execute()
    else:
        get_commands()  # Needed to populate the available commands before issuing one in a thread
        thread = ManageThread(command, args=args, name=" ".join([command] + args))
        thread.start()
        return thread
开发者ID:ruimalheiro,项目名称:ka-lite,代码行数:27,代码来源:cli.py

示例3: manage

# 需要导入模块: from django.core.management import ManagementUtility [as 别名]
# 或者: from django.core.management.ManagementUtility import execute [as 别名]
def manage(command, args=[], in_background=False):
    """
    Run a django command on the kalite project

    :param command: The django command string identifier, e.g. 'runserver'
    :param args: List of options to parse to the django management command
    :param in_background: Creates a sub-process for the command
    """
    # Ensure that django.core.management's global _command variable is set
    # before call commands, especially the once that run in the background
    get_commands()
    # Import here so other commands can run faster
    if not in_background:
        utility = ManagementUtility([os.path.basename(sys.argv[0]), command] + args)
        # This ensures that 'kalite' is printed in help menus instead of
        # 'kalitectl.py' (a part from the top most text in `kalite manage help`
        utility.prog_name = 'kalite manage'
        utility.execute()
    else:
        if os.name != "nt":
            thread = ManageThread(command, args=args, name=" ".join([command]+args))
            thread.start()
        else:
            # TODO (aron): for versions > 0.13, see if we can just have everyone spawn another process (Popen vs. ManageThread)
            Popen([sys.executable, os.path.abspath(sys.argv[0]), "manage", command] + args, creationflags=CREATE_NEW_PROCESS_GROUP)
开发者ID:JGOODYEARUCSD,项目名称:ka-lite,代码行数:27,代码来源:kalitectl.py

示例4: handle

# 需要导入模块: from django.core.management import ManagementUtility [as 别名]
# 或者: from django.core.management.ManagementUtility import execute [as 别名]
    def handle(self,*args,**options):

        #Delete old DB
        print 'Deleting old sqlite db....'
        try:
            if settings.ON_OPENSHIFT:
                os.remove(os.path.join(os.environ['OPENSHIFT_DATA_DIR'],'mwach.db'))
            else:
                os.remove(os.path.join(settings.PROJECT_PATH,'mwach.db'))
        except OSError:
            pass

        if not os.path.isfile(JSON_DATA_FILE):
            sys.exit('JSON file %s Does Not Exist'%(JSON_DATA_FILE,))

        #Migrate new models
        print 'Migrating new db....'
        utility = ManagementUtility(['reset_db.py','migrate'])
        utility.execute()

        #Turn off Autocommit
        #transaction.set_autocommit(False)

        config.CURRENT_DATE = datetime.date.today()
        with transaction.atomic():
            create_backend()

            if options['participants'] > 0:
                load_old_participants(options)

            if options['jennifer']:
                add_jennifers()
开发者ID:nyafreddy,项目名称:mwachx,代码行数:34,代码来源:reset_db.py

示例5: run

# 需要导入模块: from django.core.management import ManagementUtility [as 别名]
# 或者: from django.core.management.ManagementUtility import execute [as 别名]
    def run(self, project_name=None, dest_dir=None):
        # Make sure given name is not already in use by another python package/module.
        try:
            __import__(project_name)
        except ImportError:
            pass
        else:
            sys.exit("'%s' conflicts with the name of an existing "
                     "Python module and cannot be used as a project "
                     "name. Please try another name." % project_name)

        print("Creating a Wagtail project called %(project_name)s" % {'project_name': project_name})  # noqa

        # Create the project from the Wagtail template using startapp

        # First find the path to Wagtail
        import wagtail
        wagtail_path = os.path.dirname(wagtail.__file__)
        template_path = os.path.join(wagtail_path, 'project_template')

        # Call django-admin startproject
        utility_args = ['django-admin.py',
                        'startproject',
                        '--template=' + template_path,
                        '--ext=html,rst',
                        '--name=Dockerfile',
                        project_name]

        if dest_dir:
            utility_args.append(dest_dir)

        utility = ManagementUtility(utility_args)
        utility.execute()

        print("Success! %(project_name)s has been created" % {'project_name': project_name})  # noqa
开发者ID:Henk-JanVanHasselaar,项目名称:wagtail,代码行数:37,代码来源:wagtail.py

示例6: update_migrations

# 需要导入模块: from django.core.management import ManagementUtility [as 别名]
# 或者: from django.core.management.ManagementUtility import execute [as 别名]
def update_migrations():
    """
    Creates schemamigrations for localshop.
    """
    from django.core.management import ManagementUtility
    args = 'manage.py schemamigration localshop --auto'.split(' ')
    utility = ManagementUtility(args)
    utility.execute()
开发者ID:posborne,项目名称:localshop,代码行数:10,代码来源:manage.py

示例7: _run

# 需要导入模块: from django.core.management import ManagementUtility [as 别名]
# 或者: from django.core.management.ManagementUtility import execute [as 别名]
 def _run(coor, argv):
     global urlpatterns
     urlpatterns = patterns('',
         url('.*', coor or DjangoCoor())
     )
     os.environ['DJANGO_SETTINGS_MODULE'] = __name__
     utility = ManagementUtility(sys.argv[:1] + argv)
     utility.execute()
开发者ID:wanziforever,项目名称:statistics,代码行数:10,代码来源:coor.py

示例8: execute_from_command_line

# 需要导入模块: from django.core.management import ManagementUtility [as 别名]
# 或者: from django.core.management.ManagementUtility import execute [as 别名]
def execute_from_command_line(argv=None):
    """
    A simple method that runs a ManagementUtility.
    """
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "colab.settings")

    utility = ManagementUtility(argv)
    utility.execute()
开发者ID:rafamanzo,项目名称:colab,代码行数:10,代码来源:__init__.py

示例9: run_management_command

# 需要导入模块: from django.core.management import ManagementUtility [as 别名]
# 或者: from django.core.management.ManagementUtility import execute [as 别名]
 def run_management_command(self, *args):
     from django.core.management import ManagementUtility
     args = ['manage.py'] + list(args)
     utility = ManagementUtility(args)
     try:
         utility.execute()
     except SystemExit:
         pass
     print('')
开发者ID:numbas,项目名称:editor,代码行数:11,代码来源:first_setup.py

示例10: test_update_settings

# 需要导入模块: from django.core.management import ManagementUtility [as 别名]
# 或者: from django.core.management.ManagementUtility import execute [as 别名]
 def test_update_settings(self):
     self.assertTrue(settings.DEBUG)
     args = ['manage.py', 'settings', '--django_debug=False', 'DEBUG']
     utility = ManagementUtility(argv=args)
     self.begin_capture()
     try:
         utility.execute()
     finally:
         self.end_capture()
     self.assertTrue('False' in self.capture['stdout'])
开发者ID:iluminite,项目名称:django-configglue,代码行数:12,代码来源:test_settings.py

示例11: test_version_is_printed_once

# 需要导入模块: from django.core.management import ManagementUtility [as 别名]
# 或者: from django.core.management.ManagementUtility import execute [as 别名]
 def test_version_is_printed_once(self):
     args = ['manage.py', '--version']
     utility = ManagementUtility(argv=args)
     self.begin_capture()
     try:
         utility.execute()
     finally:
         self.end_capture()
     expected = get_version()
     self.assertTrue(self.capture['stdout'].count(expected) == 1)
开发者ID:iluminite,项目名称:django-configglue,代码行数:12,代码来源:test_settings.py

示例12: execute_from_command_line

# 需要导入模块: from django.core.management import ManagementUtility [as 别名]
# 或者: from django.core.management.ManagementUtility import execute [as 别名]
def execute_from_command_line(argv=None):
    """
    A simple method that runs a ManagementUtility.
    """
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "colab.settings")
    from django.conf import settings

    if not hasattr(settings, 'SECRET_KEY') and 'initconfig' in sys.argv:
        command = initconfig.Command()
        command.handle()
    else:
        utility = ManagementUtility(argv)
        utility.execute()
开发者ID:colab,项目名称:colab,代码行数:15,代码来源:runner.py

示例13: execute_manager

# 需要导入模块: from django.core.management import ManagementUtility [as 别名]
# 或者: from django.core.management.ManagementUtility import execute [as 别名]
def execute_manager(settings_mod, argv=None):
    """
    Like execute_from_command_line(), but for use by manage.py, a
    project-specific django-admin.py utility.
    """
    
    # don't add the project directory to the environment, as this ends
    # up importing classes using the project name, and self.assertIsInstance
    # requires us to specify the project name, making our tests non-portable.
    # setup_environ(settings_mod)
    
    import binder.monkeypatch
    utility = ManagementUtility(argv)
    utility.execute()
开发者ID:pombredanne,项目名称:intranet,代码行数:16,代码来源:manage.py

示例14: create_project

# 需要导入模块: from django.core.management import ManagementUtility [as 别名]
# 或者: from django.core.management.ManagementUtility import execute [as 别名]
def create_project(parser, options, args):
    # Validate args
    if len(args) < 2:
        parser.error("Please specify a name for your wagtail installation")
    elif len(args) > 3:
        parser.error("Too many arguments")

    project_name = args[1]
    try:
        dest_dir = args[2]
    except IndexError:
        dest_dir = None

    # Make sure given name is not already in use by another python package/module.
    try:
        __import__(project_name)
    except ImportError:
        pass
    else:
        parser.error("'%s' conflicts with the name of an existing "
                     "Python module and cannot be used as a project "
                     "name. Please try another name." % project_name)

    print("Creating a wagtail project called %(project_name)s" % {'project_name': project_name})

    # Create the project from the wagtail template using startapp

    # First find the path to wagtail
    import wagtail
    wagtail_path = os.path.dirname(wagtail.__file__)
    template_path = os.path.join(wagtail_path, 'project_template')

    # Call django-admin startproject
    utility_args = ['django-admin.py',
                    'startproject',
                    '--template=' + template_path,
                    '--name=Vagrantfile',
                    '--ext=html,rst',
                    project_name]

    if dest_dir:
        utility_args.append(dest_dir)

    utility = ManagementUtility(utility_args)
    utility.execute()

    print("Success! %(project_name)s is created" % {'project_name': project_name})
开发者ID:bjesus,项目名称:wagtail,代码行数:49,代码来源:wagtail.py

示例15: schemamigration

# 需要导入模块: from django.core.management import ManagementUtility [as 别名]
# 或者: from django.core.management.ManagementUtility import execute [as 别名]
def schemamigration():
    # turn ``schemamigration.py --initial`` into
    # ``manage.py schemamigration cmsplugin_disqus --initial`` and setup the
    # enviroment
    from django.conf import settings

    from django.core.management import ManagementUtility
    settings.configure(
        INSTALLED_APPS=test_settings.INSTALLED_APPS,
        DATABASES=test_settings.DATABASES,
        TEMPLATE_CONTEXT_PROCESSORS=test_settings.TEMPLATE_CONTEXT_PROCESSORS,
        ROOT_URLCONF=test_settings.ROOT_URLCONF)
    argv = list(sys.argv)
    argv.insert(1, 'schemamigration')
    argv.insert(2, 'djangocms_text_ckeditor')
    utility = ManagementUtility(argv)
    utility.execute()
开发者ID:MagicSolutions,项目名称:djangocms-text-ckeditor,代码行数:19,代码来源:schemamigration.py


注:本文中的django.core.management.ManagementUtility.execute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。