Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(20)  |  Call(20)  |  Derive(0)  |  Import(0)

        def main():
    parser = argparse.ArgumentParser(description="ptah migrate")
    parser.add_argument('config', metavar='config',
                        help='ini config file')

    subparsers = parser.add_subparsers()

    # revision
    subparser = subparsers.add_parser(
        revision.__name__,
        help=revision.__doc__)
    subparser.add_argument('package', metavar='package',
                           help='package name')
    subparser.add_argument("-r", "--revision",
                           type=str, dest='revid',
                           help="Unique revision id")
    subparser.add_argument("-m", "--message",
                           type=str, dest='message',
                           help="Message string to use with 'revision'")
    subparser.set_defaults(cmd='revision')

    # current
    subparser = subparsers.add_parser(
        current.__name__,
        help=current.__doc__)
    subparser.add_argument('package', metavar='package',
                           nargs='*', help='package name')
    subparser.set_defaults(cmd='current')

    # upgrade
    subparser = subparsers.add_parser(
        upgrade.__name__,
        help=upgrade.__doc__)
    subparser.add_argument('package', metavar='package',
                           nargs='*', help='package name')
    subparser.set_defaults(cmd='upgrade')

    # history
    subparser = subparsers.add_parser(
        history.__name__,
        help=history.__doc__)
    subparser.add_argument('package', metavar='package',
                           nargs='*', help='package name')
    subparser.set_defaults(cmd='history')

    # list
    subparser = subparsers.add_parser(
        'list', help='List registered migrations.')
    subparser.set_defaults(cmd='list')

    # parse
    args = parser.parse_args()

    # bootstrap pyramid
    env = scripts.bootstrap(args.config)

    if args.cmd == 'current':
        print ('')
        if not args.package:
            args.package = ptah.get_cfg_storage(MIGRATION_ID).keys()

        for pkg in args.package:
            current(pkg)

    if args.cmd == 'revision':
        if args.revid:
            for ch in ',.;-':
                if ch in args.revid:
                    print ('Revision id contains forbidden characters')
                    ptah.shutdown()
                    return

        revision(args.package, args.revid, args.message)

    if args.cmd == 'upgrade':
        # create db schemas
        create_db_schema(env['registry'], False)

        for pkg in args.package:
            upgrade(pkg)

    if args.cmd == 'history':
        if not args.package:
            args.package = ptah.get_cfg_storage(MIGRATION_ID).keys()

        for pkg in args.package:
            history(pkg)

    if args.cmd == 'list':
        list_migrations(env['registry'])

    ptah.shutdown()
        


src/p/t/ptah-HEAD/ptah/scripts/tests/test_migrate.py   ptah(Download)
 
        try:
            migrate.main()
        except:
            pass
        sys.argv[:] = ['ptah-migrate', 'ptah.ini', 'list']
 
        migrate.main()
 
        self._reset_stdout()
        sys.argv[:] = ['ptah-migrate', 'ptah.ini', 'upgrade', 'test1']
 
        migrate.main()
 
        self._reset_stdout()
        sys.argv[:] = ['ptah-migrate', 'ptah.ini', 'upgrade', 'test1', 'test2']
 
        migrate.main()
 
        self._reset_stdout()
        sys.argv[:] = ['ptah-migrate', 'ptah.ini',
                       'revision', 'test', '-r', '001', '-m', 'Test message']
        migrate.main()
 
        path = self.dirs['test']

src/p/t/ptah-0.8.0/ptah/scripts/tests/test_migrate.py   ptah(Download)
 
        try:
            migrate.main()
        except:
            pass
        sys.argv[:] = ['ptah-migrate', 'ptah.ini', 'list']
 
        migrate.main()
 
        self._reset_stdout()
        sys.argv[:] = ['ptah-migrate', 'ptah.ini', 'upgrade', 'test1']
 
        migrate.main()
 
        self._reset_stdout()
        sys.argv[:] = ['ptah-migrate', 'ptah.ini', 'upgrade', 'test1', 'test2']
 
        migrate.main()
 
        self._reset_stdout()
        sys.argv[:] = ['ptah-migrate', 'ptah.ini',
                       'revision', 'test', '-r', '001', '-m', 'Test message']
        migrate.main()
 
        path = self.dirs['test']