def OK_button(self, evt): if self.m_Text_SysName.GetValue() == "" or self.m_Text_IP.GetValue() == " . . . " or self.m_Text_Port.GetValue() == "" or self.m_Choice_DBType.GetSelection() == -1 or self.m_Choice_Cyptype.GetSelection() == -1 or self.m_Text_DBname.GetValue() == "" or self.m_Text_Sheetname.GetValue() == "" or self.m_Text_Username.GetValue() == "" or self.m_Text_Pswname.GetValue() == "": dlg = wx.MessageDialog(None, u"请输入完整信息!", u"提示", wx.YES_NO | wx.ICON_QUESTION) if dlg.ShowModal() == wx.ID_YES: #self.Close(True) dlg.Destroy() else: db_util = DBUtil() if self.m_Choice_Cyptype.GetSelection() == 0: cyp_type = EncryptAlgorithmType.md5 elif self.m_Choice_Cyptype.GetSelection() == 1: cyp_type = EncryptAlgorithmType.sha1 if self.m_Choice_DBType.GetSelection() == 0: db_type = DatabaseType.mysql elif self.m_Choice_DBType.GetSelection() == 1: db_type = DatabaseType.oracle demo_system = SystemInfo(sys_name=self.m_Text_SysName.GetValue(), db_type=db_type, db_ip=self.m_Text_IP.GetValue(), db_port=self.m_Text_Port.GetValue(), db_name=self.m_Text_DBname.GetValue(), db_table_name=self.m_Text_Sheetname.GetValue(), db_column_username=self.m_Text_Username.GetValue(), db_column_password=self.m_Text_Pswname.GetValue(), db_password_encrypt_algorithm=cyp_type) db_util.add_system(demo_system) dlg = wx.MessageDialog(None, u"添加成功!", u"提示", wx.YES_NO | wx.ICON_QUESTION) if dlg.ShowModal() == wx.ID_YES: dlg.Destroy() self.Destroy() self.parent.RefreshSysList()
def __init__(self, parent, idx): self.parent = parent super(timer, self).__init__() self._stop = threading.Event() db_util = DBUtil() self.cur_sys_info = db_util.get_system_by_id(idx)
def __init__( self, parent, ID, title, idx, size=wx.DefaultSize, pos=wx.DefaultPosition, style=wx.DEFAULT_DIALOG_STYLE, useMetal=False, ): self.parent = parent pre = wx.PreDialog() pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP) pre.Create(parent, ID, title, pos, size, style) self.PostCreate(pre) # This extra style can be set after the UI object has been created. if 'wxMac' in wx.PlatformInfo and useMetal: self.SetExtraStyle(wx.DIALOG_EX_METAL) # Now continue with the normal construction of the dialog # contents sizer = wx.BoxSizer(wx.VERTICAL) box = wx.BoxSizer(wx.HORIZONTAL) self.m_Label_Name = wx.StaticText(self,wx.ID_ANY, u"用户名",style = wx.ALIGN_CENTER) self.m_Text_Name = wx.TextCtrl(self) box.Add(self.m_Label_Name, 1, wx.ALIGN_CENTRE|wx.ALL, 5) box.Add(self.m_Text_Name, 1, wx.ALIGN_CENTRE|wx.ALL, 5) sizer.Add(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5) box = wx.BoxSizer(wx.HORIZONTAL) m_Label_PSW = wx.StaticText(self, wx.ID_ANY, u"密码",style = wx.ALIGN_CENTER) self.m_Text_PSW = wx.TextCtrl(self, style=wx.TE_PASSWORD) box.Add(m_Label_PSW, 1, wx.ALIGN_CENTRE|wx.ALL, 5) box.Add(self.m_Text_PSW, 1, wx.ALIGN_CENTRE|wx.ALL, 5) sizer.Add(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5) line = wx.StaticLine(self, -1, size=(20,-1), style=wx.LI_HORIZONTAL) sizer.Add(line, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.RIGHT|wx.TOP, 5) box = wx.BoxSizer(wx.HORIZONTAL) bt_Ok = wx.Button(self,wx.ID_ANY,label=u"确定") bt_Cancel = wx.Button(self,wx.ID_ANY,label=u"取消") box.Add(bt_Ok,1, wx.ALIGN_CENTRE|wx.ALL, 5) box.Add(bt_Cancel,1, wx.ALIGN_CENTRE|wx.ALL, 5) sizer.Add(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5) self.SetSizer(sizer) sizer.Fit(self) self.Bind(wx.EVT_BUTTON, self.OK_button, bt_Ok) self.Bind(wx.EVT_BUTTON, self.Cancel_Button, bt_Cancel) db_util = DBUtil() self.cur_sys_info = db_util.get_system_by_id(idx)
def RefreshSysList(self): self.listBox.Clear() self.sampleList = [] db_util = DBUtil() res = [] self.idList = [] res = db_util.get_all_system() print ("Find " + str(len(res)) + " Systems in the local db") for i in res: self.sampleList.append(i.sys_name) self.idList.append(i.id) #print self.idList self.listBox.SetItems(self.sampleList)
def __init__(self, parent, idx): self.parent = parent super(regularThread, self).__init__() self._stop = threading.Event() self.db_util = DBUtil() self.idx = idx
def DeleteSysButton(self, evt): print self.listBox.GetStringSelection() if self.listBox.GetStringSelection() == '': dlg = wx.MessageDialog(None, u"请在左侧选择系统!", u"提示", wx.YES_NO | wx.ICON_QUESTION) if dlg.ShowModal() == wx.ID_YES: #self.Close(True) dlg.Destroy() else: useMetal = False if 'wxMac' in wx.PlatformInfo: useMetal = self.cb.IsChecked() dlg = wx.MessageDialog(None, u"确定删除此系统?", u"提示", wx.YES_NO | wx.ICON_QUESTION) if dlg.ShowModal() == wx.ID_YES: print "delete that system" print self.listBox.GetSelection() db_util = DBUtil() print self.idList db_util.del_system_by_id(self.idList[self.listBox.GetSelection()]) self.RefreshSysList() dlg.Destroy()
def __init__( self, parent, ID, title, idx, size=wx.DefaultSize, pos=wx.DefaultPosition, style=wx.DEFAULT_DIALOG_STYLE, useMetal=False, ): self.db_util = DBUtil() self.idx = idx self.parent = parent pre = wx.PreDialog() pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP) pre.Create(parent, ID, title, pos, size, style) self.PostCreate(pre) if 'wxMac' in wx.PlatformInfo and useMetal: self.SetExtraStyle(wx.DIALOG_EX_METAL) sizer = wx.BoxSizer(wx.VERTICAL) box = wx.BoxSizer(wx.HORIZONTAL) self.m_Label_Name = wx.StaticText(self,wx.ID_ANY, u"用户名",style = wx.ALIGN_CENTER) self.m_Text_Name = wx.TextCtrl(self) box.Add(self.m_Label_Name, 1, wx.ALIGN_CENTRE|wx.ALL, 5) box.Add(self.m_Text_Name, 1, wx.ALIGN_CENTRE|wx.ALL, 5) sizer.Add(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5) box = wx.BoxSizer(wx.HORIZONTAL) m_Label_PSW = wx.StaticText(self, wx.ID_ANY, u"密码",style = wx.ALIGN_CENTER) self.m_Text_PSW = wx.TextCtrl(self, style=wx.TE_PASSWORD) box.Add(m_Label_PSW, 1, wx.ALIGN_CENTRE|wx.ALL, 5) box.Add(self.m_Text_PSW, 1, wx.ALIGN_CENTRE|wx.ALL, 5) sizer.Add(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5) line = wx.StaticLine(self, -1, size=(20,-1), style=wx.LI_HORIZONTAL) sizer.Add(line, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.RIGHT|wx.TOP, 5) box = wx.BoxSizer(wx.HORIZONTAL) bt_Ok = wx.Button(self,wx.ID_ANY,label=u"确定") bt_Cancel = wx.Button(self,wx.ID_ANY,label=u"取消") box.Add(bt_Ok,1, wx.ALIGN_CENTRE|wx.ALL, 5) box.Add(bt_Cancel,1, wx.ALIGN_CENTRE|wx.ALL, 5) sizer.Add(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5) self.SetSizer(sizer) sizer.Fit(self) self.Bind(wx.EVT_BUTTON, self.OK_button, bt_Ok) self.Bind(wx.EVT_BUTTON, self.Cancel_Button, bt_Cancel)
def __init__( self, parent, ID, title, idx, size=wx.DefaultSize, pos=wx.DefaultPosition, style=wx.DEFAULT_DIALOG_STYLE, useMetal=False ): # Instead of calling wx.Dialog.__init__ we precreate the dialog # so we can set an extra style that must be set before # creation, and then we create the GUI object using the Create # method. pre = wx.PreDialog() pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP) pre.Create(parent, ID, title, pos, size, style) # This next step is the most important, it turns this Python # object into the real wrapper of the dialog (instead of pre) # as far as the wxPython extension is concerned. self.PostCreate(pre) # This extra style can be set after the UI object has been created. if 'wxMac' in wx.PlatformInfo and useMetal: self.SetExtraStyle(wx.DIALOG_EX_METAL) # Now continue with the normal construction of the dialog # contents sizer = wx.BoxSizer(wx.VERTICAL) label = wx.StaticText(self, -1, u"请编辑系统基本信息") label.SetHelpText("This is the help text for the label") sizer.Add(label, 0, wx.ALIGN_CENTRE|wx.ALL, 5) box = wx.BoxSizer(wx.HORIZONTAL) self.m_Label_SysName = wx.StaticText(self,wx.ID_ANY, u"系统名称") self.m_Text_SysName = wx.TextCtrl(self) self.m_Text_SysName.SetEditable(False) box.Add(self.m_Label_SysName, 1, wx.ALIGN_CENTRE|wx.ALL, 5) box.Add(self.m_Text_SysName, 3, wx.ALIGN_CENTRE|wx.ALL, 5) sizer.Add(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5) box = wx.BoxSizer(wx.HORIZONTAL) m_Label_IP = wx.StaticText(self, wx.ID_ANY, u"IP地址") self.m_Text_IP = masked.IpAddrCtrl(self, -1, style = wx.TE_PROCESS_TAB) m_Label_Port = wx.StaticText(self,wx.ID_ANY,u"端口号") self.m_Text_Port = wx.TextCtrl(self) box.Add(m_Label_IP, 1, wx.ALIGN_CENTRE|wx.ALL, 5) box.Add(self.m_Text_IP, 2, wx.ALIGN_CENTRE|wx.ALL, 5) box.Add(m_Label_Port, 1, wx.ALIGN_CENTRE|wx.ALL, 5) box.Add(self.m_Text_Port, 2, wx.ALIGN_CENTRE|wx.ALL, 5) sizer.Add(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5) box = wx.BoxSizer(wx.HORIZONTAL) m_Label_DBType = wx.StaticText(self,wx.ID_ANY,u"数据库类型") sampleList = db_type_list self.m_Choice_DBType = wx.Choice(self, choices=sampleList) m_Label_Cyptype = wx.StaticText(self,wx.ID_ANY,u"加密算法") sampleList1 = crypt_type_list self.m_Choice_Cyptype = wx.Choice(self,choices=sampleList1) box.Add(m_Label_DBType, 1, wx.ALIGN_CENTRE|wx.ALL, 5) box.Add(self.m_Choice_DBType, 2, wx.ALIGN_CENTRE|wx.ALL, 5) box.Add(m_Label_Cyptype, 1, wx.ALIGN_CENTRE|wx.ALL, 5) box.Add(self.m_Choice_Cyptype, 2, wx.ALIGN_CENTRE|wx.ALL, 5) sizer.Add(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5) box = wx.BoxSizer(wx.HORIZONTAL) m_Label_DBname = wx.StaticText(self, wx.ID_ANY, u"数据库名") self.m_Text_DBname = wx.TextCtrl(self) m_Label_Sheetname = wx.StaticText(self, wx.ID_ANY, u"表名") self.m_Text_Sheetname = wx.TextCtrl(self) box.Add(m_Label_DBname, 1, wx.ALIGN_CENTRE|wx.ALL, 5) box.Add(self.m_Text_DBname, 2, wx.ALIGN_CENTRE|wx.ALL, 5) box.Add(m_Label_Sheetname, 1, wx.ALIGN_CENTRE|wx.ALL, 5) box.Add(self.m_Text_Sheetname, 2, wx.ALIGN_CENTRE|wx.ALL, 5) sizer.Add(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5) box = wx.BoxSizer(wx.HORIZONTAL) m_Label_Username = wx.StaticText(self, wx.ID_ANY, u"账号字段名") self.m_Text_Username = wx.TextCtrl(self) m_Label_Pswname = wx.StaticText(self, wx.ID_ANY, u"密码字段名") self.m_Text_Pswname = wx.TextCtrl(self) box.Add(m_Label_Username, 1, wx.ALIGN_CENTRE|wx.ALL, 5) box.Add(self.m_Text_Username, 2, wx.ALIGN_CENTRE|wx.ALL, 5) box.Add(m_Label_Pswname, 1, wx.ALIGN_CENTRE|wx.ALL, 5) box.Add(self.m_Text_Pswname, 2, wx.ALIGN_CENTRE|wx.ALL, 5) sizer.Add(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5) line = wx.StaticLine(self, -1, size=(20,-1), style=wx.LI_HORIZONTAL) sizer.Add(line, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.RIGHT|wx.TOP, 5) box = wx.BoxSizer(wx.HORIZONTAL) bt_Ok = wx.Button(self,wx.ID_ANY,label=u"确定") bt_Cancel = wx.Button(self,wx.ID_ANY,label=u"取消") box.Add(bt_Ok,1, wx.ALIGN_CENTRE|wx.ALL, 5) box.Add(bt_Cancel,1, wx.ALIGN_CENTRE|wx.ALL, 5) sizer.Add(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5) self.SetSizer(sizer) sizer.Fit(self) self.Bind(wx.EVT_BUTTON, self.OK_button, bt_Ok) self.Bind(wx.EVT_BUTTON, self.Cancel_Button, bt_Cancel) db_util = DBUtil() self.cur_sys_info = db_util.get_system_by_id(idx) self.m_Text_SysName.SetValue(self.cur_sys_info.sys_name) self.m_Text_IP.SetValue(self.cur_sys_info.db_ip) self.m_Text_Port.SetValue(self.cur_sys_info.db_port) self.m_Text_DBname.SetValue(self.cur_sys_info.db_name) self.m_Text_Sheetname.SetValue(self.cur_sys_info.db_table_name) self.m_Text_Username.SetValue(self.cur_sys_info.db_column_username) self.m_Text_Pswname.SetValue(self.cur_sys_info.db_column_password) if self.cur_sys_info.db_type == DatabaseType.mysql: self.m_Choice_DBType.SetSelection(0) elif self.cur_sys_info.db_type == DatabaseType.oracle: self.m_Choice_DBType.SetSelection(1) if self.cur_sys_info.db_password_encrypt_algorithm == EncryptAlgorithmType.md5: self.m_Choice_Cyptype.SetSelection(0) elif self.cur_sys_info.db_password_encrypt_algorithm == EncryptAlgorithmType.sha1: self.m_Choice_Cyptype.SetSelection(1)
class exportRegularDialog(wx.Dialog): #cur_sys_info = None parent = None idx = None db_util = None def __init__( self, parent, ID, title, idx, size=wx.DefaultSize, pos=wx.DefaultPosition, style=wx.DEFAULT_DIALOG_STYLE, useMetal=False, ): self.parent = parent self.idx = idx self.db_util = DBUtil() pre = wx.PreDialog() pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP) pre.Create(parent, ID, title, pos, size, style) self.PostCreate(pre) # This extra style can be set after the UI object has been created. if 'wxMac' in wx.PlatformInfo and useMetal: self.SetExtraStyle(wx.DIALOG_EX_METAL) # Now continue with the normal construction of the dialog # contents sizer = wx.BoxSizer(wx.VERTICAL) box = wx.BoxSizer(wx.HORIZONTAL) self.m_Label_Day = wx.StaticText(self,wx.ID_ANY, u"限制天数",style = wx.ALIGN_CENTER) self.m_Text_Day = wx.TextCtrl(self) box.Add(self.m_Label_Day, 1, wx.ALIGN_CENTRE|wx.ALL, 5) box.Add(self.m_Text_Day, 1, wx.ALIGN_CENTRE|wx.ALL, 5) sizer.Add(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5) line = wx.StaticLine(self, -1, size=(20,-1), style=wx.LI_HORIZONTAL) sizer.Add(line, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.RIGHT|wx.TOP, 5) box = wx.BoxSizer(wx.HORIZONTAL) bt_Ok = wx.Button(self,wx.ID_ANY,label=u"确定") bt_Cancel = wx.Button(self,wx.ID_ANY,label=u"取消") box.Add(bt_Ok,1, wx.ALIGN_CENTRE|wx.ALL, 5) box.Add(bt_Cancel,1, wx.ALIGN_CENTRE|wx.ALL, 5) sizer.Add(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5) self.SetSizer(sizer) sizer.Fit(self) self.Bind(wx.EVT_BUTTON, self.OK_button, bt_Ok) self.Bind(wx.EVT_BUTTON, self.Cancel_Button, bt_Cancel) def OK_button(self, evt): #print("ok!") rl = [] count = 0 if self.m_Text_Day.GetValue() == "": dlg = wx.MessageDialog(None, u"请输入限制天数!", u"提示", wx.YES_NO | wx.ICON_QUESTION) if dlg.ShowModal() == wx.ID_YES: dlg.Destroy() else: crypt_list = self.db_util.get_crypt_by_systemID(self.idx) for i in crypt_list: if i[2] >= int(self.m_Text_Day.GetValue()): count += 1 temp = {'name' : 'aaaa1', 'day' : '31'} temp['name'] = i[0] temp['day'] = str(i[2]) rl.append(temp) print "input period: " + self.m_Text_Day.GetValue() generate_unmod_statement(self.parent.listBox.GetStringSelection(), u'汪明', rl, len(crypt_list), self.m_Text_Day.GetValue()) print("export report") self.Destroy() def Cancel_Button(self, evt): print("cancel!") self.Destroy()
class ReguTestDialog(wx.Dialog): parent = None db_util = None idx = None def __init__( self, parent, ID, title, idx, size=wx.DefaultSize, pos=wx.DefaultPosition, style=wx.DEFAULT_DIALOG_STYLE, useMetal=False, ): self.db_util = DBUtil() self.idx = idx self.parent = parent pre = wx.PreDialog() pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP) pre.Create(parent, ID, title, pos, size, style) self.PostCreate(pre) if 'wxMac' in wx.PlatformInfo and useMetal: self.SetExtraStyle(wx.DIALOG_EX_METAL) sizer = wx.BoxSizer(wx.VERTICAL) box = wx.BoxSizer(wx.HORIZONTAL) self.m_Label_Name = wx.StaticText(self,wx.ID_ANY, u"用户名",style = wx.ALIGN_CENTER) self.m_Text_Name = wx.TextCtrl(self) box.Add(self.m_Label_Name, 1, wx.ALIGN_CENTRE|wx.ALL, 5) box.Add(self.m_Text_Name, 1, wx.ALIGN_CENTRE|wx.ALL, 5) sizer.Add(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5) box = wx.BoxSizer(wx.HORIZONTAL) m_Label_PSW = wx.StaticText(self, wx.ID_ANY, u"密码",style = wx.ALIGN_CENTER) self.m_Text_PSW = wx.TextCtrl(self, style=wx.TE_PASSWORD) box.Add(m_Label_PSW, 1, wx.ALIGN_CENTRE|wx.ALL, 5) box.Add(self.m_Text_PSW, 1, wx.ALIGN_CENTRE|wx.ALL, 5) sizer.Add(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5) line = wx.StaticLine(self, -1, size=(20,-1), style=wx.LI_HORIZONTAL) sizer.Add(line, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.RIGHT|wx.TOP, 5) box = wx.BoxSizer(wx.HORIZONTAL) bt_Ok = wx.Button(self,wx.ID_ANY,label=u"确定") bt_Cancel = wx.Button(self,wx.ID_ANY,label=u"取消") box.Add(bt_Ok,1, wx.ALIGN_CENTRE|wx.ALL, 5) box.Add(bt_Cancel,1, wx.ALIGN_CENTRE|wx.ALL, 5) sizer.Add(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5) self.SetSizer(sizer) sizer.Fit(self) self.Bind(wx.EVT_BUTTON, self.OK_button, bt_Ok) self.Bind(wx.EVT_BUTTON, self.Cancel_Button, bt_Cancel) def OK_button(self, evt): #print("ok!") if self.m_Text_Name == "" or self.m_Text_PSW == "": dlg = wx.MessageDialog(None, u"请输入完整信息!", u"提示", wx.YES_NO | wx.ICON_QUESTION) if dlg.ShowModal() == wx.ID_YES: dlg.Destroy() else: print("regular modify testing!") self.regularTest() self.Destroy() 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 Cancel_Button(self, evt): print("cancel!") self.Destroy()
class regularThread(threading.Thread): #The timer class is derived from the class threading.Thread parent = None db_user_name = None db_pass_wd = None db_util = None idx = None #crypt_list = [] def __init__(self, parent, idx): self.parent = parent super(regularThread, self).__init__() self._stop = threading.Event() self.db_util = DBUtil() self.idx = idx # self.cur_sys_info = db_util.get_system_by_id(idx) # self.crypt_list = db_util.get_crypt_by_systemID(idx) 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) def stop(self): self._stop.set() def stopped(self): return self._stop.isSet() def set_db_user(self, name, passwd): self.db_user_name = name self.db_pass_wd = passwd