def setUp(self): EnvironmentUtil.setup_fresh_test_env() self.context = CommandContext.via({'type': 'memory-db'}) self.downCommand = DownCommand(self.context) self.newCommand = NewCommand(self.context) self.upCommand = UpCommand(self.context) self.checkCommand = CheckCommand(self.context)
def init(cls): if not cls.initialized: cls.context = CommandContext.via({ 'type': 'memory-db'}) cls.newCommand = NewCommand(cls.context) cls.upCommand = UpCommand(cls.context) cls.initialized = True
def setUp(self): EnvironmentUtil.setup_fresh_test_env() self.context = CommandContext.via({ 'type': 'memory-db'}) self.downCommand = DownCommand(self.context) self.newCommand = NewCommand(self.context) self.upCommand = UpCommand(self.context) self.checkCommand = CheckCommand(self.context)
def main(): """ Determine what command is being called and dispatch it to the appropriate handler. If the command is unknown or the '-h' or '-v' flag has been given, display help-file or version-info, respectively. """ commands = [ " new Create a new alter", " check Check that all back-refs constitute a valid chain", " list List the current alter chain", " up Bring up to particular revision", " down Roll back to a particular revision", " rebuild Run the entire database down and back up (hard refresh)", " gen-ref Generate new file-ref", " gen-sql Generate SQL for a given reference, including revision-history alter(s)", " resolve Resolve a divergent-branch conflict (found by 'check' command)", " init Initialize new project", " version Shows current version of tool", " help Show this help message and exit" ] usage = "schema command [options]\n\nCommands:\n" + ("\n".join(commands)) parser = OptionParser(usage=usage) if len(sys.argv) == 1: sys.stderr.write( "Error: No commands or options given, view -h for each\n" + " command for more information\n\n") parser.print_help() sys.exit(1) if sys.argv[1] in ['-v', '--version', 'version']: sys.stderr.write('Version: %s\n' % Constants.VERSION) sys.exit(0) if sys.argv[1] in ['-h', '--help', 'help']: parser.print_help() sys.exit(0) # load and validate config config = load_config() config_errors = CommandContext.validate_config(config) if not len(config_errors) == 0: sys.stderr.write("Error: Configurations are not valid:\n") for error in config_errors: sys.stderr.write("\t%s\n" % error) sys.exit(1) # check if the command given is valid and dispatch appropriately user_command = sys.argv[1] if user_command in [c['command'] for c in Constants.COMMANDS]: # strip command-name from arguments sys.argv = sys.argv[1:] # Create context and select handler and attempt to dispatch context = CommandContext.via(config) handler = [ c['handler'] for c in Constants.COMMANDS if c['command'] == user_command ][0] try: globals()[handler](context).run() # Errors that are caught by the application code except tuple([ i[1] for i in inspect.getmembers(errors) if inspect.isclass(i[1]) ]), e: sys.stderr.write("Error: ") for i in e.args: sys.stderr.write("%s\n\n" % i) sys.exit(1) # Uncaught errors except (Exception, EnvironmentError), ex: sys.stderr.write( "An exception has occurred... Sorry. You should file a ticket in\nour issue tracker: %s\n\n" % (Constants.ISSUE_URL)) if isinstance(ex, EnvironmentError): sys.stderr.write("Error: %s, %s\n\n" % (ex.errno, ex.strerror)) else: sys.stderr.write("Error: %s\n\n" % ex) print_exc() sys.exit(1)
def setUp(self): EnvironmentUtil.setup_fresh_test_env() self.context = CommandContext.via({ 'type': 'memory-db'}) self.listCommand = ListCommand(self.context)
def init(cls): if not cls.initialized: cls.context = CommandContext.via({'type': 'memory-db'}) cls.newCommand = NewCommand(cls.context) cls.upCommand = UpCommand(cls.context) cls.initialized = True
def setUp(self): EnvironmentUtil.setup_fresh_test_env() self.context = CommandContext.via({"type": "memory-db"}) self.newCommand = NewCommand(self.context)
def main(): """ Determine what command is being called and dispatch it to the appropriate handler. If the command is unknown or the '-h' or '-v' flag has been given, display help-file or version-info, respectively. """ commands = [ " new Create a new alter", " check Check that all back-refs constitute a valid chain", " list List the current alter chain", " up Bring up to particular revision", " down Roll back to a particular revision", " rebuild Run the entire database down and back up (hard refresh)", " gen-ref Generate new file-ref", " gen-sql Generate SQL (DBA Files) for a given reference, including revision-history alter(s)", " resolve Resolve a divergent-branch conflict (found by 'check' command)", " init Initialize new project", " version Shows current version of tool", " help Show this help message and exit" ] usage = "schema command [options]\n\nCommands:\n" + ("\n".join(commands)) parser = OptionParser(usage=usage) if len(sys.argv) == 1: sys.stderr.write("Error: No commands or options given, view -h for each\n" + " command for more information\n\n") parser.print_help(); sys.exit(1) if sys.argv[1] in ['-v', '--version', 'version']: sys.stderr.write('Version: %s\n' % Constants.VERSION) sys.exit(0) if sys.argv[1] in ['-h', '--help', 'help']: parser.print_help() sys.exit(0) # load and validate config config = load_config() config_errors = CommandContext.validate_config(config) if not len(config_errors) == 0: sys.stderr.write("Error: Configurations are not valid:\n") for error in config_errors: sys.stderr.write("\t%s\n" % error) sys.exit(1) # check if the command given is valid and dispatch appropriately user_command = sys.argv[1] if user_command in [c['command'] for c in Constants.COMMANDS]: # strip command-name from arguments sys.argv = sys.argv[1:] # Create context and select handler and attempt to dispatch context = CommandContext.via(config) handler = [c['handler'] for c in Constants.COMMANDS if c['command'] == user_command][0] try: globals()[handler](context).run() # Errors that are caught by the application code except tuple([i[1] for i in inspect.getmembers(errors) if inspect.isclass(i[1])]), e: sys.stderr.write("Error: ") for i in e.args: sys.stderr.write("%s\n\n" % i) sys.exit(1) # Uncaught errors except (Exception, EnvironmentError), ex: sys.stderr.write( "An exception has occurred... Sorry. You should file a ticket in\nour issue tracker: %s\n\n" % ( Constants.ISSUE_URL)) if isinstance(ex, EnvironmentError): sys.stderr.write("Error: %s, %s\n\n" % (ex.errno, ex.strerror)) else: sys.stderr.write("Error: %s\n\n" % ex) print_exc() sys.exit(1)
def setUp(self): EnvironmentUtil.setup_fresh_test_env() self.context = CommandContext.via({'type': 'memory-db'}) self.listCommand = ListCommand(self.context)