コード例 #1
0
    def load_connection_names(self):
        '''
        load all connection names from workspace
        @return: count of connections
        '''
        # setup the connection file path into workspace folder
        fileconstant = File_constant()
        workspacepath = self.get_trans().get_workspacepath()
        cassandra_conection_folder = workspacepath + fileconstant.CASSANDRA_CONFIG_FOLDER

        if not File_processor.verify_dir_existing(cassandra_conection_folder):
            File_processor.create_folder(cassandra_conection_folder)

        cassandra_conection_file = cassandra_conection_folder + fileconstant.CASSANDRA_CONNECTION_FILE

        # verify connection file existing
        if not File_processor.verify_file(cassandra_conection_file):
            showerror('Error', 'Cassandra connection file does not exist!')
            return 0

        # load connection names
        connection_names = Database_connection_file_processor.read_connection_names(
            cassandra_conection_file)
        # set tuple to combox list
        self.__comboxlist["values"] = tuple(connection_names)
        if len(self.__comboxlist["values"]) == 0:
            showerror('Error', 'No valid connection, please add one first!')
            return 0

        # default the first one
        self.__comboxlist.current(0)

        # load connection parameters
        connection_params = Database_connection_file_processor.read_connection_params(
            cassandra_conection_file, self.__comboxlist.get())
        # set parameters
        self.__input02.delete(0, END)
        self.__input02.insert(END, connection_params['host'])
        self.__input03.delete(0, END)
        self.__input03.insert(END, connection_params['port'])
        self.__input04.delete(0, END)
        self.__input04.insert(END, connection_params['username'])
        self.__input05.delete(0, END)
        self.__input05.insert(END, connection_params['password'])

        return len(self.__comboxlist["values"])
コード例 #2
0
    def before_next(self):
        '''
        overwrite the function in super class
        verify the input directory
        generating the next frames according to the selections
        '''
        # verify the connection name
        if not self.__input01.get(
        ) and self.__maintain_mode == MATAIN_MODE_NEW:
            showerror('Error', 'Please provide the connection name!')
            return False

        # verify the input value
        if not self.__input02.get() or not self.__input03.get(
        ) or not self.__input04.get() or not self.__input05.get():
            showerror('Error', 'Please provide the complete info!')
            return False

        # setup the connection file path into workspace folder
        fileconstant = File_constant()
        workspacepath = self.get_trans().get_workspacepath()
        cassandra_conection_folder = workspacepath + fileconstant.CASSANDRA_CONFIG_FOLDER

        if not File_processor.verify_dir_existing(cassandra_conection_folder):
            File_processor.create_folder(cassandra_conection_folder)

        cassandra_conection_file = cassandra_conection_folder + fileconstant.CASSANDRA_CONNECTION_FILE

        # combine the connection parameter
        # TODO: this should be implemented as toString() in Cassandra_connection_dto
        if self.__maintain_mode == MATAIN_MODE_NEW:
            connection_name = self.__input01.get()
            connection_param = self.__input01.get(
            ) + ':' + 'host=' + self.__input02.get(
            ) + ',port=' + self.__input03.get(
            ) + ',username='******',password='******':' + 'host=' + self.__input02.get(
            ) + ',port=' + self.__input03.get(
            ) + ',username='******',password='******'Warning',
                        'The connection name is existing, do you confirm to overwrite?'
                ):
                    return False
            Database_connection_file_processor.update_connection_file(
                cassandra_conection_file, connection_name, connection_param)

        return True