Example #1
0
    def ReadSection(self):
        self.__str_list = []
        is_eof = False
        cur_session_id = ''
        try:
            pattern = re.compile(MATCH_SESSIONID)
            while (not is_eof):

                if self.__str_lastline == '':
                    self.__str_line = self.__str_file.readline()
                else:
                    self.__str_line = self.__str_lastline
                    self.__str_lastline = ''

                #print("Read:len=%s"%self.__str_line)

                if self.__str_line == '':           ### 判断文件是否结束
                    LOGDebug.debug("Reach end of file.")
                    is_eof = True
                    continue

                session_id_list = pattern.findall( self.__str_line)
                if len(session_id_list) > 0:        # 找到session_id
                    if session_id_list[0] != cur_session_id:
                        if cur_session_id == '':
                            cur_session_id = session_id_list[0]
                        else:
                            self.__str_lastline = self.__str_line
                            break
                    self.__str_list.append(self.__str_line)

        except EOFError:
            LOGError.error("End of File Error!")
        except:
            LOGError.error("Read file faild!")
            self.__str_file.close()
            return []
        return self.__str_list
Example #2
0
 def ConnectDb(self):
     LOGDebug.debug("Connect database..")
     pass
Example #3
0
 def SetDbObj(self, host,dbName, tableName):
     LOGDebug.debug("use Database %s", self.__dbType)
     self.__dbObj = DictDataBaseType.get(self.__dbType)(host, dbName, tableName)