def UrlPageBlackCheckStart(self): chkw = self.urlpage.urlpage_white_start_checkBox.checkState() chkb = self.urlpage.urlpage_black_start_checkBox.checkState() bsetw = 0 bsetb = 0 if chkb == 2 or chkb == 1: # 黑选中 chkb = 2 chkw = 0 bsetb = 1 bsetw = 0 else: pass url = "%s/config/set" % (config.GLB_CFG['SRV_URL']) param = {'WhiteStatus': bsetw, 'BlackStatus': bsetb} ret = http.Post(url, param) if ret['ErrStat'] == 0: # 更新数据 config.GLB_CFG['URL']['White_Start'] = chkw config.GLB_CFG['URL']['Black_Start'] = chkb self.urlpage.urlpage_white_start_checkBox.setCheckState(chkw) self.urlpage.urlpage_black_start_checkBox.setCheckState(chkb) #QMessageBox.about(self, u"设置", u"设置:" + "white=%d" % (chkw) + " black=%d" % (chkb)) else: QMessageBox.about(self, u"设置", u"设置失败:" + ret['ErrMsg'])
def PortPageList_SetList(self): MaxLines = 10 url = "%s/port/list/query" % (config.GLB_CFG['SRV_URL']) param = {'Start' : (self.port_page.port_list_now_page - 1) * MaxLines, 'Length' : MaxLines, } ret = http.Post(url, param) if ret['ErrStat'] == 0: # 清空列表 for i in range(0, 10): for j in range(0, 7): self.port_page.port_list_tableWidget.setItem(i, j, None) # 添加列表 for i in range(0, len(ret['Lists'])): newItem = QTableWidgetItem(ret['Lists'][i]['Pid']) newItem.setTextAlignment(Qt.AlignCenter) self.port_page.port_list_tableWidget.setItem(i, 0, newItem) newItem = QTableWidgetItem(ret['Lists'][i]['Type']) newItem.setTextAlignment(Qt.AlignCenter) self.port_page.port_list_tableWidget.setItem(i, 1, newItem) newItem = QTableWidgetItem(ret['Lists'][i]['Sip']) newItem.setTextAlignment(Qt.AlignCenter) self.port_page.port_list_tableWidget.setItem(i, 2, newItem) newItem = QTableWidgetItem(ret['Lists'][i]['Sport']) newItem.setTextAlignment(Qt.AlignCenter) self.port_page.port_list_tableWidget.setItem(i, 3, newItem) newItem = QTableWidgetItem(ret['Lists'][i]['Dip']) newItem.setTextAlignment(Qt.AlignCenter) self.port_page.port_list_tableWidget.setItem(i, 4, newItem) newItem = QTableWidgetItem(ret['Lists'][i]['Dport']) newItem.setTextAlignment(Qt.AlignCenter) self.port_page.port_list_tableWidget.setItem(i, 5, newItem) newItem = QTableWidgetItem(ret['Lists'][i]['Process']) newItem.setTextAlignment(Qt.AlignLeft) self.port_page.port_list_tableWidget.setItem(i, 6, newItem) tot = ret['Totle'] # 设置当前页码 self.port_page.port_list_now_label.setText(u"%d" %(self.port_page.port_list_now_page)) # 设置总页数 totpage = tot / MaxLines if (tot % MaxLines) > 0 : totpage += 1 self.port_page.port_list_tot_page = totpage self.port_page.port_list_tot_label.setText(u"共 %d 页" %(totpage)) else: QMessageBox.about(self, u"获取使用端口列表", u"错误:" + ret['ErrMsg'])
def SpecrcOkBtnClick(self): url = "%s/config/setspecrc" % (config.GLB_CFG['SRV_URL']) param = { 'ShutDownStatus': self.list_widget_shutdown_value, 'SetTimeStatus': self.list_widget_settime_value } ret = http.Post(url, param) if ret['ErrStat'] == 0: # 更新数据 self.list_widget_shutdown_text.setText(_fromUtf8("已应用到服务器")) self.list_widget_settime_text.setText(_fromUtf8("已应用到服务器")) else: QtGui.QMessageBox.about(self, u"设置", u"设置失败:" + ret['ErrMsg'])
def DeviceOkBtnClick(self): url = "%s/config/setdevice" % (config.GLB_CFG['SRV_URL']) param = { 'CdromStatus': self.list_widget_cdrom_value, 'UsbStatus': self.list_widget_usb_value } ret = http.Post(url, param) if ret['ErrStat'] == 0: # 更新数据 self.list_widget_cdrom_text.setText(_fromUtf8("已应用到服务器")) self.list_widget_usb_text.setText(_fromUtf8("已应用到服务器")) #QtGui.QMessageBox.about(self, u"设置", u"设置:" + "white=%d" % (chkw) + " black=%d" % (chkb)) else: QtGui.QMessageBox.about(self, u"设置", u"设置失败:" + ret['ErrMsg'])
def UrlPageBlackAdd(self): dialog = urlpage.UrlAddDialg() dialog.setModal(False) dialog.exec_() if len(dialog.inputurl) < 1: QMessageBox.about(self, u"添加URL", u"添加失败:URL不能为空") return url = "%s/url/black/add" % (config.GLB_CFG['SRV_URL']) param = {'Url': dialog.inputurl} ret = http.Post(url, param) if ret['ErrStat'] == 0: #QMessageBox.about(self, u"添加URL", u"添加成功") # 刷新列表 self.SetItemUrlBlack(self.urlpage.urlpage_black_tableWidget, 0, 10) else: QMessageBox.about(self, u"添加URL", u"添加失败:" + ret['ErrMsg'])
def InitConfig(self): # 获取配置信息 url = "%s/config/get" % (config.GLB_CFG['SRV_URL']) ret = http.Post(url, {}) if ret['ErrStat'] == 0: bWhite = ret['Config']['White_Start'] bBlack = ret['Config']['Black_Start'] if bWhite != 0: bWhite = 2 if bBlack != 0: bBlack = 2 config.GLB_CFG['URL']['White_Start'] = bWhite config.GLB_CFG['URL']['Black_Start'] = bBlack self.urlpage.urlpage_white_start_checkBox.setCheckState(bWhite) self.urlpage.urlpage_black_start_checkBox.setCheckState(bBlack) return 0 else: QMessageBox.about(self, u"获取配置信息", u"获取配置信息:" + ret['ErrMsg']) return -1
def UrlPageBlackDel(self): itemcnt = self.urlpage.urlpage_black_tableWidget.rowCount() dellist = [] for i in range(0, itemcnt): it = self.urlpage.urlpage_black_tableWidget.item(i, 1) if it == None: continue chk = it.checkState() if chk == 2: # 状态有0和2 dellist.append( self.urlpage.urlpage_black_tableWidget.item(i, 0).text()) url = "%s/url/black/del" % (config.GLB_CFG['SRV_URL']) for u in dellist: param = {'Url': u} ret = http.Post(url, param) if ret['ErrStat'] != 0: QMessageBox.about(self, u"删除URL", u"删除失败: %s\n" % (url) + ret['ErrMsg']) # 刷新列表 self.SetItemUrlBlack(self.urlpage.urlpage_black_tableWidget, 0, 10)
def SpecrcSetStatus(self): url = "%s/config/getspecrc" % (config.GLB_CFG['SRV_URL']) param = {} ret = http.Post(url, param) if ret['ErrStat'] == 0: # 更新数据 self.list_widget_shutdown_value = ret['Config']['ShutDownStatus'] self.list_widget_settime_value = ret['Config']['SetTimeStatus'] if self.list_widget_shutdown_value == 1: self.list_widget_shutdown_onoff.setStyleSheet( _fromUtf8("border-image: url(:/image/btn_on.png);")) else: self.list_widget_shutdown_onoff.setStyleSheet( _fromUtf8("border-image: url(:/image/btn_off.png);")) if self.list_widget_settime_value == 1: self.list_widget_settime_onoff.setStyleSheet( _fromUtf8("border-image: url(:/image/btn_on.png);")) else: self.list_widget_settime_onoff.setStyleSheet( _fromUtf8("border-image: url(:/image/btn_off.png);")) else: QtGui.QMessageBox.about(self, u"设置", u"设置失败:" + ret['ErrMsg'])
def DeviceSetStatus(self): url = "%s/config/getdevice" % (config.GLB_CFG['SRV_URL']) param = {} ret = http.Post(url, param) if ret['ErrStat'] == 0: # 更新数据 self.list_widget_cdrom_value = ret['Config']['CdromStatus'] self.list_widget_usb_value = ret['Config']['UsbStatus'] if self.list_widget_cdrom_value == 1: self.list_widget_cdrom_onoff.setStyleSheet( _fromUtf8("border-image: url(:/image/btn_on.png);")) else: self.list_widget_cdrom_onoff.setStyleSheet( _fromUtf8("border-image: url(:/image/btn_off.png);")) if self.list_widget_usb_value == 1: self.list_widget_usb_onoff.setStyleSheet( _fromUtf8("border-image: url(:/image/btn_on.png);")) else: self.list_widget_usb_onoff.setStyleSheet( _fromUtf8("border-image: url(:/image/btn_off.png);")) #QtGui.QMessageBox.about(self, u"设置", u"设置:" + "white=%d" % (chkw) + " black=%d" % (chkb)) else: QtGui.QMessageBox.about(self, u"设置", u"设置失败:" + ret['ErrMsg'])
def SetItemUrlWhite(self, qlistwidget, start, length): url = "%s/url/white/getlist" % (config.GLB_CFG['SRV_URL']) param = {'Start': start, 'Length': length} ret = http.Post(url, param) if ret['ErrStat'] == 0: # 清空列表 for i in range(0, 10): qlistwidget.setItem(i, 0, None) qlistwidget.setItem(i, 1, None) # 添加列表 for i in range(0, len(ret['Lists'])): newItem = QTableWidgetItem(ret['Lists'][i]) newItem.setTextAlignment(Qt.AlignCenter) qlistwidget.setItem(i, 0, newItem) newItemChkbox = QTableWidgetItem() newItemChkbox.setCheckState(False) newItemChkbox.setTextAlignment(Qt.AlignCenter) qlistwidget.setItem(i, 1, newItemChkbox) tot = ret['Totle'] # 设置当前页码 self.urlpage.urlpage_white_nowpage_lab.setText(u"%d" % ((start / 10) + 1)) config.GLB_CFG['URL']['White_NowPage'] = (start / 10) + 1 # 设置总页数 totpage = tot / length if (tot % length) > 0: totpage += 1 self.urlpage.urlpage_white_totpage_lab.setText(u"共 %d 页" % (totpage)) config.GLB_CFG['URL']['White_TotPage'] = totpage else: QMessageBox.about(self, u"获取URL列表", u"错误:" + ret['ErrMsg'])
def LogPageUrl_SetList(self): MaxLines = 10 StartTime = self.log_page.log_url_start_timeedit.dateTime().toString( 'yyyy-MM-dd hh:mm:ss') StopTime = self.log_page.log_url_stop_timeedit.dateTime().toString( 'yyyy-MM-dd hh:mm:ss') KeyWord = self.log_page.log_url_query_edit.text().toUtf8() url = "%s/log/url/query" % (config.GLB_CFG['SRV_URL']) param = { 'Start': (self.log_page.log_url_now_page - 1) * MaxLines, 'Length': MaxLines, 'StartTime': StartTime, 'StopTime': StopTime, 'KeyWord': KeyWord, } ret = http.Post(url, param) if ret['ErrStat'] == 0: # 清空列表 for i in range(0, 10): for j in range(0, 8): self.log_page.url_log_tableWidget.setItem(i, j, None) # 添加列表 for i in range(0, len(ret['Lists'])): newItem = QTableWidgetItem(ret['Lists'][i]['Type']) newItem.setTextAlignment(Qt.AlignCenter) self.log_page.url_log_tableWidget.setItem(i, 0, newItem) newItem = QTableWidgetItem(ret['Lists'][i]['Pid']) newItem.setTextAlignment(Qt.AlignCenter) self.log_page.url_log_tableWidget.setItem(i, 1, newItem) newItem = QTableWidgetItem(ret['Lists'][i]['User']) newItem.setTextAlignment(Qt.AlignCenter) self.log_page.url_log_tableWidget.setItem(i, 2, newItem) newItem = QTableWidgetItem(ret['Lists'][i]['Subproc']) newItem.setTextAlignment(Qt.AlignLeft) self.log_page.url_log_tableWidget.setItem(i, 3, newItem) newItem = QTableWidgetItem(ret['Lists'][i]['Sipdip']) newItem.setTextAlignment(Qt.AlignLeft) self.log_page.url_log_tableWidget.setItem(i, 4, newItem) newItem = QTableWidgetItem(ret['Lists'][i]['Host'] + ret['Lists'][i]['Uri']) newItem.setTextAlignment(Qt.AlignLeft) self.log_page.url_log_tableWidget.setItem(i, 5, newItem) newItem = QTableWidgetItem(ret['Lists'][i]['Perm']) newItem.setTextAlignment(Qt.AlignCenter) self.log_page.url_log_tableWidget.setItem(i, 6, newItem) newItem = QTableWidgetItem(ret['Lists'][i]['Time']) newItem.setTextAlignment(Qt.AlignCenter) self.log_page.url_log_tableWidget.setItem(i, 7, newItem) tot = ret['Totle'] # 设置当前页码 self.log_page.log_url_now_label.setText( u"%d" % (self.log_page.log_url_now_page)) # 设置总页数 totpage = tot / MaxLines if (tot % MaxLines) > 0: totpage += 1 self.log_page.log_url_tot_page = totpage self.log_page.log_url_tot_label.setText(u"共 %d 页" % (totpage)) else: QMessageBox.about(self, u"获取URL日志", u"错误:" + ret['ErrMsg'])