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


Python shell.main函数代码示例

本文整理汇总了Python中migrate.versioning.shell.main函数的典型用法代码示例。如果您正苦于以下问题:Python main函数的具体用法?Python main怎么用?Python main使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: take_action

    def take_action(self, opts):
        #Work-around for SQLA0.8 being incompatible with sqlalchemy-migrate
        import sqlalchemy
        sqlalchemy.exceptions = sqlalchemy.exc

        from migrate.versioning.shell import main

        sect = 'app:main'
        option = 'sqlalchemy.url'

        # get sqlalchemy.url config in app:mains
        conf = ConfigParser()
        conf.read(opts.ini)

        name = "migration"
        try:
            dburi = conf.get(sect, option, vars={'here':os.getcwd()})
        except:
            print("Unable to read config file or missing sqlalchemy.url in app:main section")
            return

        print("Migrations repository '%s',\ndatabase url '%s'\n"%(name, dburi))
        if not opts.args:
            opts.args = ['help']
        sys.argv[0] = sys.argv[0] + ' migrate'
        main(argv=opts.args, url=dburi, repository=name, name=name)
开发者ID:TurboGears,项目名称:tg2devtools,代码行数:26,代码来源:sqlamigrate.py

示例2: invoke_migrate_main

def invoke_migrate_main():
    # Migrate has its own args, so cannot use argparse
    config = get_config(sys.argv, use_argparse=False)
    db_url = config['db_url']
    repo = config['repo']

    main(repository=repo, url=db_url)
开发者ID:ImmPortDB,项目名称:immport-galaxy,代码行数:7,代码来源:manage_db.py

示例3: parseOptions

 def parseOptions(self, options=None):
     if not required_imports_ok():
         sys.exit(1)
     from migrate.versioning.shell import main
     # Tweak sys.argv
     sys.argv = sys.argv[sys.argv.index('migrate'):]
     main(url=db.create_engine().url, repository=UPGRADES_REPO.path)
     sys.exit()
开发者ID:UfSoft,项目名称:SSHg,代码行数:8,代码来源:service.py

示例4: handle

        def handle(self, app, prog, name, remaining_args):
            optional = {}
            repository = app.config.get('SQLALCHEMY_MIGRATE_REPOSITORY', False)
            if repository:
                optional['repository'] = repository

            shell.main(remaining_args,
                       url=app.config['SQLALCHEMY_DATABASE_URI'],
                       debug=app.config['DEBUG'],
                       **optional)
开发者ID:miracle2k,项目名称:flask-sqlalchemy,代码行数:10,代码来源:flask_sqlalchemy.py

示例5: _check_error

 def _check_error(self,args,code,expected,**kw):
     original = sys.stderr
     try:
         actual = StringIO()
         sys.stderr = actual
         try:
             shell.main(args,**kw)
         except SystemExit, e:
             self.assertEqual(code,e.args[0])
         else:
开发者ID:Fematich,项目名称:article_browser,代码行数:10,代码来源:test_shell.py

示例6: test_shutdown_logging

    def test_shutdown_logging(self):
        """Try to shutdown logging output"""
        repos = self.tmp_repos()
        result = self.env.run('migrate create %s repository_name' % repos)
        result = self.env.run('migrate version %s --disable_logging' % repos)
        self.assertEqual(result.stdout, '')
        result = self.env.run('migrate version %s -q' % repos)
        self.assertEqual(result.stdout, '')

        # TODO: assert logging messages to 0
        shell.main(['version', repos], logging=False)
开发者ID:Fematich,项目名称:article_browser,代码行数:11,代码来源:test_shell.py

示例7: main

def main(url, repository):
    # Check if database is under version control
    try:
        db_version(url, repository)
    except DatabaseNotControlledError:
        # put database under version control
        version_control(url, repository)         

    kwargs = {'url': url,
        'repository': repository
    }

    shell.main(**kwargs)
开发者ID:prinzdezibel,项目名称:p2.datashackle.repository,代码行数:13,代码来源:manage.py

示例8: test_main

    def test_main(self):
        """Test main() function"""
        repos = self.tmp_repos()
        shell.main(['help'])
        shell.main(['help', 'create'])
        shell.main(['create', 'repo_name', '--preview_sql'], repository=repos)
        shell.main(['version', '--', '--repository=%s' % repos])
        shell.main(['version', '-d', '--repository=%s' % repos, '--version=2'])

        self._check_error(['foobar'],2,'error: Invalid command foobar')
        self._check_error(['create', 'f', 'o', 'o'],2,'error: Too many arguments for command create: o')
        self._check_error(['create'],2,'error: Not enough arguments for command create: name, repository not specified')
        self._check_error(['create', 'repo_name'],2,'already exists', repository=repos)
开发者ID:Fematich,项目名称:article_browser,代码行数:13,代码来源:test_shell.py

