Ejemplo n.º 1
0
def main(init=True):
    args = ManageCommand.parser.parse_args()

    # bootstrap pyramid
    if init: # pragma: no cover
        scripts.bootstrap(args.config)

    cmd = ManageCommand(args)
    cmd.run()

    ptah.shutdown()
Ejemplo n.º 2
0
def main(init=True):
    args = SettingsCommand.parser.parse_args()

    # bootstrap pyramid
    if init: # pragma: no cover
        scripts.bootstrap(args.config)

    cmd = SettingsCommand(args)
    cmd.run()

    ptah.shutdown()
Ejemplo n.º 3
0
    def test_boostrap(self):
        import ptah
        from ptah.scripts import bootstrap

        result = bootstrap('/foo/settings.ini')

        self.assertEqual(result['app'], self.app)
        self.assertEqual(result['registry'], self.registry)
        self.assertTrue(result['request'] is not None)
        self.assertEqual(result['request'].registry, self.registry)
        self.assertFalse(ptah.POPULATE)
Ejemplo n.º 4
0
Archivo: amd.py Proyecto: webmaven/ptah
def main(init=True):
    args = ManifestCommand.parser.parse_args()

    # bootstrap pyramid
    if init: # pragma: no cover
        env = scripts.bootstrap(args.config)

    cmd = ManifestCommand(args, env['registry'], env['request'])
    cmd.run()

    ptah.shutdown()
Ejemplo n.º 5
0
    def test_boostrap(self):
        import ptah
        from ptah.scripts import bootstrap

        result = bootstrap('/foo/settings.ini')

        self.assertEqual(result['app'], self.app)
        self.assertEqual(result['registry'], self.registry)
        self.assertTrue(result['request'] is not None)
        self.assertEqual(result['request'].registry, self.registry)
        self.assertFalse(ptah.POPULATE)
Ejemplo n.º 6
0
def main():
    parser = argparse.ArgumentParser(description="ptah populate")
    parser.add_argument('config', metavar='config',
                        help='ini config file')
    parser.add_argument('step', metavar='step', nargs='*',
                        help='list of populate steps')
    parser.add_argument('-l', action="store_true", dest='list',
                        help='list of registered populate steps')
    parser.add_argument('-a', action="store_true", dest='all',
                        help='execute all active populate steps')
    args = parser.parse_args()

    env = scripts.bootstrap(args.config)

    populate = Populate(env['registry'])

    if args.list:
        titleWrap = textwrap.TextWrapper(
            initial_indent='* ',
            subsequent_indent='  ')

        descWrap = textwrap.TextWrapper(
            initial_indent='    ',
            subsequent_indent='    ')

        print('')

        for step in sorted(populate.list_steps(all=True),
                           key=lambda i:i['name']):
            print(titleWrap.fill('{0}: {1} ({2})'.format(
                        step['name'], step['title'],
                        'active' if step['active'] else 'inactive')))
            if step['factory'].__doc__:
                print(descWrap.fill(step['factory'].__doc__))

            print('')
    elif args.all:
        populate.execute()
    elif args.step:
        populate.execute(args.step)
    else:
        parser.print_help()

    ptah.shutdown()
Ejemplo n.º 7
0
def main():
    parser = argparse.ArgumentParser(description="ptah populate")
    parser.add_argument('config', metavar='config',
                        help='ini config file')
    parser.add_argument('step', metavar='step', nargs='*',
                        help='list of populate steps')
    parser.add_argument('-l', action="store_true", dest='list',
                        help='list of registered populate steps')
    parser.add_argument('-a', action="store_true", dest='all',
                        help='execute all active populate steps')
    args = parser.parse_args()

    env = scripts.bootstrap(args.config)

    populate = Populate(env['registry'])

    if args.list:
        titleWrap = textwrap.TextWrapper(
            initial_indent='* ',
            subsequent_indent='  ')

        descWrap = textwrap.TextWrapper(
            initial_indent='    ',
            subsequent_indent='    ')

        print('')

        for step in sorted(populate.list_steps(all=True),
                           key=lambda i:i['name']):
            print(titleWrap.fill('{0}: {1} ({2})'.format(
                        step['name'], step['title'],
                        'active' if step['active'] else 'inactive')))
            if step['factory'].__doc__:
                print(descWrap.fill(step['factory'].__doc__))

            print('')
    elif args.all:
        populate.execute()
    elif args.step:
        populate.execute(args.step)
    else:
        parser.print_help()

    ptah.shutdown()
Ejemplo n.º 8
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()
Ejemplo n.º 9
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()