type=str, default='*', required=False, help=logid_help) parser.add_argument('--debug', default=False, required=False, help=debug_help, action='store_true') parser.add_argument('--version', action='version', help=version_help, version='{version}'.format(version=__version__)) parser.add_argument('--rollbar-level', type=str, default="info", required=False, help=rollbar_help) args = parser.parse_args() replica = replica_engine(args) if args.debug: getattr(replica, args.command)() else: try: getattr(replica, args.command)() except AttributeError: print("ERROR - Invalid command") print(command_help)
parser = argparse.ArgumentParser(description='Command line for pg_chameleon.', add_help=True) parser.add_argument('command', metavar='command', type=str, help=command_help) parser.add_argument('--config', metavar='config', type=str, default='default', required=False, help=config_help) parser.add_argument('--table', metavar='table', type=str, default='*', required=False, help=table_help) parser.add_argument('--debug', default=False, required=False, help=nolock_help, action='store_true') parser.add_argument('--nolock', default=False, required=False, help=debug_help, action='store_true') parser.add_argument('--version', action='version',version='pg_chameleon {version}'.format(version=__version__)) parser.add_argument('--thread', default=False, required=False, help=thread_help, action='store_true') args = parser.parse_args() if args.command == commands[14]: configdir.set_config() elif args.command in commands: replica = replica_engine(args.config, args.debug, args.nolock) if args.command == commands[0]: replica.create_service_schema() elif args.command == commands[1]: replica.init_replica() elif args.command == commands[2]: if args.thread: replica.run_replica_thread() else: replica.run_replica() elif args.command == commands[3]: replica.upgrade_service_schema() elif args.command == commands[4]: replica.drop_service_schema() elif args.command == commands[5]: replica.list_config()
parser.add_argument('--table', metavar='table', type=str, default='*', required=False, help=table_help) parser.add_argument('--debug', default=False, required=False, help=debug_help, action='store_true') args = parser.parse_args() if args.command in commands: replica = replica_engine(args.config, args.debug) if args.command == commands[0]: replica.create_service_schema() elif args.command == commands[1]: replica.init_replica() elif args.command == commands[2]: replica.run_replica() elif args.command == commands[3]: replica.upgrade_service_schema() elif args.command == commands[4]: replica.drop_service_schema() elif args.command == commands[5]: replica.list_config() elif args.command == commands[6]: replica.add_source() elif args.command == commands[7]:
metavar='config', type=str, default='default', required=False, help=config_help) parser.add_argument('--table', metavar='table', type=str, default='*', required=False, help=table_help) args = parser.parse_args() if args.command in commands: replica = replica_engine(args.config) if args.command == commands[0]: replica.create_service_schema() elif args.command == commands[1]: replica.init_replica() elif args.command == commands[2]: replica.run_replica() elif args.command == commands[3]: replica.upgrade_service_schema() elif args.command == commands[4]: replica.drop_service_schema() elif args.command == commands[5]: replica.list_config() elif args.command == commands[6]: replica.add_source() elif args.command == commands[7]:
logid_help = """Specifies the log id entry for displaying the error details""" debug_help = """Forces the debug mode with logging on stdout and log level debug.""" version_help = """Displays pg_chameleon's installed version.""" rollbar_help = """Overrides the level for messages to be sent to rolllbar. One of: "critical", "error", "warning", "info". The Default is "info" """ full_help = """When specified with run_maintenance the switch performs a vacuum full instead of a normal vacuum. """ parser = argparse.ArgumentParser(description='Command line for pg_chameleon.', add_help=True) parser.add_argument('command', type=str, help=command_help) parser.add_argument('--config', type=str, default='default', required=False, help=config_help) parser.add_argument('--schema', type=str, default='*', required=False, help=schema_help) parser.add_argument('--source', type=str, default='*', required=False, help=source_help) parser.add_argument('--tables', type=str, default='*', required=False, help=tables_help) parser.add_argument('--logid', type=str, default='*', required=False, help=logid_help) parser.add_argument('--debug', default=False, required=False, help=debug_help, action='store_true') parser.add_argument('--version', action='version', help=version_help,version='{version}'.format(version=__version__)) parser.add_argument('--rollbar-level', type=str, default="info", required=False, help=rollbar_help) parser.add_argument('--full', default=False, required=False, help=full_help, action='store_true') args = parser.parse_args() replica = replica_engine(args) if args.debug: getattr(replica, args.command)() else: try: getattr(replica, args.command)() except AttributeError: print("ERROR - Invalid command" ) print(command_help)