示例9: test_main

    def test_main(self):
        """Test main() function"""
        repos = self.tmp_repos()
        shell.main(["help"])
        shell.main(["help", "create"])
        shell.main(["create", "repo_name", "--preview_sql"], repository=repos)
        shell.main(["version", "--", "--repository=%s" % repos])
        shell.main(["version", "-d", "--repository=%s" % repos, "--version=2"])

        self._check_error(["foobar"], 2, "error: Invalid command foobar")
        self._check_error(["create", "f", "o", "o"], 2, "error: Too many arguments for command create: o")
        self._check_error(
            ["create"], 2, "error: Not enough arguments for command create: name, repository not specified"
        )
        self._check_error(["create", "repo_name"], 2, "already exists", repository=repos)
开发者ID:Gitlena,项目名称:ichhabkeinblog,代码行数:15,代码来源:test_shell.py

示例10: _check_error

 def _check_error(self,args,code,expected,**kw):
     original = sys.stderr
     try:
         actual = cStringIO()
         sys.stderr = actual
         try:
             shell.main(args,**kw)
         except SystemExit as e:
             self.assertEqual(code,e.args[0])
         else:
             self.fail('No exception raised')
     finally:
         sys.stderr = original
     actual = actual.getvalue()
     self.assertTrue(expected in actual,'%r not in:\n"""\n%s\n"""'%(expected,actual))
开发者ID:BLourence,项目名称:RemoteIR,代码行数:15,代码来源:test_shell.py

示例11: setup_schema

def setup_schema(command, conf, vars):
    """Place any commands to setup tutorial here"""
    # Load the models

    # <websetup.websetup.schema.before.model.import>
    from tutorial import model
    # <websetup.websetup.schema.after.model.import>

    
    # <websetup.websetup.schema.before.metadata.create_all>
    print "Creating tables"
    model.metadata.create_all(bind=config['pylons.app_globals'].sa_engine)
    # <websetup.websetup.schema.after.metadata.create_all>
    transaction.commit()
    from migrate.versioning.shell import main
    main(argv=['version_control'], url=config['sqlalchemy.url'], repository='migration', name='migration')
开发者ID:mokshaproject,项目名称:moksha-turbogears2-hello_world,代码行数:16,代码来源:schema.py

示例12: _perform_appless_action

    def _perform_appless_action(self, pluggable):
        repository = self._pluggable_repository(pluggable)
        if repository is None:
            return

        tablename = self._pluggable_tablename(pluggable)
        print "\n%s Migrations" % pluggable
        print "\tRepository '%s'" % repository
        print "\tVersioning Table '%s'" % tablename

        #disable logging, this is due to sqlalchemy-migrate bug that
        #causes the disable_logging option to ignored
        args = self.args[:1] + ['-q'] + self.args[1:]

        main(argv=args, url=None, repository=repository, name=pluggable,
             version_table=tablename, disable_logging=True)
开发者ID:simock85,项目名称:tgext.pluggable,代码行数:16,代码来源:migration.py

示例13: command

    def command(self):
        ini = 'development.ini'
        sect = 'app:main'
        option = 'sqlalchemy.url'

        # get sqlalchemy.url config in app:mains
        curdir = os.getcwd()
        conf = ConfigParser.ConfigParser()
        conf.read(os.path.join(curdir, ini))

        self.name = "migration"
        try:
            self.dburi = conf.get(sect, option, vars={'here':curdir})
        except:
            print "you shold set sqlalchemy.url in development.ini first"

        print "The repository is '%s'\nThe url is '%s'"%(self.name, self.dburi)
        main(argv=self.args, url=self.dburi,repository=self.name, name=self.name)
开发者ID:desarrollo1,项目名称:tg2env,代码行数:18,代码来源:migration.py

示例14: _perform_migration

    def _perform_migration(self, pluggable):
        repository = self._pluggable_repository(pluggable)
        if repository is None or not os.path.exists(repository):
            print "%s - Pluggable does not support migrations" % pluggable
            return

        tablename = self._pluggable_tablename(pluggable)
        print '\n%s Migrations' % pluggable
        print "\tRepository '%s'" % repository
        print "\tDatabase '%s'" % self.dburi
        print "\tVersioning Table '%s'" % tablename

        #disable logging, this is due to sqlalchemy-migrate bug that
        #causes the disable_logging option to ignored
        args = self.args[:1] + ['-q'] + self.args[1:]

        main(argv=args, url=self.dburi, repository=repository, name=pluggable,
             version_table=tablename, disable_logging=True)
开发者ID:simock85,项目名称:tgext.pluggable,代码行数:18,代码来源:migration.py

示例15: setup_schema

def setup_schema(command, conf, vars):
    """Place any commands to setup tgtodotrack here"""
    # Load the models

    # <websetup.websetup.schema.before.model.import>
    from tgtodotrack import model
    # <websetup.websetup.schema.after.model.import>

    
    # <websetup.websetup.schema.before.metadata.create_all>
    print "Creating tables"
    model.metadata.create_all(bind=config['pylons.app_globals'].sa_engine)
    # <websetup.websetup.schema.after.metadata.create_all>
    transaction.commit()
    from migrate.versioning.shell import main
    from migrate.exceptions import DatabaseAlreadyControlledError
    try:
        main(argv=['version_control'], url=config['sqlalchemy.url'], repository='migration', name='migration')
    except DatabaseAlreadyControlledError:
        print 'Database already under version control'
开发者ID:patovala,项目名称:tgtodotrack,代码行数:20,代码来源:schema.py


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