Exemple #1
0
    def help_list(self, dictionary):
        path = os.path.dirname(dictionary.get_pod_fname())
        file_list = os.listdir(path)
        file_list.sort()

        response = dictionary.get_pod_response_body()
        short = response['BRIEF']

        for file in file_list:
            # only usef alpha prefix file name
            if not re.match('^[a-zA-Z]', file):
                continue

            sub_fname = path.rstrip('/') + '/' + file
            sub_dic = pod.CommandDictionary()
            sub_dic.set_pod_fname(sub_fname)
            sub_dic.open_pod()
            brief = sub_dic.get_pod_help_brief()

            short.append({'NAME': file.split('.')[0], 'DESC': brief})

        # delete template value
        del short[0]
        output = dictionary.get_pod_display_help_brief()
        return output
Exemple #2
0
    def help_detail(self, dictionary, fname):
        cmd_dict = pod.CommandDictionary()
        cmd_dict.set_pod_fname(fname)
        cmd_dict.open_pod()

        output = cmd_dict.get_pod_display_help()
        if output is None:
            dictionary.set_pod_error_string(cmd_dict.get_pod_error_string())
            return None

        response = dictionary.get_pod_response_body()
        response['DETAIL'] = output
        output = dictionary.get_pod_display_help_detail()
        return output
Exemple #3
0
    def __init__(self, ip, port, server_type="COMMAND", event_loop=None):
        self.__type = server_type
        self.__loop = event_loop
        self.__addr = (ip, port)
        self.__protocol = EMSProtocol(ip, port)

        # EMS Transaction Protocol Key
        self.__key = 0

        # Pending Queue for request messages
        self.__qtick = 5
        self.__qtimer = None
        self.__queue = util.PendingQueue()
        self.__queue.set_expire_tick(self.__qtick)

        self.__pod = pod.CommandDictionary()
        self.__clients = set()
Exemple #4
0
    def do_job(self, path):
        if self.do_parging() is not True:
            return None

        dictionary = list()
        for command in self.__command_list:
            fname = self.__get_command_fname(path, command['name'])
            if fname is None:
                self.__error_string = \
                        "fail, undefined command name [{0}]"\
                        .format(command['line'])
                return None
            try:
                instance = pod.CommandDictionary()
                instance.set_pod_fname(fname)
                e_code = instance.open_pod()
                if e_code is not True:
                    self.__error_string += instance.get_pod_error_string()
                    trace.error(self.__error_string)
                    return None

                instance.set_pod_command(command['line'])
                e_code = instance.set_pod_request(command['parameter'])
                if e_code is not True:
                    trace.error(instance.get_pod_error_string())
                    self.__error_string += instance.get_pod_error_string()
                    return None

                dictionary.append(instance)
            except Exception as ex:
                self.__error_string += instance.get_pod_error_string()
                self.__error_string += "[exception [name:{0}, args:{1}]"\
                                        .format(type(ex).__name__, ex.args)
                trace.error(self.__error_string)
                return None
        return tuple(dictionary)