def main(init=True): import gevent.monkey gevent.monkey.patch_all() args = BackendCommand.parser.parse_args() # logging config def fileConfig(f, defaults): from logging.config import fileConfig return fileConfig(f, defaults, disable_existing_loggers = False) paster.setup_logging(args.config.split('#', 1)[0], fileConfig) # read settings parser = configparser.SafeConfigParser() parser.read((args.config,)) settings = parser.items(configparser.DEFAULTSECT, vars={'here': './'}) # run configuration config = Configurator(settings=settings) config.include('ptah') config.include('smxq') # ptah config.ptah_init_sql() config.ptah_init_settings() config.commit() # run command cmd = BackendCommand(args, config.registry, config) cmd.run() ptah.shutdown()
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()
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()
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()
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()
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()
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()