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


Python command.init方法代码示例

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


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

示例1: staging_env

# 需要导入模块: from alembic import command [as 别名]
# 或者: from alembic.command import init [as 别名]
def staging_env(create=True, template="generic", sourceless=False):
    from alembic import command, script
    cfg = _testing_config()
    if create:
        path = os.path.join(_get_staging_directory(), 'scripts')
        if os.path.exists(path):
            shutil.rmtree(path)
        command.init(cfg, path, template=template)
        if sourceless:
            try:
                # do an import so that a .pyc/.pyo is generated.
                util.load_python_file(path, 'env.py')
            except AttributeError:
                # we don't have the migration context set up yet
                # so running the .env py throws this exception.
                # theoretically we could be using py_compiler here to
                # generate .pyc/.pyo without importing but not really
                # worth it.
                pass
            make_sourceless(os.path.join(path, "env.py"))

    sc = script.ScriptDirectory.from_config(cfg)
    return sc 
开发者ID:jpush,项目名称:jbox,代码行数:25,代码来源:env.py

示例2: init_development_data

# 需要导入模块: from alembic import command [as 别名]
# 或者: from alembic.command import init [as 别名]
def init_development_data(context, upgrade_db=True, skip_on_failure=False):
    """
    Fill a database with development data like default users.
    """
    if upgrade_db:
        context.invoke_execute(context, 'app.db.upgrade')

    log.info("Initializing development data...")

    from migrations import initial_development_data
    try:
        initial_development_data.init()
    except AssertionError as exception:
        if not skip_on_failure:
            log.error("%s", exception)
        else:
            log.debug(
                "The following error was ignored due to the `skip_on_failure` flag: %s",
                exception
            )
            log.info("Initializing development data step is skipped.")
    else:
        log.info("Fixtures have been successfully applied.") 
开发者ID:frol,项目名称:flask-restplus-server-example,代码行数:25,代码来源:db.py

示例3: test_init_file_exists_and_is_empty

# 需要导入模块: from alembic import command [as 别名]
# 或者: from alembic.command import init [as 别名]
def test_init_file_exists_and_is_empty(self):
        def access_(path, mode):
            if "generic" in path or path == "foobar":
                return True
            else:
                return False

        def listdir_(path):
            if path == "foobar":
                return []
            else:
                return ["file1", "file2", "alembic.ini.mako"]

        with mock.patch(
            "alembic.command.os.access", side_effect=access_
        ), mock.patch("alembic.command.os.makedirs") as makedirs, mock.patch(
            "alembic.command.os.listdir", side_effect=listdir_
        ), mock.patch(
            "alembic.command.ScriptDirectory"
        ):
            command.init(self.cfg, directory="foobar")
            eq_(
                makedirs.mock_calls,
                [mock.call(os.path.normpath("foobar/versions"))],
            ) 
开发者ID:sqlalchemy,项目名称:alembic,代码行数:27,代码来源:test_command.py

示例4: test_init_file_doesnt_exist

# 需要导入模块: from alembic import command [as 别名]
# 或者: from alembic.command import init [as 别名]
def test_init_file_doesnt_exist(self):
        def access_(path, mode):
            if "generic" in path:
                return True
            else:
                return False

        with mock.patch(
            "alembic.command.os.access", side_effect=access_
        ), mock.patch("alembic.command.os.makedirs") as makedirs, mock.patch(
            "alembic.command.ScriptDirectory"
        ):
            command.init(self.cfg, directory="foobar")
            eq_(
                makedirs.mock_calls,
                [
                    mock.call("foobar"),
                    mock.call(os.path.normpath("foobar/versions")),
                ],
            ) 
开发者ID:sqlalchemy,项目名称:alembic,代码行数:22,代码来源:test_command.py

示例5: test_init_w_package

# 需要导入模块: from alembic import command [as 别名]
# 或者: from alembic.command import init [as 别名]
def test_init_w_package(self):

        path = os.path.join(_get_staging_directory(), "foobar")

        with mock.patch("alembic.command.open") as open_:
            command.init(self.cfg, directory=path, package=True)
            eq_(
                open_.mock_calls,
                [
                    mock.call(
                        os.path.abspath(os.path.join(path, "__init__.py")), "w"
                    ),
                    mock.call().close(),
                    mock.call(
                        os.path.abspath(
                            os.path.join(path, "versions", "__init__.py")
                        ),
                        "w",
                    ),
                    mock.call().close(),
                ],
            ) 
开发者ID:sqlalchemy,项目名称:alembic,代码行数:24,代码来源:test_command.py

示例6: init

# 需要导入模块: from alembic import command [as 别名]
# 或者: from alembic.command import init [as 别名]
def init(directory=None, multidb=False):
    """Generates a new migration"""
    if directory is None:
        directory = current_app.extensions['migrate'].directory
    config = Config()
    config.set_main_option('script_location', directory)
    config.config_file_name = os.path.join(directory, 'alembic.ini')
    config = current_app.extensions['migrate'].\
        migrate.call_configure_callbacks(config)
    if multidb:
        command.init(config, directory, 'flask-multidb')
    else:
        command.init(config, directory, 'flask') 
开发者ID:jpush,项目名称:jbox,代码行数:15,代码来源:__init__.py

示例7: init_db

# 需要导入模块: from alembic import command [as 别名]
# 或者: from alembic.command import init [as 别名]
def init_db(config):
    """Creates a new migration repository."""

    directory = os.path.join('yui', 'migrations')
    c = Config()
    c.set_main_option('script_location', directory)
    c.set_main_option('sqlalchemy.url', config.DATABASE_URL)

    c.config_file_name = os.path.join(directory, 'alembic.ini')

    command.init(c, directory, 'chatterbox') 
