def check(self): try: cwd, listing = fetch_listing(self.url) return len(listing) > 0 except Exception as e: show_message_box(self.get_default_error_message()) return False
def update(dialogUi, mainUi): uniques = [] #set original data once in case validation returns an error model.setVolumeScaling(utils.build_list_from_table(dialogUi.tableWidget)) mainUi.lineEdit_volumeScaling.setText(str(dialogUi.tableWidget.rowCount())) for row in range(0,dialogUi.tableWidget.rowCount()): rowOut = int(row) + int(1) if ( dialogUi.tableWidget.item(row,0) == None or not re.match("^\d+$",dialogUi.tableWidget.item(row,0).text()) or dialogUi.tableWidget.item(row,0).text() == '0' ): utils.show_message_box(QtWidgets.QMessageBox.Warning,"Bitte geben Sie eine ganze Zahl (>0) in Zeile "+str(rowOut)+" ein.","Fehler") #@TO-DO: closing and reopening the dialog seems a bit sketchy, better solution needed show(mainUi) return #only one message at a time scaling = int(dialogUi.tableWidget.item(row,0).text()) if scaling not in uniques: uniques.append(scaling) #remove extra lines and adjust texts of remaining lines accordingly while len(uniques) < dialogUi.tableWidget.rowCount(): dialogUi.tableWidget.removeRow(dialogUi.tableWidget.rowCount() - 1) uniques.sort() for row in range(0,len(uniques)): dialogUi.tableWidget.item(row,0).setText(str(uniques[row])) #set final result model.setVolumeScaling(utils.build_list_from_table(dialogUi.tableWidget)) mainUi.lineEdit_volumeScaling.setText(str(dialogUi.tableWidget.rowCount()))
def check(self): # Check that aws cli works if not find_executable("aws") and not shutil.which("aws"): show_message_box( "aws cli was not found. Please make sure you have aws cli installed and configured in the PATH environment variable\nhttps://aws.amazon.com/cli/" ) return False return True
def check(self): try: self.ftp = FTP(self.hostname(), FTP_USER_DEFAULT, FTP_PASS_DEFAULT) if self.ftp.pwd(): return True return False except Exception as e: show_message_box(self.get_default_error_message()) return False
def handle_item_change(tableWidget, commonBools): #only check after data was initialized if commonBools.getInitializing() == True: return for row in range(0, tableWidget.rowCount()): for column in range(2, 4): if not re.match("^\d+$", tableWidget.item(row, column).text()): utils.show_message_box( QtWidgets.QMessageBox.Warning, "Bitte geben Sie eine ganze Zahlen ein.", "Fehler") return
def check(self): # Check that azcopy works if not find_executable("azcopy") and not shutil.which("azcopy"): show_message_box( "azcopy not found. Please make sure you have placed azcopy somewhere in the PATH. https://docs.microsoft.com/en-us/azure/storage/common/storage-use-azcopy-v10" ) return False container = urlparse(self.url.lower()).path if not container or container == "/": show_message_box( "Please provide container name as well. https://BLOBNAME.blob.core.windows.net/CONTAINER" ) return False return True
def get_color_from_image(ui_mm, globalColor): fileDialog = QtWidgets.QFileDialog() path = fileDialog.getOpenFileName(None, "Bild wählen ...", "", "Images (*.png *.bmp *.jpg *.jpeg *.tif *.gif)") if path[0] != '': image = io.imread(path[0])[:, :, :, ] if image.shape[2] == 2: utils.show_message_box(QtWidgets.QMessageBox.Warning,"Das ausgewählte bild ist graustufig. Bitte wählen Sie ein farbiges Bild.","Fehler") return elif image.shape[2] == 3: pass #image already usable elif image.shape[2] == 4: image = io.imread(path[0])[:, :, :-1 ] else: utils.show_message_box(QtWidgets.QMessageBox.Warning,"Fehler beim auslesen der Bilddatei. Bitte wählen sie ein anderes Bild.","Fehler") return average_color_per_row = np.average(image, axis=0) average_color = np.average(average_color_per_row, axis=0) globalColor.setColorValue(utils.convert_rgb_to_hex(int(average_color[0]),int(average_color[1]),int(average_color[2]))) change_button_color(ui_mm, globalColor)
def update(dialog, mainUi): data = utils.build_list_from_table(dialog.ui.tableWidget) for dataset in data: column = 0 for item in dataset: column += 1 #text in first two items (ID, material) are automatically set and do not need to be checked here if column < 3: continue if item.text() == '': utils.show_message_box(QtWidgets.QMessageBox.Warning, "Bitte alle Felder füllen", "Fehler") return elif (item.text() == '0' or not re.match("^\d+$", item.text())): utils.show_message_box(QtWidgets.QMessageBox.Warning, "Bitte geben Sie nur Zahlen (>0) ein", "Fehler") return model.setSfg(data) dialog.set_previous(previousData=create_copy()) dialog.close()
def check_pocket_size(side, a, b, depth, rowOut, mainUi): if (side == "A (oben)" or side == "A' (unten)"): checkSize_a = a checkSize_b = depth checkSize_c = b elif (side == "B (vorne)" or side == "B' (hinten)"): checkSize_a = a checkSize_b = b checkSize_c = depth elif (side == "C (rechts)" or side == "C' (links)"): checkSize_a = depth checkSize_b = b checkSize_c = a if (checkSize_a > int(mainUi.lineEdit_bodySideA.text()) or checkSize_b > int(mainUi.lineEdit_bodySideB.text()) or checkSize_c > int(mainUi.lineEdit_bodySideC.text())): utils.show_message_box( QtWidgets.QMessageBox.Warning, "Dimensionen der Tasche in Zeile " + str(rowOut) + " passen nicht auf den eigegeben Hüllkörper!", "Fehler") #@TO-DO: closing and reopening the dialog seems a bit sketchy, better solution needed show(mainUi)
def on_click_material_save(ui_mm,ui,globalColor): if not re.match("[0-9]{1}[.]{1}[0-9]{4}",ui_mm.lineEdit_material.text()): utils.show_message_box(QtWidgets.QMessageBox.Warning,"Bitte geben Sie die Werkstoffnummer im Format 0.0000 ein","Fehler") return decimalPoint = locale.localeconv()['decimal_point'] seperator = locale.localeconv()['thousands_sep'] densityStr = str(ui_mm.lineEdit_density.text()).replace(seperator, '') if not re.match("\d+(?:\,\d{0,3})?$",densityStr): utils.show_message_box(QtWidgets.QMessageBox.Warning,"Bitte geben Sie die Dichte im Format 0"+decimalPoint+"000 ein","Fehler") return #settings for regular numbers and currency can be different #they are mostlikely the same in 99.999% of the cases, but this is the clean way to code it decimalPoint = locale.localeconv()['mon_decimal_point'] seperator = locale.localeconv()['mon_thousands_sep'] priceStr = str(ui_mm.lineEdit_price.text()).replace(seperator, '') if not re.match("\d+(?:\,\d{0,2})?$",priceStr): utils.show_message_box(QtWidgets.QMessageBox.Warning,"Bitte geben Sie den Preis im Format 0"+decimalPoint+"00 ein","Fehler") return density = locale.atof(densityStr) price = locale.atof(priceStr) if ui_mm.mode == 'E': model.update_material((ui_mm.lineEdit_standard.text(),ui_mm.lineEdit_chemical.text(),density,price,globalColor.getColorValue(),ui_mm.lineEdit_material.text())) if model.getSfg() != []: model.update_sfg((ui_mm.lineEdit_material.text(),), utils.create_tuple_from_list(model.getSfg())) elif ui_mm.mode == 'N': if ( ui_mm.lineEdit_material.text() == '' or ui_mm.lineEdit_standard.text() == '' or ui_mm.lineEdit_chemical.text() == '' or ui_mm.lineEdit_density.text() == '' or ui_mm.lineEdit_price.text() == '' ): utils.show_message_box(QtWidgets.QMessageBox.Warning,"Bitte alle Felder füllen","Fehler") return else: model.insert_material((ui_mm.lineEdit_material.text(),ui_mm.lineEdit_standard.text(),ui_mm.lineEdit_chemical.text(),density,price,globalColor.getColorValue())) controller.refresh_comboBox_material(ui, ui_mm.lineEdit_material.text(),ui_mm.lineEdit_standard.text(),ui_mm.lineEdit_chemical.text()) ui_mm.accept()
def update(dialogUi, mainUi): model.setPockets(utils.build_list_from_pocket_table(dialogUi.tableWidget)) mainUi.lineEdit_pockets.setText(str(dialogUi.tableWidget.rowCount())) for row in range(0, dialogUi.tableWidget.rowCount()): rowOut = int(row) + int(1) if (dialogUi.tableWidget.item(row, 1) == None or not re.match("^\d+$", dialogUi.tableWidget.item(row, 1).text())): utils.show_message_box( QtWidgets.QMessageBox.Warning, "Bitte geben Sie eine ganze Zahl als Tiefe in Zeile " + str(rowOut) + " ein.", "Fehler") #@TO-DO: closing and reopening the dialog seems a bit sketchy, better solution needed show(mainUi) return if (dialogUi.tableWidget.item(row, 3) == None or not re.match("^\d+$", dialogUi.tableWidget.item(row, 3).text())): utils.show_message_box( QtWidgets.QMessageBox.Warning, "Bitte geben Sie eine ganze Zahl als Hüllfläche: a in Zeile " + str(rowOut) + " ein.", "Fehler") #@TO-DO: closing and reopening the dialog seems a bit sketchy, better solution needed show(mainUi) return if (dialogUi.tableWidget.item(row, 4) == None or not re.match("^\d+$", dialogUi.tableWidget.item(row, 4).text())): utils.show_message_box( QtWidgets.QMessageBox.Warning, "Bitte geben Sie eine ganze Zahl als Hüllfläche: b in Zeile " + str(rowOut) + " ein.", "Fehler") #@TO-DO: closing and reopening the dialog seems a bit sketchy, better solution needed show(mainUi) return check_pocket_size(selected_side(dialogUi, row), int(dialogUi.tableWidget.item(row, 3).text()), int(dialogUi.tableWidget.item(row, 4).text()), int(dialogUi.tableWidget.item(row, 1).text()), rowOut, mainUi)