Example #1
0
    def regularTest(self):
        cur_sys_info = self.db_util.get_system_by_id(self.idx)
        up_pair = cur_sys_info.get_account_data(username=self.m_Text_Name.GetValue(), password=self.m_Text_PSW.GetValue())
        up_pair_crypt = []
        for i in up_pair:
            temp = (i[0],crypt(i[1]))
            up_pair_crypt.append(temp)

        #if table not exists, set up_pair_crypt to db

        crypt_list = self.db_util.get_crypt_by_systemID(self.idx)
        d = {}
        for i in crypt_list:
            d[i[0]] = (i[1],i[2])

        new_list = []

        now = datetime.datetime.now()
        if cur_sys_info.last_update_time == None:
            dTime = 0
        else:
            dTime = (now - cur_sys_info.last_update_time).days
        cur_sys_info.last_update_time = now
        self.db_util.update_system(cur_sys_info)

        count = 0
        for i in up_pair_crypt:
            temp1 = None
            if d.has_key(i[0]) == True:
                if i[1] == d[i[0]][0]:
                    temp1 = (i[0],i[1],d[i[0]][1] + dTime)
                    if temp1[2] >= detect_period:
                        self.parent.m_ListCtrl.InsertStringItem(count,str(count+1))
                        self.parent.m_ListCtrl.SetStringItem(count,1,temp1[0])
                        self.parent.m_ListCtrl.SetStringItem(count,2,str(temp1[2]))
                        count += 1
                else:
                    temp1 = (i[0],i[1],0)
            else:
                temp1 = (i[0],i[1],0)
            new_list.append(temp1)

        self.db_util.set_crypt(self.idx, new_list)
        self.parent.m_Gauge.SetValue(100)
    def run(self): #Overwrite run() method, put what you want the thread do here
        print("todo:regular test")
        cur_sys_info = self.db_util.get_system_by_id(self.idx)
        up_pair = self.cur_sys_info.get_account_data(username=self.db_user_name, password=self.db_pass_wd)
        up_pair_crypt = []
        for i in up_pair:
            temp = (i[0],crypt(i[1]))
            up_pair_crypt.append(temp)

        #if table not exists, set up_pair_crypt to db

        crypt_list = self.db_util.get_crypt_by_systemID(self.idx)
        new_list = []
        symbol = False
        #dTime = updateDtime('2015-11-05')
        now = datetime.datetime.now()
        dTime = (now - cur_sys_info.last_update_time).days
        cur_sys_info.last_update_time = now
        self.db_util.update_system(cur_sys_info)

        for i in up_pair_crypt:
            for j in crypt_list:
                if i[0] != j[0]:
                    symbol = True
                    continue
                else:
                    symbol = False
                    if i[1] != j[1]:
                        temp = (i[0],i[1],0)
                    else:
                        temp = (i[0],i[1],j[2] + dTime)
            if symbol == True:
                temp = (i[0],i[1],0)
                symbol = False
            new_list.append(temp)

        self.db_util.set_crypt(self.idx, new_list)
        self.parent.m_Gauge.SetValue(100)