def load_wallet(self, wallet): self.wallet = wallet if self.trezor_is_connected(): if not self.wallet.check_proper_device(): QMessageBox.information(self.window, _('Error'), _("This wallet does not match your Trezor device"), _('OK')) else: QMessageBox.information(self.window, _('Error'), _("Trezor device not detected.\nContinuing in watching-only mode."), _('OK'))
def viewDownloadedContent(self): """ Show the downloaded content dialog GUI for the selected user / subreddit """ if self._rddtDataExtractor.currentlyDownloading: QMessageBox.warning( QMessageBox(), "Data Extractor for reddit", "Cannot view downloads while currently downloading. Please wait." ) return model = self.model() index = self.getCurrentSelectedIndex() if model is not None and index is not None: selected = model.getObjectInLst(index) downloadedContent = selected.redditSubmissions if downloadedContent is not None and len(downloadedContent) > 0: downloadedContentGUI = DownloadedContentGUI( selected, self.model(), confirmDialog, self._gui.saveState) downloadedContentGUI.exec_() else: QMessageBox.information( QMessageBox(), "Data Extractor for reddit", selected.name + " has no downloaded content. Download some by hitting the download button." ) elif index is None: QMessageBox.information( QMessageBox(), "Data Extractor for reddit", "To view a " + self.objectName() + "'s downloaded content, please select a " + self.objectName() + " in the " + self.objectName() + " list.")
def load_wallet(self, wallet, window): self.print_error("load_wallet") self.wallet = wallet self.wallet.plugin = self self.keepkey_button = StatusBarButton( QIcon(":icons/keepkey.png"), _("KeepKey"), partial(self.settings_dialog, window) ) if type(window) is ElectrumWindow: window.statusBar().addPermanentWidget(self.keepkey_button) if self.handler is None: self.handler = KeepKeyQtHandler(window) try: self.get_client().ping("t") except BaseException as e: QMessageBox.information( window, _("Error"), _("KeepKey device not detected.\nContinuing in watching-only mode." + "\n\nReason:\n" + str(e)), _("OK"), ) self.wallet.force_watching_only = True return if self.wallet.addresses() and not self.wallet.check_proper_device(): QMessageBox.information(window, _("Error"), _("This wallet does not match your KeepKey device"), _("OK")) self.wallet.force_watching_only = True
def load_wallet(self, wallet, window): self.print_error("load_wallet") self.wallet = wallet self.window = window self.wallet.plugin = self self.trezor_button = StatusBarButton(QIcon(":icons/trezor.png"), _("Trezor"), self.settings_dialog) self.window.statusBar().addPermanentWidget(self.trezor_button) if self.handler is None: self.handler = TrezorQtHandler(self.window.app) try: self.get_client().ping("t") except BaseException as e: QMessageBox.information( self.window, _("Error"), _("Trezor device not detected.\nContinuing in watching-only mode." + "\n\nReason:\n" + str(e)), _("OK"), ) self.wallet.force_watching_only = True return if self.wallet.addresses() and not self.wallet.check_proper_device(): QMessageBox.information( self.window, _("Error"), _("This wallet does not match your Trezor device"), _("OK") ) self.wallet.force_watching_only = True
def install(self): pref = self.app.preferences.ui ct = pref.configTable curi = int(pref.filtersComboBox_new.currentIndex()) filter = self._filters[self._keys[curi]] config, hash = {}, gen_hash() settings = self.filter_settings(filter.id, hash) for i in range(ct.rowCount()): config[unicode(ct.item(i,0).text())] = unicode(ct.item(i,1).text()) try: filter.install(settings, config) except Exception as e: msg = QMessageBox(pref) msg.setIcon(QMessageBox.Critical) msg.setWindowTitle("Installation Error ...") msg.setText("An Error occured during installation.") msg.setInformativeText("Could install filter '%s'." % filter.name) msg.setStandardButtons(QMessageBox.Ok) msg.setDetailedText(format_exc()) msg.exec_() return QMessageBox.information(pref, "Installling "+filter.name+" ...", "Filter '%s' successful installed." % filter.name) self.add_filter_instance(filter, hash) pref.filtersComboBox_new.currentIndexChanged.emit(curi) pref.filtertabWidget.setCurrentIndex(0)
def showMessageDialog(self, msg_type, msg): print "showMessageDialog" # Warning if msg_type == 'w': print "warning" QMessageBox.warning(self, "Warning", msg, buttons=QMessageBox.Ok, defaultButton=QMessageBox.NoButton) # Information elif msg_type == 'i': print "information" QMessageBox.information(self, "Info", msg, buttons=QMessageBox.Ok, defaultButton=QMessageBox.NoButton) # Critical elif msg_type == 'c': print "critical" QMessageBox.critical(self, "Critical", msg, buttons=QMessageBox.Ok, defaultButton=QMessageBox.NoButton) # Nothing to do, the type is not correct else: pass
def load_wallet(self, wallet, window): self.print_error("load_wallet") self.wallet = wallet self.window = window self.wallet.plugin = self self.keepkey_button = StatusBarButton(QIcon(":icons/keepkey.png"), _("KeepKey"), self.settings_dialog) if type(window) is ElectrumWindow: self.window.statusBar().addPermanentWidget(self.keepkey_button) if self.handler is None: self.handler = KeepKeyQtHandler(self.window) try: self.get_client().ping('t') except BaseException as e: QMessageBox.information( self.window, _('Error'), _("KeepKey device not detected.\nContinuing in watching-only mode." + '\n\nReason:\n' + str(e)), _('OK')) self.wallet.force_watching_only = True return if self.wallet.addresses() and not self.wallet.check_proper_device(): QMessageBox.information( self.window, _('Error'), _("This wallet does not match your KeepKey device"), _('OK')) self.wallet.force_watching_only = True
def removeLst(self): name = self._lstChooser.currentText() if len(name) <= 0: return msgBox = confirmDialog("Are you sure you want to delete the " + self.objectName() + " list: " + name + "?") ret = msgBox.exec_() if ret == QMessageBox.Yes: if len(self._chooserDict) <= 0: QMessageBox.information( QMessageBox(), "Data Extractor for reddit", "There are no more lists left to delete.") return self._lstChooser.removeItem(self._lstChooser.currentIndex()) del self._chooserDict[name] defaultName = self._rddtDataExtractor.defaultSubredditListName # if default is not being removed, just remove and switch to default if name != defaultName: self.removeNonDefaultLst() else: if len(self._chooserDict) > 0: # just choose the first model self.removeDefaultLst() else: self.removeLastLst() self._gui.setUnsavedChanges(True)
def apply(self): #validate newcachedir = unicode(self.generalCacheLocation.text()) newcachedir = newcachedir.strip() if newcachedir.endswith(os.path.sep): newcachedir = newcachedir[:-1] if not os.path.isdir(newcachedir): QMessageBox.information(self, "QOSM Error", "'%s' is not a directory" % newcachedir) return False if (not len(os.listdir(newcachedir)) == 0) and \ ((newcachedir != s._defaultsetting(s.CACHE_DIRECTORY)) and (newcachedir != s.get(s.CACHE_DIRECTORY))): if QMessageBox.Ok != QMessageBox.question(self, "Question", "Use non-emtpy directory for cache?", QMessageBox.Ok | QMessageBox.Cancel): return False if newcachedir == s._defaultsetting(s.CACHE_DIRECTORY): s.reset(s.CACHE_DIRECTORY) self.generalCacheLocation.setText(s.get(s.CACHE_DIRECTORY)) else: s.put(s.CACHE_DIRECTORY, newcachedir) self.generalCacheLocation.setText(newcachedir) if self.generalMaxTiles.value() == s._defaultsetting(s.MAX_TILES): s.reset(s.MAX_TILES) else: s.put(s.MAX_TILES, self.generalMaxTiles.value()) s.put(s.AUTODOWNLOAD, self.autoDownload.isChecked()) self.apply_customtypes() self.calculate_cachesize() return True
def load_wallet(self, wallet): if self.btchip_is_connected(): if not self.wallet.check_proper_device(): QMessageBox.information(self.window, _('Error'), _("This wallet does not match your BTChip device"), _('OK')) self.wallet.force_watching_only = True else: QMessageBox.information(self.window, _('Error'), _("BTChip device not detected.\nContinuing in watching-only mode."), _('OK')) self.wallet.force_watching_only = True
def restore_from_archive(self, parent=None): """Function to restore a DP from archived copy Asks for confirmation along the way if parent is not None (in which case it will be the parent widget for confirmation dialogs) """ from PyQt4.Qt import QMessageBox exists = os.path.exists(self.sourcepath) if parent: msg = """<P>Do you really want to restore <tt>%s</tt> from this entry's copy of <tt>%s</tt>?</P>""" % (self.sourcepath, self.filename) exists = os.path.exists(self.sourcepath) if exists: msg += """<P>Current file exists, and will be overwritten.</P>""" if QMessageBox.warning(parent, "Restoring from archive", msg, QMessageBox.Yes, QMessageBox.No) != QMessageBox.Yes: return False else: if QMessageBox.question(parent, "Restoring from archive", msg, QMessageBox.Yes, QMessageBox.No) != QMessageBox.Yes: return False busy = Purr.BusyIndicator() # remove file if in the way if exists: if os.system("/bin/rm -fr '%s'" % self.sourcepath): busy = None if parent: QMessageBox.warning(parent, "Error removing file", """<P> There was an error removing %s. Archived copy was not restored. The text console may have more information.</P>""" % self.sourcepath, QMessageBox.Ok, 0) return False # unpack archived file if self.fullpath.endswith('.tgz'): parent_dir = os.path.dirname(self.sourcepath.rstrip('/')) os.system("/bin/rm -fr %s" % self.sourcepath) if os.system("tar zxf '%s' -C '%s'" % (self.fullpath, parent_dir)): busy = None if parent: QMessageBox.warning(parent, "Error unpacking file", """<P> There was an error unpacking the archived version to %s. The text console may have more information.</P>""" % self.sourcepath, QMessageBox.Ok, 0) return False # else simply copy over else: if os.system("/bin/cp -a '%s' '%s'" % (self.fullpath, self.sourcepath)): busy = None if parent: QMessageBox.warning(parent, "Error copying file", """<P> There was an error copying the archived version to %s. The text console may have more information.</P>""" % self.sourcepath, QMessageBox.Ok, 0) return False busy = None if parent: QMessageBox.information(parent, "Restored file", """<P>Restored %s from this entry's archived copy.</P>""" % self.sourcepath, QMessageBox.Ok, 0) return True
def installwizard_restore(self, wizard, storage): if storage.get('wallet_type') != 'trezor': return wallet = TrezorWallet(storage) try: wallet.create_main_account(None) except BaseException as e: QMessageBox.information(None, _('Error'), str(e), _('OK')) return return wallet
def installwizard_restore(self, wizard, storage): if storage.get("wallet_type") != "btchip": return wallet = BTChipWallet(storage) try: wallet.create_main_account(None) except BaseException as e: QMessageBox.information(None, _("Error"), str(e), _("OK")) return return wallet
def installwizard_restore(self, wizard, storage): if storage.get('wallet_type') != 'btchip': return wallet = MUEhipWallet(storage) try: wallet.create_main_account(None) except BaseException as e: QMessageBox.information(None, _('Error'), str(e), _('OK')) return return wallet
def GetIpAndGateway(self): self.listWidget.clear() """Get 2 elem.""" Ip_input = str(self.lineEdit_5.text()) GateWay = str(self.lineEdit_6.text()) Ip_CHECK = Check_ip(Ip_input) GateWay_CHECK = Check_ip(GateWay) #Get two Fundamental parameter. if Ip_CHECK and GateWay_CHECK : IP = Ip_input Gate_ = GateWay #Substitute with a process_bar. QMessageBox.information(None,"0xcc_"," Scan Started! Please Wait...",QMessageBox.__str__('^_^')) #Substitute with a process_bar. def ProcessA(dest_ip,src_ip=IP,Gate=Gate_): res = arp_backend.arp_resolve(dest_ip, src_ip) #Host Online. if res: mac = arp_backend.mac_straddr(res, 1, ":") try : hostname = arp_backend.socket.gethostbyaddr(dest_ip) hostname=hostname[0] except: if dest_ip == Gate_: hostname = "NetWork Router" else: hostname = "Android platform Or Family Router." if mutex.acquire(): self.listWidget.addItem("Hostname:") self.listWidget.addItem(hostname) self.listWidget.addItem("IP:"+" "+dest_ip+"-- MAC:"+mac) mutex.release() #QMessageBox.information(None,"0xcc_"," Launch Scan!",QMessageBox.__str__("_")) threadpool = [] num = 0 wait =0 Scan_List = arp_backend.ip_process(str(IP)) #20 Threads. for x in Scan_List: t = threading.Thread(target=ProcessA,args=(str(x),)) threadpool.append(t) for th in threadpool: if wait > 8: time.sleep(1) wait = 0 th.start() wait +=1
def _onConflictSaveAsButton(self): filePath = QFileDialog.getSaveFileName(self.conflictDialog, QApplication.translate('VectorLayerSaveConflictController', 'Save File'), "", QApplication.translate('VectorLayerSaveConflictController', 'Files (*.csv *.tsv *.*)')); if filePath: self.conflictDialog.accept() try: self.csvDataSourceHandler.moveDataSourcesToPath(filePath) self.csvDataSourceHandler.syncFeaturesWithCsv(self.csvVectorLayer().vectorLayerDescriptor, self.features, filePath) self.csvVectorLayer().updateGeoCsvPath(filePath) NotificationHandler.pushSuccess(QApplication.translate('VectorLayerSaveConflictController', 'CSV File updated'), QApplication.translate('VectorLayerSaveConflictController', 'Changes to layer "{}" successfully stored in csv file.').format(self.csvVectorLayer().qgsVectorLayer.name())) except: QMessageBox.information(None, QApplication.translate('VectorLayerSaveConflictController', 'Invalid path'), QApplication.translate('VectorLayerSaveConflictController', 'An error occured while trying to save file on new location. Please try again.'))
def on_tiletypesList_itemChanged(self, item): row = self.tiletypesList.row(item) oldtext = self.customtypes[row][2] newtext = unicode(item.text()) newtext = newtext.strip() if oldtext != newtext: if len(newtext) == 0: item.setText(oldtext) QMessageBox.information(self, "QOSM Error", "Invalid name") return self.customtypes[row][2] = newtext
def on_tiletypeChange_released(self): urlpattern = unicode(self.tiletypesPattern.text()) urlpattern = urlpattern.strip() if self.valid_urlpattern(urlpattern): row = [mi.row() for mi in self.tiletypesList.selectedIndexes()][0] self.customtypes[row][1] = urlpattern self.tiletypesPattern.clearFocus() self.tiletypeChange.setEnabled(False) else: QMessageBox.information(self, "QOSM Error", "Invalid URL pattern (must contain ${x}, ${y} and ${z} or ${quadkey}")
def deleteAttributes(self, attributeIds, vectorLayerDescriptor): try: for attributeId in attributeIds: vectorLayerDescriptor.deleteAttributeAtIndex(attributeId) except: QMessageBox.information(None, QApplication.translate('VectorLayerSaveConflictController', 'Error while updating attributes happend'), QApplication.translate('VectorLayerSaveConflictController', 'An error occured while trying to update the attributes list. Nothing has been stored on disk.')) else: try: self.csvDataSourceHandler.updateCsvtFile(vectorLayerDescriptor.getAttributeTypes()) NotificationHandler.pushInfo(QApplication.translate('GeoCsvNewController', 'CSVT File created/updated.'), QApplication.translate('GeoCsvNewController', 'The CSVT file was successfully created/updated on disk.')) except: QMessageBox.information(None, QApplication.translate('VectorLayerSaveConflictController', 'CSVT file could not be updated'), QApplication.translate('VectorLayerSaveConflictController', 'An error occured while trying to update the CSVT file according to the new attribute types. Please update the csvt file manually.'))
def load_wallet(self, wallet, window): self.wallet = wallet self.wallet.plugin = self if self.handler is None: self.handler = BTChipQTHandler(window) if self.btchip_is_connected(): if not self.wallet.check_proper_device(): QMessageBox.information(window, _('Error'), _("This wallet does not match your Ledger device"), _('OK')) self.wallet.force_watching_only = True else: QMessageBox.information(window, _('Error'), _("Ledger device not detected.\nContinuing in watching-only mode."), _('OK')) self.wallet.force_watching_only = True
def deleteServer(self): """Delete a server. """ if len(self.servers) == 1: msg = "At least 1 server must exist. After deleting the last one, "\ "a default new server will be created." QMessageBox.information(self, "Deleting a server", msg, QMessageBox.Ok) item = self.server_listview.currentIndex() self.server_listview.takeItem(item) del self.servers[self.items.index(item)] self.items.remove(item) print "After deleting." return
def _deleteContent(self, downloadedContentType): """ Delete the selected content :type downloadedContentType: RedditDataExtractor.downloader.DownloadedContentType """ currentLstModelObj = self._getCurrentLstModelObj() currentTab = self.tabWidget.currentWidget() currentTabLst = currentTab.findChild(QListWidget) currentTabLstItem = currentTabLst.currentItem() submissionURL = currentTabLstItem.text() downloadedContentForSubmission = currentLstModelObj.redditSubmissions.get( submissionURL) for content in downloadedContentForSubmission: if content.type == downloadedContentType: files = content.files numFiles = len(files) if numFiles <= 20: # avoid making a super long list that is hard to read fileStr = "".join([str(file) + "\n" for file in files]) else: fileStr = "".join( [str(file) + "\n" for file in files[:20]]) fileStr += "\n...\nand " + str(numFiles - 20) + " others. " msgBox = self._confirmDialog( "This will delete these files: \n" + fileStr + "Are you sure you want to delete them?") ret = msgBox.exec_() if ret == QMessageBox.Yes: downloadedContentForSubmission.remove(content) if (len(downloadedContentForSubmission) <= 0): del currentLstModelObj.redditSubmissions[submissionURL] else: currentLstModelObj.redditSubmissions[ submissionURL] = downloadedContentForSubmission if downloadedContentType is not DownloadedContentType.JSON_DATA: for externalURL in content.externalDownloadURLs: if externalURL in currentLstModelObj.externalDownloads: currentLstModelObj.externalDownloads.remove( externalURL) item = currentTabLst.takeItem(currentTabLst.currentRow()) del item # PyQt documentation says the item won't be garbage collected automatically after using takeItem() content.deleteFiles() del content QMessageBox.information( QMessageBox(), "Data Extractor for reddit", "Successfully removed requested files.") self._saveState() return True return False return False
def deleteServer(self): """Delete a server. """ if len(self.servers) == 1: msg = "At least 1 server must exist. After deleting the last one, "\ "a default new server will be created." QMessageBox.information(self, "Deleting a server", msg, QMessageBox.Ok ) item = self.server_listview.currentIndex() self.server_listview.takeItem(item) del self.servers[self.items.index(item)] self.items.remove(item) print "After deleting." return
def load_wallet(self, wallet, window): self.print_error("load_wallet") self.wallet = wallet self.window = window self.wallet.plugin = self if self.handler is None: self.handler = TrezorQtHandler(self.window.app) if self.trezor_is_connected(): if self.wallet.addresses() and not self.wallet.check_proper_device(): QMessageBox.information(self.window, _('Error'), _("This wallet does not match your Trezor device"), _('OK')) self.wallet.force_watching_only = True else: QMessageBox.information(self.window, _('Error'), _("Trezor device not detected.\nContinuing in watching-only mode."), _('OK')) self.wallet.force_watching_only = True
def _initContentLsts(self): downloadedContent = self._startingLstModelObj.redditSubmissions if downloadedContent is not None and len(downloadedContent) > 0: for submissionURL in downloadedContent: for submission in downloadedContent.get(submissionURL): if submission.type is DownloadedContentType.JSON_DATA: self._addToTab(submission, submissionURL, self.submissionJSONLst) elif submission.type is DownloadedContentType.EXTERNAL_SUBMISSION_DATA: self._addToTab(submission, submissionURL, self.submissionExternalLst) elif submission.type is DownloadedContentType.EXTERNAL_COMMENT_DATA: self._addToTab(submission, submissionURL, self.commentLst) elif submission.type is DownloadedContentType.EXTERNAL_SELFTEXT_DATA: self._addToTab(submission, submissionURL, self.selftextLst) else: QMessageBox.information(QMessageBox(), "Data Extractor for reddit", self._startingLstModelObj.name + " has no downloaded submissions. Download some by hitting the download button.")
def makeNewList(self): listName, okay = QInputDialog.getText(QInputDialog(), self.objectName().capitalize() + " List Name", "New " + self.objectName().capitalize() + " List Name:", QLineEdit.Normal, "New " + self.objectName().capitalize() + " List") if okay and len(listName) > 0: if any([listName in lst for lst in self._rddtDataExtractor.subredditLists]): QMessageBox.information(QMessageBox(), "Data Extractor for reddit", "Duplicate subreddit list names not allowed.") return self._lstChooser.addItem(listName) self._lstChooser.setCurrentIndex(self._lstChooser.count() - 1) self._chooserDict[listName] = ListModel([], self._classToUse) self.chooseNewList(self._lstChooser.count() - 1) if self._rddtDataExtractor.defaultSubredditListName is None: # becomes None if user deletes all subreddit lists self._rddtDataExtractor.defaultSubredditListName = listName self._gui.setUnsavedChanges(True)
def apply(self): self.name = self.Param1.nameEdit.text() self.host = self.Param1.HostEdit.text() self.portValue = self.Param1.portSpinbox.value() self.keepValue = self.Param1.keepaliveSpinbox.value() self.client = self.Param1.ClientEdit.text() self.user = self.Param1.tab.gen.UserEdit.text() self.password = self.Param1.tab.gen.PassWordEdit.text() self.visionValue = self.Param1.tab.gen.visionComboBox.currentText() self.cleanssionValue = self.Param1.tab.gen.CleanSessionComboBox.currentText( ) self.napsBooL = self.Param1.tab.gen.groupBox.isChecked( ) #namepassword 框是否勾选 self.pascheck = self.Param1.tab.gen.checkBox1.checkState() self.file = self.Param1.tab.tls.openFileNameLabel.text() print self.file # print self.pascheck # print self.napsBooL if self.cleanssionValue == 'True': self.cleanssion = True # print self.cleanssion else: self.cleanssion = False # print self.cleanssion count = len(childlist) for x in range(count): if rot == x: childlist[rot].setText(0, self.tr(self.name)) # print self.idname c = self.conn.cursor() c.execute( '''UPDATE MQ SET CONNAME = '%s' ,HOSTNAME = '%s', PORT = %d, KEEPLIVE = %d, CLIENTID = '%s', USERNAME = '******', PASSWORD = '******', CLEANSSID = '%s', MQVISION = '%s', NAPSBOOL = %d\ where CONNAME = '%s' ''' % (self.name, self.host, self.portValue, self.keepValue, self.client, self.user, self.password, self.cleanssionValue, self.visionValue, self.napsBooL, self.idname)) c.execute('''UPDATE MQ1 SET CONNAME = '%s' ,PASCHECK = %d, FILE = '%s'\ where CONNAME = '%s' ''' % (self.name, self.pascheck, self.file, self.idname)) self.conn.commit() QMessageBox.information(self, self.tr("提示"), self.tr("保存成功"))
def _deleteContent(self, downloadedContentType): """ Delete the selected content :type downloadedContentType: RedditDataExtractor.downloader.DownloadedContentType """ currentLstModelObj = self._getCurrentLstModelObj() currentTab = self.tabWidget.currentWidget() currentTabLst = currentTab.findChild(QListWidget) currentTabLstItem = currentTabLst.currentItem() submissionURL = currentTabLstItem.text() downloadedContentForSubmission = currentLstModelObj.redditSubmissions.get(submissionURL) for content in downloadedContentForSubmission: if content.type == downloadedContentType: files = content.files numFiles = len(files) if numFiles <= 20: # avoid making a super long list that is hard to read fileStr = "".join([str(file) + "\n" for file in files]) else: fileStr = "".join([str(file) + "\n" for file in files[:20]]) fileStr += "\n...\nand " + str(numFiles - 20) + " others. " msgBox = self._confirmDialog( "This will delete these files: \n" + fileStr + "Are you sure you want to delete them?") ret = msgBox.exec_() if ret == QMessageBox.Yes: downloadedContentForSubmission.remove(content) if (len(downloadedContentForSubmission) <= 0): del currentLstModelObj.redditSubmissions[submissionURL] else: currentLstModelObj.redditSubmissions[submissionURL] = downloadedContentForSubmission if downloadedContentType is not DownloadedContentType.JSON_DATA: for externalURL in content.externalDownloadURLs: if externalURL in currentLstModelObj.externalDownloads: currentLstModelObj.externalDownloads.remove(externalURL) item = currentTabLst.takeItem(currentTabLst.currentRow()) del item # PyQt documentation says the item won't be garbage collected automatically after using takeItem() content.deleteFiles() del content QMessageBox.information(QMessageBox(), "Data Extractor for reddit", "Successfully removed requested files.") self._saveState() return True return False return False
def load_wallet(self, wallet, window): self.print_error("load_wallet") self.wallet = wallet self.window = window self.wallet.plugin = self if self.handler is None: self.handler = TrezorQtHandler(self.window.app) try: self.get_client().ping('t') except BaseException as e: QMessageBox.information(self.window, _('Error'), _("Trezor device not detected.\nContinuing in watching-only mode." + '\n\nReason:\n' + str(e)), _('OK')) self.wallet.force_watching_only = True return if self.wallet.addresses() and not self.wallet.check_proper_device(): QMessageBox.information(self.window, _('Error'), _("This wallet does not match your Trezor device"), _('OK')) self.wallet.force_watching_only = True
def MakeGcode(self): path = QFileDialog.getSaveFileName(self, u"选择保存路径", "", " (*.nc)") if path == "": QMessageBox.warning(self, u"发生错误", u"路径错误!!") return f = open(path, 'w') f.write("M5\n") for i in range(self.resultImage.width()): flag = False #检测这一行是否有点 for j in range(self.resultImage.height()): if self.resultImage.pixelIndex(i, j) < 128: flag = True break #如果这一行都没有点则跳过这一行 if flag: f.write("G0 Y%f\n" % (i * self.pixDoubleSpinBox.value())) else: continue if (i % 2) > 0: for j in range(self.resultImage.height()): if self.resultImage.pixelIndex(i, j) < 128: f.write("G0 X%f\n" % (j * self.pixDoubleSpinBox.value())) f.write("M3\n") f.write("G4 P%f\n" % self.timeDoubleSpinBox.value()) f.write("M5\n") else: for j in range(self.resultImage.height())[::-1]: if self.resultImage.pixelIndex(i, j) < 128: f.write("G0 X%f\n" % (j * self.pixDoubleSpinBox.value())) f.write("M3\n") f.write("G4 P%f\n" % self.timeDoubleSpinBox.value()) f.write("M5\n") f.write("M5\n") f.write("G0 X0 Y0\n") f.close() QMessageBox.information(self, u"成功", u"生成G代码文件成功!!")
def load_wallet(self, wallet, window): self.wallet = wallet self.window = window self.wallet.plugin = self if self.handler is None: self.handler = TrezorQtHandler(self.window.app) if self.trezor_is_connected(): if not wallet.is_supported_coin(): QMessageBox.information( self.window, _('Error'), _("Wallet firmware does not support the active currency.\nContinuing in watching-only mode." ), _('OK')) self.wallet.force_watching_only = True if self.wallet.addresses( ) and not self.wallet.check_proper_device(): QMessageBox.information( self.window, _('Error'), _("This wallet does not match your Trezor device"), _('OK')) self.wallet.force_watching_only = True else: QMessageBox.information( self.window, _('Error'), _("Trezor device not detected.\nContinuing in watching-only mode." ), _('OK')) self.wallet.force_watching_only = True
def msg_pushButton_4(self ): Ip_input = str(self.lineEdit_4.text()) R = Check_ip(Ip_input) Src_ip = str(self.lineEdit_5.text()) GateWay = str(self.lineEdit_6.text()) if R: QMessageBox.information(None,"0xcc_"," Start Attacking..!",QMessageBox.__str__("_")) dest_IP = Ip_input dest_mac = "a" res = arp_backend.arp_resolve(dest_IP,Src_ip) if res: dest_mac = arp_backend.mac_straddr(res, 1, ":") else : QMessageBox.information(None,"0xcc_"," IP NOT FOUND!",QMessageBox.__str__("...")) Attack_thread1 = threading.Thread(target=arp_backend.StartAttack,args=(dest_IP,dest_mac,GateWay)) Attack_thread2 = threading.Thread(target=arp_backend.StartAttack,args=(dest_IP,dest_mac,GateWay)) """Start Attaka.""" Attack_thread1.start() Attack_thread2.start() if arp_backend.M == False: QMessageBox.information(None,"0xcc_","Attaka Failed.Please install winpcap(in the package) and Run me with Administrator!",QMessageBox.__str__("..."))
def viewDownloadedContent(self): """ Show the downloaded content dialog GUI for the selected user / subreddit """ if self._rddtDataExtractor.currentlyDownloading: QMessageBox.warning(QMessageBox(), "Data Extractor for reddit", "Cannot view downloads while currently downloading. Please wait.") return model = self.model() index = self.getCurrentSelectedIndex() if model is not None and index is not None: selected = model.getObjectInLst(index) downloadedContent = selected.redditSubmissions if downloadedContent is not None and len(downloadedContent) > 0: downloadedContentGUI = DownloadedContentGUI(selected, self.model(), confirmDialog, self._gui.saveState) downloadedContentGUI.exec_() else: QMessageBox.information(QMessageBox(), "Data Extractor for reddit", selected.name + " has no downloaded content. Download some by hitting the download button.") elif index is None: QMessageBox.information(QMessageBox(), "Data Extractor for reddit", "To view a " + self.objectName() + "'s downloaded content, please select a " + self.objectName() + " in the " + self.objectName() + " list.")
def _initContentLsts(self): downloadedContent = self._startingLstModelObj.redditSubmissions if downloadedContent is not None and len(downloadedContent) > 0: for submissionURL in downloadedContent: for submission in downloadedContent.get(submissionURL): if submission.type is DownloadedContentType.JSON_DATA: self._addToTab(submission, submissionURL, self.submissionJSONLst) elif submission.type is DownloadedContentType.EXTERNAL_SUBMISSION_DATA: self._addToTab(submission, submissionURL, self.submissionExternalLst) elif submission.type is DownloadedContentType.EXTERNAL_COMMENT_DATA: self._addToTab(submission, submissionURL, self.commentLst) elif submission.type is DownloadedContentType.EXTERNAL_SELFTEXT_DATA: self._addToTab(submission, submissionURL, self.selftextLst) else: QMessageBox.information( QMessageBox(), "Data Extractor for reddit", self._startingLstModelObj.name + " has no downloaded submissions. Download some by hitting the download button." )
def load_wallet(self, wallet, window): self.print_error("load_wallet") self.wallet = wallet self.window = window self.wallet.plugin = self if self.handler is None: self.handler = TrezorQtHandler(self.window.app) try: self.get_client().ping('t') except BaseException as e: QMessageBox.information( self.window, _('Error'), _("Trezor device not detected.\nContinuing in watching-only mode." + '\n\nReason:\n' + str(e)), _('OK')) self.wallet.force_watching_only = True return if self.wallet.addresses() and not self.wallet.check_proper_device(): QMessageBox.information( self.window, _('Error'), _("This wallet does not match your Trezor device"), _('OK')) self.wallet.force_watching_only = True
def removeLst(self): name = self._lstChooser.currentText() if len(name) <= 0: return msgBox = confirmDialog("Are you sure you want to delete the " + self.objectName() + " list: " + name + "?") ret = msgBox.exec_() if ret == QMessageBox.Yes: if len(self._chooserDict) <= 0: QMessageBox.information(QMessageBox(), "Data Extractor for reddit", "There are no more lists left to delete.") return self._lstChooser.removeItem(self._lstChooser.currentIndex()) del self._chooserDict[name] defaultName = self._rddtDataExtractor.defaultSubredditListName # if default is not being removed, just remove and switch to default if name != defaultName: self.removeNonDefaultLst() else: if len(self._chooserDict) > 0: # just choose the first model self.removeDefaultLst() else: self.removeLastLst() self._gui.setUnsavedChanges(True)
def load_wallet(self, wallet): if self.trezor_is_connected(): if not wallet.is_supported_coin(): QMessageBox.information(self.window, _('Error'), _("Wallet firmware does not support the active currency.\nContinuing in watching-only mode."), _('OK')) self.wallet.force_watching_only = True if not self.wallet.check_proper_device(): QMessageBox.information(self.window, _('Error'), _("This wallet does not match your Trezor device"), _('OK')) self.wallet.force_watching_only = True else: QMessageBox.information(self.window, _('Error'), _("Trezor device not detected.\nContinuing in watching-only mode."), _('OK')) self.wallet.force_watching_only = True
def startqueue(self): data = self.calibeditor.model.getjson() try: title = str(data['Title']) except Exception as e: return self.calibeditor.model.save() argu = ["new", data] result = {} title = str(data['Title']) usrfolder = str(data['Directory'][0]) titlestr = 'The title and the selected user folder do NOT match. Are you sure you are user: '******' ?' if title.find(usrfolder) == -1: res = QMessageBox.warning(self, self.tr("User folder"), self.tr(titlestr), QMessageBox.Yes | QMessageBox.No, QMessageBox.No) else: res = QMessageBox.Yes if res == QMessageBox.Yes: try: result = json.loads( Leash.initcommand(self.options, argu, self.netconf)) except Exception as e: self.errormessage.setWindowTitle("Server Error") self.errormessage.setMinimumSize(400, 300) self.errormessage.showMessage(str(e)) if 'result' in result and result['result'] == "new queue": self.setqueuesynced() self.plotthread.start() self.consolidatepanel.submitbutton.setEnabled(True) folderpath = "/" for text in data['Directory']: folderpath += text + "/" titlestr = 'Successfully loaded new calibration to Server!\n\nDo you want to re-integrate all images in ' + folderpath + ' ?' res = QMessageBox.information(self, self.tr("Re-integrate?"), self.tr(titlestr), QMessageBox.Yes | QMessageBox.No, QMessageBox.No) if res == QMessageBox.Yes: self.menue.queueRedoAllImmages() else: self.errormessage.setWindowTitle("Server Error") self.errormessage.setMinimumSize(400, 300) self.errormessage.showMessage(result["data"]["Error"])
def on_generalClearCache_released(self): QMessageBox.information(self, "fish", "fish") if self.generalCacheLocation.text() == s.get(s.CACHE_DIRECTORY): if QMessageBox.Ok == QMessageBox.question(self, "Question", "Clear entire cache directory? This cannot be undone.", QMessageBox.Ok | QMessageBox.Cancel): try: shutil.rmtree(s.get(s.CACHE_DIRECTORY)) os.mkdir(s.get(s.CACHE_DIRECTORY)) self.calculate_cachesize() except Exception as e: log("Error clearing cache directory: %s" % e) QMessageBox.information(self, "Error", "Error cleaning directory: %s" % e) else: QMessageBox.information(self, "Error", "Apply changes to cache directory before clearing.")
def startqueue(self): data=self.calibeditor.model.getjson() try : title = str(data['Title']) except Exception as e: return self.calibeditor.model.save() argu=["new", data] result={} title = str(data['Title']) usrfolder = str(data['Directory'][0]) titlestr='The title and the selected user folder do NOT match. Are you sure you are user: '******' ?' if title.find(usrfolder)==-1: res=QMessageBox.warning(self, self.tr("User folder"),self.tr(titlestr), QMessageBox.Yes | QMessageBox.No, QMessageBox.No) else: res = QMessageBox.Yes if res==QMessageBox.Yes: try: result=json.loads(Leash.initcommand(self.options,argu,self.netconf)) except Exception as e: self.errormessage.setWindowTitle("Server Error") self.errormessage.setMinimumSize(400, 300) self.errormessage.showMessage(str(e)) if 'result' in result and result['result']=="new queue": self.setqueuesynced() self.plotthread.start() self.consolidatepanel.submitbutton.setEnabled(True) folderpath = "/" for text in data['Directory']: folderpath+=text + "/" titlestr='Successfully loaded new calibration to Server!\n\nDo you want to re-integrate all images in '+folderpath+' ?' res=QMessageBox.information(self, self.tr("Re-integrate?"),self.tr(titlestr), QMessageBox.Yes | QMessageBox.No, QMessageBox.No) if res==QMessageBox.Yes: self.menue.queueRedoAllImmages() else: self.errormessage.setWindowTitle("Server Error") self.errormessage.setMinimumSize(400, 300) self.errormessage.showMessage( result["data"]["Error"])
def load_wallet(self, wallet): if self.trezor_is_connected(): if not wallet.is_supported_coin(): QMessageBox.information( self.window, _('Error'), _("Wallet firmware does not support the active currency.\nContinuing in watching-only mode." ), _('OK')) self.wallet.force_watching_only = True if not self.wallet.check_proper_device(): QMessageBox.information( self.window, _('Error'), _("This wallet does not match your Trezor device"), _('OK')) self.wallet.force_watching_only = True else: QMessageBox.information( self.window, _('Error'), _("Trezor device not detected.\nContinuing in watching-only mode." ), _('OK')) self.wallet.force_watching_only = True
def restore_from_archive(self, parent=None): """Function to restore a DP from archived copy Asks for confirmation along the way if parent is not None (in which case it will be the parent widget for confirmation dialogs) """ from PyQt4.Qt import QMessageBox exists = os.path.exists(self.sourcepath) if parent: msg = """<P>Do you really want to restore <tt>%s</tt> from this entry's copy of <tt>%s</tt>?</P>""" % (self.sourcepath, self.filename) exists = os.path.exists(self.sourcepath) if exists: msg += """<P>Current file exists, and will be overwritten.</P>""" if QMessageBox.warning(parent, "Restoring from archive", msg, QMessageBox.Yes, QMessageBox.No) != QMessageBox.Yes: return False else: if QMessageBox.question(parent, "Restoring from archive", msg, QMessageBox.Yes, QMessageBox.No) != QMessageBox.Yes: return False busy = Purr.BusyIndicator() # remove file if in the way if exists: if os.system("/bin/rm -fr '%s'" % self.sourcepath): busy = None if parent: QMessageBox.warning( parent, "Error removing file", """<P> There was an error removing %s. Archived copy was not restored. The text console may have more information.</P>""" % self.sourcepath, QMessageBox.Ok, 0) return False # unpack archived file if self.fullpath.endswith('.tgz'): parent_dir = os.path.dirname(self.sourcepath.rstrip('/')) os.system("/bin/rm -fr %s" % self.sourcepath) if os.system("tar zxf '%s' -C '%s'" % (self.fullpath, parent_dir)): busy = None if parent: QMessageBox.warning( parent, "Error unpacking file", """<P> There was an error unpacking the archived version to %s. The text console may have more information.</P>""" % self.sourcepath, QMessageBox.Ok, 0) return False # else simply copy over else: if os.system("/bin/cp -a '%s' '%s'" % (self.fullpath, self.sourcepath)): busy = None if parent: QMessageBox.warning( parent, "Error copying file", """<P> There was an error copying the archived version to %s. The text console may have more information.</P>""" % self.sourcepath, QMessageBox.Ok, 0) return False busy = None if parent: QMessageBox.information( parent, "Restored file", """<P>Restored %s from this entry's archived copy.</P>""" % self.sourcepath, QMessageBox.Ok, 0) return True
def startqueue(self): data = self.calibeditor.model.getjson() try: title = str(data['Title']) except Exception as e: return self.calibeditor.model.save() argu = ["new", data] result = {} '''Check if slices are here in GISAXS mode''' if data['GISAXSmode']: if 'Slices' not in data: self.errormessage.setWindowTitle("Calibration Error") self.errormessage.setMinimumSize(400, 300) msg = "You tried to use GISAXSmode but you have no slices defined. Please specify and rerun again!" self.errormessage.showMessage(str(msg)) return elif data['Slices'] == []: self.errormessage.setWindowTitle("Calibration Error") self.errormessage.setMinimumSize(400, 300) msg = "You tried to use GISAXSmode but you have no slices defined. Please Add Item and rerun again!" self.errormessage.showMessage(str(msg)) return '''Check if Title has something in common with the user name''' title = str(data['Title']) usrfolder = str(data['Directory'][0]) titlestr = 'The title and the selected user folder do NOT match. Are you sure you are user: '******' ?' if title.find(usrfolder) == -1: res = QMessageBox.warning(self, self.tr("User folder"), self.tr(titlestr), QMessageBox.Yes | QMessageBox.No, QMessageBox.No) else: res = QMessageBox.Yes if res == QMessageBox.Yes: try: result = json.loads( Leash.initcommand(self.options, argu, self.netconf)) except Exception as e: self.errormessage.setWindowTitle("Server Error") self.errormessage.setMinimumSize(400, 300) self.errormessage.showMessage(str(e)) return if 'result' in result and result['result'] == "new queue": self.setqueuesynced() self.plotthread.start() self.consolidatepanel.submitbutton.setEnabled(True) folderpath = "/" for text in data['Directory']: folderpath += text + "/" titlestr = 'Successfully loaded new calibration to Server!\n\nDo you want to re-integrate all images in ' + folderpath + ' ?' res = QMessageBox.information(self, self.tr("Re-integrate?"), self.tr(titlestr), QMessageBox.Yes | QMessageBox.No, QMessageBox.No) if res == QMessageBox.Yes: self.menue.queueRedoAllImmages() else: self.errormessage.setWindowTitle("Server Error") self.errormessage.setMinimumSize(400, 300) self.errormessage.showMessage(result["data"]["Error"])
def change_CI_alert(self, value=None): if not self.already_showed_change_CI_alert: QMessageBox.information(self, "Changing Confidence Level", meta_globals.get_CHANGE_CI_ALERT_MSG()) self.already_showed_change_CI_alert = True
def checkDeleteAttribute(self, attributeId, vectorLayerDescriptor): isOk = True if vectorLayerDescriptor.indexIsGeoemtryIndex(attributeId): QMessageBox.information(None, QApplication.translate('VectorLayerSaveConflictController', 'Geometry index violation'), QApplication.translate('VectorLayerSaveConflictController', 'You tried to delete an attribute which is providing geometry information. The change will not be saved to disk.')) isOk = False return isOk