def extraction_done(self, outputs):
nb_written_all, wrote_endpoints = 0, False
for folder, output in outputs.items():
nb_written, wrote_endpoints = extractor_save(BASE_PATH, folder, output)
nb_written_all += nb_written
if wrote_endpoints:
self.set_view(self.welcome)
QMessageBox.information(self.view, ' ', '%d endpoints and their <i>.proto</i> structures have been extracted! You can now reuse the <i>.proto</i>s or fuzz the endpoints.' % nb_written_all)
elif nb_written_all:
self.set_view(self.welcome)
QMessageBox.information(self.view, ' ', '%d <i>.proto</i> structures have been extracted! You can now reuse the <i>.protos</i> or define endpoints for them to fuzz.' % nb_written_all)
else:
self.set_view(self.choose_extractor)
QMessageBox.warning(self.view, ' ', 'This extractor did not find Protobuf structures in the corresponding format for specified files.')
python类information()的实例源码
def save(self):
"""
Orders the AppController to save the current trained models.
Parameters
----------
None
Return
----------
None
"""
if self.controller.isTrained():
self.controller.save()
QMessageBox.information(self.train, "Message", "Save succesful.")
else:
QMessageBox.warning(self.train, "Message", "Must have at least 1 trained classifier.")
def trainSystem(self):
"""
Orders the AppController to train a model based on the selected database.
Parameters
----------
None
Return
----------
None
"""
if self.path_train:
trained = self.controller.train(self.path_train, self.comboBoxDatabaseTrain.currentText())
self.path_train = None
if not trained:
QMessageBox.critical(self.train, "Message", "File columns or labels mismatch.")
else:
QMessageBox.information(self.train, "Message", "Training succesful.")
else:
QMessageBox.warning(self.train, "Message", "Must pick a database file.")
def conflict_tags_submit(self):
"""
submit conflict tags
:return:
"""
updata_tag_message_list = self.get_table_data()
again_conflict_data = self.get_conflict_data(updata_tag_message_list)
self.wait_dialog = WaitDialog(self)
self.wait_dialog.setWindowModality(Qt.ApplicationModal)
if again_conflict_data:
message = str(again_conflict_data) + " has existed, whether to continue to submit"
reply = QMessageBox.information(self, "merge conflicts", message, QMessageBox.Yes | QMessageBox.No)
if reply == QMessageBox.Yes:
self.wait_dialog.show()
thread = Thread(target=self.case_data_manager.merge_conflict_data_callback,
args=(updata_tag_message_list, self.callback))
thread.start()
else:
self.wait_dialog.show()
thread = Thread(target=self.case_data_manager.merge_conflict_data_callback,
args=(updata_tag_message_list, self.callback))
thread.start()
def closeEvent(self, close_even):
if self.tag_id_line_edit.text() != '':
if self.tag.name != self.tag_name_line_edit.text() or self.tag.description != self.tag_description_text_edit.toPlainText():
reply = QMessageBox.information(self, 'close window', 'Changes not saved, confirm close?',
QMessageBox.Yes, QMessageBox.No)
if reply != QMessageBox.Yes:
close_even.ignore()
return
else:
if self.tag_id_line_edit.text() != '' or self.tag_description_text_edit.toPlainText() != '':
reply = QMessageBox.information(self, 'close window', 'Changes not saved, confirm close?',
QMessageBox.Yes, QMessageBox.No)
if reply != QMessageBox.Yes:
close_even.ignore()
return
self.refresh_signal.emit()
def tag_save(self):
tag_id = self.tag_id_line_edit.text()
tag_name = self.tag_name_line_edit.text()
tag_description = self.tag_description_text_edit.toPlainText()
if tag_name == '' or tag_description == '':
QMessageBox.warning(self, 'tag editor', 'tag name and description can\'t be empty')
else:
if len(tag_name) > 8:
QMessageBox.warning(self, 'tag editor', 'tag name is not greater than 8 characters')
else:
if tag_id:
self.tag.name = tag_name
self.tag.description = tag_description
self.db_helper.update_tag()
QMessageBox.information(self, 'tag editor', 'tag update success')#todo ??????
else:
tag = self.db_helper.query_tag_by_name(tag_name)
if tag is None:
tag = self.db_helper.insert_tag(tag_name, tag_description)
self.tag_id_line_edit.setText(str(tag.id))
self.tag = tag
QMessageBox.information(self, 'tag editor', 'tag insert success')#todo ??????
else:
QMessageBox.warning(self, 'tag editor', 'tag has existed')
def connectToDatabase(db, user, psswrd, host):
try:
global conn
conn = pymysql.connect(
db=db,
user=user,
passwd=psswrd,
host=host
)
global data
data = getAndSetData(conn)
return conn, data
except pymysql.err.OperationalError:
Q = QMessageBox()
Q = QMessageBox.information(Q, 'Error', 'Your username and/or password was incorrect. Please try again.', QMessageBox.Ok)
return None, None
def acquire_vm_from_vmpool(self, rowid):
"""
Description: A machine will be acquired by a user if they click on the icon of a VmPool
Arguments: The row id that has been clicked. This relationship is stored using the VmData class.
Returns: Nothing
"""
self.lastclick = int(time()) # Last click timestamp update
vmtype = self.vmdata[rowid].vmtype
if vmtype == 'vmpool':
try:
QMessageBox.information(None, _('apptitle') + ': ' + _('info'), _('acquiring_vm_from_pool'))
vmp = conf.OVIRTCONN.vmpools.get(id=self.vmdata[rowid].vmid)
vmp.allocatevm()
self.refresh_grid()
except ConnectionError:
QMessageBox.critical(None, _('apptitle') + ': ' + _('error'), _('unexpected_connection_drop'))
quit()
except RequestError:
QMessageBox.critical(None, _('apptitle') + ': ' + _('error'), _('cannot_attach_vm_to_user'))
else:
QMessageBox.warning(None, _('apptitle') + ': ' + _('warning'), _('object_is_not_a_vmpool'))
def forget_creds(self):
"""
Description: Invoked when the user clicks on the 'Forget credentials' button in the toolbar.
Arguments: None
Returns: Nothing
"""
global conf
self.lastclick = int(time()) # Last click timestamp update
reply = QMessageBox.question(None, _('apptitle') + ': ' + _('confirm'), _('confirm_forget_creds'), QMessageBox.Yes | QMessageBox.No, QMessageBox.No)
if reply == QMessageBox.Yes:
remove(conf.USERCREDSFILE)
self.forgetCredsAction.setDisabled(True)
QMessageBox.information(None, _('apptitle') + ': ' + _('success'), _('creds_forgotten'))
def upgrade(self):
response = QMessageBox.question(
self.anki.window(),
'AnkiConnect',
'Upgrade to the latest version?',
QMessageBox.Yes | QMessageBox.No
)
if response == QMessageBox.Yes:
data = download(URL_UPGRADE)
if data is None:
QMessageBox.critical(self.anki.window(), 'AnkiConnect', 'Failed to download latest version.')
else:
path = os.path.splitext(__file__)[0] + '.py'
with open(path, 'w') as fp:
fp.write(makeStr(data))
QMessageBox.information(self.anki.window(), 'AnkiConnect', 'Upgraded to the latest version, please restart Anki.')
return True
return False
def calculateDalpha(self):
try:
a_par = self.ui.alpha_par.text();
a_perp = self.ui.alpha_perp.text();
if (a_par == ""):
a_par = "0";
if (a_perp == ""):
a_perp = "0";
self.ui.deltaAlpha.setText(str(round(float(a_par)-float(a_perp),5)));
except ValueError:
self.ui.deltaAlpha.setText("");
# try:
# result = QMessageBox.information(QWidget(),'Information','Some informative text');
# print(result);
# result = QMessageBox.warning(QWidget(),'Warn','WARNONNN!');
# result = QMessageBox.warning(QWidget(),'Warn','WARNONNN!');
# print(result);
# self.enable_save_option();
# finally:
# self.enable_Go_button();
#
def calculate(self):
inputs = self.validate_input();
if (inputs is not False):
Jmax,Kmax,Mmax = inputs;
self.setEnabled(False);
self.update();
QMessageBox.information(self,'Responsiveness','This user interface will be irresponsive while the calculation is carried out.\n\nSorry about that!');
try:
U2dcalc.set_num_threads(multiprocessing.cpu_count());
U2dcalc.precalculate_matrix_elements(Jmax,Kmax,Mmax);
self.update_available();
QMessageBox.information(self,'Success!','Calculation done.');
self.close();
except BaseException as e:
QMessageBox.critical(self,'Failed to calculate matrix elements',str(e));
self.setEnabled(True);
else:
QMessageBox.critical(self,'Validation error',"Invalid input");
def slot_new(self):
"""
???? ?? ? ??
:return:
"""
if not self.is_saved:
reply = QMessageBox.information(
self, self.tr("Save"), self.tr("??? ??? ?????????"),
QMessageBox.Save | QMessageBox.No | QMessageBox.Cancel, QMessageBox.Save)
if reply == QMessageBox.Save:
if not self.slot_save():
return # ?? ??
elif reply == QMessageBox.No:
pass
else:
return # ?? ??
self.init_setting()
def saveDesign_inputs(self):
fileName,_ = QFileDialog.getSaveFileName(self,"Save Design", os.path.join(str(self.folder), "untitled.osi"),"Input Files(*.osi)")
if not fileName:
return
try:
out_file = open(str(fileName), 'wb')
except IOError:
QMessageBox.information(self, "Unable to open file",
"There was an error opening \"%s\"" % fileName)
return
# yaml.dump(self.uiObj,out_file,allow_unicode=True, default_flow_style=False)
json.dump(self.uiobj, out_file)
out_file.close()
def displaylog_totextedit(self, commLogicObj):
'''
This method displaying Design messages(log messages)to textedit widget.
'''
fname = str(commLogicObj.call_saveMessages())
afile = QFile(fname)
if not afile.open(QIODevice.ReadOnly): # ReadOnly
QMessageBox.information(None, 'info', afile.errorString())
stream = QTextStream(afile)
self.ui.textEdit.clear()
self.ui.textEdit.setHtml(stream.readAll())
vscroll_bar = self.ui.textEdit.verticalScrollBar()
vscroll_bar.setValue(vscroll_bar.maximum())
afile.close()
def login_click(self):
string = ''
ID = self.inputID.text()
passwd = self.inputPW.text()
result = mysign.login(ID, passwd, s, key)
if result == 1:
QMessageBox.warning(self, '???', '??? ?? ????? ?? ????.')
elif result == 3:
QMessageBox.warning(self, '???', '??? ?? ????? ???? ????')
else:
QMessageBox.information(self, '???', result + '?, ?????.')
user_info['username'] = result
user_info['account'] = ID
self.tmp = MainForm()
self.hide()
self.tmp.draw()
self.inputID.setText("")
self.inputPW.setText("")
def check_btn_click(self):
ID = self.inputID.text()
if len(ID) < 5 or len(ID) > 20:
QMessageBox.warning(self, '?? ??', '???? 5???? 20?? ??? ?????.')
self.inputID.setText("")
return
elif len(ID) > 5 or len(ID) < 20:
string = mysign.overlap(ID, s, key)
if string == 'success':
QMessageBox.information(self, '?? ??', '?? ??? ??? ???')
self.i = 1
else:
QMessageBox.warning(self, '?? ??', '?? ???? ??? ???.')
self.inputID.setText("")
def with_btn_click(self):
if self.input_PW.text() == '':
QMessageBox.warning(self, '?? ??', '????? ??? ???')
return
answer = QMessageBox.warning(self, '?? ??', '??? ?? ???????\n??? ??? ??? ??????.', QMessageBox.Ok|QMessageBox.No)
if (answer == QMessageBox.No):
return
else:
QMessageBox.information(self, '??? ??', '?? ????')
"""
mysocket.sendMsg(s, '2', key)
mysocket.sendMsg(s, self.input_PW.text(), key)
result = mysocket.getMsg(s, key)
if result == 'PW different' or result == 'PW different ':
QMessageBox.warning(self, '?? ??', '?? ?? ??')
return
else:
QMessageBox.information(self, '?? ??', '???? ??????. ??~')
??? ???.
"""
def fuzz_endpoint(self):
QMessageBox.information(self.view, ' ', 'Automatic fuzzing is not implemented yet.')
def validateSystem(self):
"""
Orders the AppController to validate a model based on the selected database.
Parameters
----------
None
Return
----------
None
"""
if self.path_validate:
checked, validated, accuracy, precision, sensitivity, specificity, kappa = self.controller.validate(self.path_validate, self.spinBoxFolds.value(), self.comboBoxDatabaseValidate.currentText())
self.path_validate = None
if not validated:
QMessageBox.warning(self.validate, "Message", "Classifier for "+ self.comboBoxDatabaseValidate.currentText() + " database is not trained.")
self.clearValidateLineEdits()
else:
self.lineEditAccuracy.setText(str(accuracy))
self.lineEditPrecision.setText(str(precision))
self.lineEditSensitivity.setText(str(sensitivity))
self.lineEditSpecificity.setText(str(specificity))
self.lineEditKappa.setText(str(kappa))
QMessageBox.information(self.train, "Message", "Validation finished.")
if not checked:
QMessageBox.critical(self.validate, "Message", "File columns or labels mismatch.")
self.clearValidateLineEdits()
else:
QMessageBox.warning(self.validate, "Message", "Must pick a database file.")
self.clearValidateLineEdits()
def _show_wiring(self):
wiring = "RST\t-> RTS\n" \
"GPIO0\t-> DTR\n" \
"TXD\t-> RXD\n" \
"RXD\t-> TXD\n" \
"VCC\t-> 3V3\n" \
"GND\t-> GND"
QMessageBox.information(self, "Wiring", wiring)
def closeEvent(self, event):
if self.trayIcon.isVisible() and not self.user_closed:
QMessageBox.information(
self, "Bitmask",
"Bitmask will minimize to the system tray. "
"You can choose 'Quit' from the menu with a "
"right click on the icon, and restore the window "
"with a double click.")
self.hide()
if not self.user_closed:
event.ignore()
def onCalculationFinish(self):
self.textEdit.append('????????? ?? ' + self.profiler.stop() + ' ?.')
QApplication.restoreOverrideCursor()
QMessageBox.information(self, "????????", "??????? ????????????? ????????!")
# ????? ??? ??????? ?? ?????? "????????????????"
def onCalculationFinish(self):
self.textEdit.append('????????? ?? ' + self.profiler.stop() + ' ?.')
QApplication.restoreOverrideCursor()
QMessageBox.information(self, "????????", "??????: MI, IG, ??-??????? ????????!")
def onCalculationFinish(self, xs, ys, similarity, short_filenames):
self.textEdit.append('????????? ?? ' + self.profiler.stop() + ' ?.')
self.xs = xs
self.ys = ys
self.similarity = similarity
self.short_filenames = short_filenames
QApplication.restoreOverrideCursor()
self.button2DView.setEnabled(True)
self.buttonRelationTable.setEnabled(True)
self.buttonMakeLSA.setEnabled(True)
QMessageBox.information(self, "????????", "????????-????????????? ?????? ????????!")
def on_calculation_finish(self):
self.textEdit.append('????????? ?? ' + self.profiler.stop() + ' ?.')
QApplication.restoreOverrideCursor()
self.buttonProcess.setEnabled(True)
QMessageBox.information(self, "????????", "?????????????? ????????????? ?????????!")
def onCalculationFinish(self):
# self.groupButtonsBox.setEnabled(True)
self.textEdit.append('????????? ?? ' + self.profiler.stop() + ' ?.')
QApplication.restoreOverrideCursor()
QMessageBox.information(self, "????????", "??????? ????????????? ????????!")
# ????? ??? ??????? ?? ?????? "????????????????"
def onCalculationFinish(self):
self.tabWidget.setEnabled(True)
self.textEdit.append('????????? ?? ' + self.profiler.stop() + ' ?.')
QApplication.restoreOverrideCursor()
self.addfig(plt.gcf())
self.startMethod.setEnabled(True)
self.checkBoxNeedCalculateTFIDF.setEnabled(True)
QMessageBox.information(self, "????????", "????????????? ?????????!")
def set_content_image(self, list_image, des_dir):
self.content_text_browser.clear()
self.content_text_browser.setEnabled(True)
for i in list_image:
full_path = html.escape(des_dir + '/' + PurePath(i).name)
self.content_text_browser.append(
"<img src='{}' title='store at : {}'/><br/>".format(full_path, full_path))
self.__load_finished()
QMessageBox.information(self, 'Download Completed',
'All of your donwload images store at : {}'.format(des_dir))
def handle_error_occurred(self):
QMessageBox.information(self, 'Not Found', 'Title or Lang Not Found')
self.content_text_browser.clear()
self.content_text_browser.setEnabled(False)
self.__load_finished()