开发者ID:item4,项目名称:yui,代码行数:13,代码来源:cli.py

示例8: init

# 需要导入模块: from alembic import command [as 别名]
# 或者: from alembic.command import init [as 别名]
def init(context, directory='migrations', multidb=False):
    """Generates a new migration"""
    config = Config()
    config.set_main_option('script_location', directory)
    config.config_file_name = os.path.join(directory, 'alembic.ini')
    if multidb:
        command.init(config, directory, 'flask-multidb')
    else:
        command.init(config, directory, 'flask') 
开发者ID:frol,项目名称:flask-restplus-server-example,代码行数:11,代码来源:db.py

示例9: staging_env

# 需要导入模块: from alembic import command [as 别名]
# 或者: from alembic.command import init [as 别名]
def staging_env(create=True, template="generic", sourceless=False):
    from alembic import command, script

    cfg = _testing_config()
    if create:

        path = os.path.join(_get_staging_directory(), "scripts")
        assert not os.path.exists(path), (
            "staging directory %s already exists; poor cleanup?" % path
        )

        command.init(cfg, path, template=template)
        if sourceless:
            try:
                # do an import so that a .pyc/.pyo is generated.
                util.load_python_file(path, "env.py")
            except AttributeError:
                # we don't have the migration context set up yet
                # so running the .env py throws this exception.
                # theoretically we could be using py_compiler here to
                # generate .pyc/.pyo without importing but not really
                # worth it.
                pass
            assert sourceless in (
                "pep3147_envonly",
                "simple",
                "pep3147_everything",
            ), sourceless
            make_sourceless(
                os.path.join(path, "env.py"),
                "pep3147" if "pep3147" in sourceless else "simple",
            )

    sc = script.ScriptDirectory.from_config(cfg)
    return sc 
开发者ID:sqlalchemy,项目名称:alembic,代码行数:37,代码来源:env.py

示例10: test_init_file_exists_and_is_not_empty

# 需要导入模块: from alembic import command [as 别名]
# 或者: from alembic.command import init [as 别名]
def test_init_file_exists_and_is_not_empty(self):
        with mock.patch(
            "alembic.command.os.listdir", return_value=["file1", "file2"]
        ), mock.patch("alembic.command.os.access", return_value=True):
            directory = "alembic"
            assert_raises_message(
                util.CommandError,
                "Directory %s already exists and is not empty" % directory,
                command.init,
                self.cfg,
                directory=directory,
            ) 
开发者ID:sqlalchemy,项目名称:alembic,代码行数:14,代码来源:test_command.py

示例11: init

# 需要导入模块: from alembic import command [as 别名]
# 或者: from alembic.command import init [as 别名]
def init(self):
        dirname = self.cfg.get_main_option('script_location')
        alembic_cmd.init(self.cfg, dirname, template='lux') 
开发者ID:quantmind,项目名称:lux,代码行数:5,代码来源:migrations.py

示例12: make_parser

# 需要导入模块: from alembic import command [as 别名]
# 或者: from alembic.command import init [as 别名]
def make_parser(self, subparsers):
        parser = subparsers.add_parser('init', help=self.init.__doc__)
        parser.add_argument('-d', '--directory', dest='directory', default=None,
                            help="migration script directory (default is 'migrations')")
        return parser 
开发者ID:mozilla,项目名称:build-relengapi,代码行数:7,代码来源:alembic_wrapper.py

示例13: run

# 需要导入模块: from alembic import command [as 别名]
# 或者: from alembic.command import init [as 别名]
def run(self, parser, args):
        self.init(**vars(args)) 
开发者ID:mozilla,项目名称:build-relengapi,代码行数:4,代码来源:alembic_wrapper.py

示例14: init

# 需要导入模块: from alembic import command [as 别名]
# 或者: from alembic.command import init [as 别名]
def init(self, directory, **kwargs):
        """Generates a new migration"""
        config = Config()
        config.set_main_option('script_location', directory)
        config.config_file_name = os.path.join(directory, 'alembic.ini')
        command.init(config, directory, 'relengapi') 
开发者ID:mozilla,项目名称:build-relengapi,代码行数:8,代码来源:alembic_wrapper.py

示例15: staging_env

# 需要导入模块: from alembic import command [as 别名]
# 或者: from alembic.command import init [as 别名]
def staging_env(create=True, template="generic", sourceless=False):
    from alembic import command, script
    cfg = _testing_config()
    if create:
        path = os.path.join(_get_staging_directory(), 'scripts')
        if os.path.exists(path):
            shutil.rmtree(path)
        command.init(cfg, path, template=template)
        if sourceless:
            try:
                # do an import so that a .pyc/.pyo is generated.
                util.load_python_file(path, 'env.py')
            except AttributeError:
                # we don't have the migration context set up yet
                # so running the .env py throws this exception.
                # theoretically we could be using py_compiler here to
                # generate .pyc/.pyo without importing but not really
                # worth it.
                pass
            assert sourceless in (
                "pep3147_envonly", "simple", "pep3147_everything"), sourceless
            make_sourceless(
                os.path.join(path, "env.py"),
                "pep3147" if "pep3147" in sourceless else "simple"
            )

    sc = script.ScriptDirectory.from_config(cfg)
    return sc 
开发者ID:bkerler,项目名称:android_universal,代码行数:30,代码来源:env.py


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