Exemple #1
0
    def execute(self, command_args):
        try:
            repo = Repository()
            repo.name = command_args[1]
            repo.host = command_args[2]
            repo.port = command_args[3]
            repo.username = command_args[4]
            repo.database_driver = command_args[5]
            repo.database_name = command_args[6]
            repo.scripts_path = command_args[7]

            validate_repository(repo)

            if has_errors(repo):
                return console_out(errors_parser(repo))

        except IndexError:
            console_error(
                "In executing command: {}  Not all arguments have been passed.".format(
                    command_to_plain_string(command_args)
                )
            )
        try:
            Repository.create(repo)
        except IntegrityError:
            console_error("Repository {} already exists.".format(repo.name))
            return
        console_info("Repository {} created successfully.".format(repo.name))
Exemple #2
0
 def execute(self, command_args):
     if len(command_args) > 2:
         sys.stdout.write(
             "\nError in executing command: {}  To many arguments".format(command_to_plain_string(command_args))
         )
     else:
         try:
             repo_name = command_args[1]
             Repository.remove_by_name(repo_name)
             console_info("Deleted repository: {}".format(repo_name))
         except RepositoryException:
             console_out("Can't find repository: {}".format(repo_name))
Exemple #3
0
    def execute(self, command_args):
        repo_name = command_args[1]
        file_name = command_args[2]
        repo = Repository.read_by_name(repo_name)
        dump_command = DBResolver.resolve_dump_command(repo.database_driver)
        terminal_cmd = "{} -U {} {} >{}.sql".format(dump_command, repo.username, repo.database_name, file_name)

        try:
            call(terminal_cmd, shell=True)
        except CalledProcessError:
            """TODO handler"""
        else:
            console_info("Database dumped successfully.")