コード例 #1
0
ファイル: scripts.py プロジェクト: bearstech/DjangoDevKit
def manage(*args):
    settings = utils.get_settings(
        apps=('django_extensions',),
        DEBUG_PROPAGATE_EXCEPTIONS=False)
    del settings.DEBUG
    from django.core import management
    if utils.get_version() < (1, 4):
        # django < 1.6
        def run(argv=None):
            return management.execute_manager(settings)
        management.setup_environ = lambda *args: os.getcwd
    else:
        def run(argv=None):
            return management.execute_from_command_line(argv=argv)
    if utils.get_version() < (1, 7):
        from django.conf import settings as sets  # NOQA
    args = args or sys.argv[1:]

    if not args:
        return sys.exit(run())

    cmd = args[0]
    config = ConfigParser()
    config.read(os.path.expanduser('~/.djangodevkitrc'))
    try:
        alias = config.get('aliases', cmd)
    except:
        cmds = [args]
    else:
        sargs = ' '.join(args[1:])
        cmds = [a.replace('[]', sargs) for a in alias.split('\n') if a.strip()]
        cmds = [a.split() for a in cmds]
    for cmd in cmds:
        sys.argv[1:] = cmd
        run(argv=sys.argv)
コード例 #2
0
ファイル: scripts.py プロジェクト: bearstech/DjangoDevKit
def manage_migrate():
    if utils.get_version() >= (1, 7):
        manage('migrate', '--noinput')
    else:
        manage('syncdb', '--noinput')
        from django.conf import settings
        if 'south' in settings.INSTALLED_APPS:
            manage('migrate', '--noinput')
コード例 #3
0
def manage_migrate():
    if utils.get_version() >= (1, 7):
        manage('migrate', '--noinput')
    else:
        manage('syncdb', '--noinput')
        from django.conf import settings
        if 'south' in settings.INSTALLED_APPS:
            manage('migrate', '--noinput')
コード例 #4
0
def manage(*args):
    settings = utils.get_settings(apps=('django_extensions', ),
                                  DEBUG_PROPAGATE_EXCEPTIONS=False)
    del settings.DEBUG
    from django.core import management
    if utils.get_version() < (1, 4):
        # django < 1.6
        def run(argv=None):
            return management.execute_manager(settings)

        management.setup_environ = lambda *args: os.getcwd
    else:

        def run(argv=None):
            return management.execute_from_command_line(argv=argv)

    if utils.get_version() < (1, 7):
        from django.conf import settings as sets  # NOQA
    args = args or sys.argv[1:]

    if not args:
        return sys.exit(run())

    cmd = args[0]
    config = ConfigParser()
    config.read(os.path.expanduser('~/.djangodevkitrc'))
    try:
        alias = config.get('aliases', cmd)
    except:
        cmds = [args]
    else:
        sargs = ' '.join(args[1:])
        cmds = [a.replace('[]', sargs) for a in alias.split('\n') if a.strip()]
        cmds = [a.split() for a in cmds]
    for cmd in cmds:
        sys.argv[1:] = cmd
        run(argv=sys.argv)