def show_works(): works = [item.serialize for item in get_works()] res = make_response(get_json(works)) res.headers['Access-Control-Allow-Origin'] = '*' res.headers['Content-Type'] = 'application/json' return res, 200
def write_to_pdf(): #read variables from data.txt json_data = data.get_json() #conver true false to X if json_data["completed_per_instruction"] is True: completed_per_instruction_text = "X" else: completed_per_instruction_text = "" if json_data["completed_by_factory"] is True: completed_by_factory_text = "X" else: completed_by_factory_text = "" if json_data["not_comp_not_affected"] is True: not_comp_not_affected_text = "X" else: not_comp_not_affected_text = "" if json_data["not_comp_required_parts"] is True: not_comp_required_parts_text = "X" else: not_comp_required_parts_text = "" if json_data["not_comp_refused"] is True: not_comp_refused_text = "X" else: not_comp_refused_text = "" packet = StringIO.StringIO() # create a new PDF with Reportlab can = canvas.Canvas(packet, pagesize=letter) #can.drawString(PositionX, PositionY, "STRING") #see translation.xlsx for the conversion can.drawString(173, 654, str(json_data["hospital_address"])) can.drawString(188, 633, str(json_data["location"])) can.drawString(440, 631, str(json_data["sales"])) can.drawString(201, 600, str(json_data["product_number"])) can.drawString(201, 566, str(json_data["serial_number"])) can.drawString(74, 503, completed_per_instruction_text) can.drawString(264, 503, str(json_data["completed_date"])) can.drawString(364, 503, str(json_data["job_number"])) can.drawString(74, 472, completed_by_factory_text) can.drawString(74, 438, not_comp_not_affected_text) can.drawString(74, 397, not_comp_required_parts_text) can.drawString(74, 363, not_comp_refused_text) can.drawString(104, 279, str(json_data["customer_name"])) can.drawString(380, 279, str(json_data["customer_title"])) can.drawString(133, 194, str(json_data["branch_region_dealer"])) can.drawString(84, 162, str(json_data["customer_services_engineer"])) can.drawString(368, 162, str(json_data["signed_date"])) can.save() #move to the beginning of the StringIO buffer packet.seek(0) new_pdf = PdfFileReader(packet) # read your existing PDF existing_pdf = PdfFileReader("template.pdf") output = PdfFileWriter() # add the "watermark" (which is the new pdf) on the existing page page = existing_pdf.getPage(0) page.mergePage(new_pdf.getPage(0)) output.addPage(page) # finally, write "output" to a real file file_path = os.path.relpath("_output/ANR_%s.pdf" % str(json_data["serial_number"])) outputStream = open(file_path, "wb") output.write(outputStream) outputStream.close()
def api_per_capita(country): return get_json(country, true_for_kt=False)
def api_kt(country): return get_json(country, true_for_kt=True)
""" Запуск обученной сети на тестовых данных """ test_loss, test_acc = model.evaluate(test_images, test_labels) print('\nТочность на проверочных данных', test_acc) if __name__ == '__main__': # Загрузка модели model = keras.models.load_model(nw.FILENAME) if len(sys.argv) > 1: # Загрузка собственноручно созданных изображений dir = sys.argv[1] os.chdir(os.getcwd() + '/' + dir) test_images, test_labels = data.get_own_data() os.chdir('..') print(test_images.shape) test_predict = model.predict(test_images) else: # Загрузка стандартных тестовых данных (_, _), (test_images, test_labels) = data.get_data() evaluate(model, test_images, test_labels) test_predict = model.predict(test_images) data.get_json(test_predict, test_labels) data.get_conf_mat(test_predict, test_labels)
def __init__(self, parent=None): super(Program, self).__init__(parent) #setting up objects to be on the layout self.setWindowTitle(__appname__) self.hospital_address_label = QLabel("Hospital/Address:") self.hospital_address = QLineEdit() self.location_label = QLabel("Location/FW Site No.:") self.location = QLineEdit() self.sales_label = QLabel("Sales Order No.:") self.sales = QLineEdit() self.product_number_label = QLabel("Product Number:") self.product_number = QLineEdit() self.serial_number_label = QLabel("Unit Serial Number:") self.serial_number = QLineEdit() self.completed_date_label = QLabel("Action Date:") self.completed_date = QLineEdit() self.job_number_label = QLabel("Job No./Service Incident NO.:") self.job_number = QLineEdit() self.completed_per_instruction_box = QCheckBox("Completed per Instruction") self.completed_by_factory_box = QCheckBox("Completed by the factory prior to delivery") self.not_comp_not_affected_box = QCheckBox("Not Completed as this unit is not affected per instruction because:(state reason)") self.not_comp_required_parts_box = QCheckBox("Not completed because required parts & instructions are received by the customer") self.not_comp_refuse_box = QCheckBox("Not completed because customer refuses to install FCO:(state reason)") self.customer_name_label = QLabel("Customer Name (Please Print):") self.customer_name = QLineEdit() self.customer_title_label = QLabel("Customer Title") self.customer_title = QLineEdit() self.branch_region_dealer_label = QLabel("Branch Region Dealer::") self.branch_region_dealer = QLineEdit() self.customer_services_engineer_label = QLabel("Customer Services Engineer:") self.customer_services_engineer = QLineEdit() self.signed_date_label = QLabel("Signed Date:") self.signed_date = QLineEdit() self.contact_label = QLabel("Contact: george.paw(at)philips.com") write2pdf = QPushButton("Generate ANR") #putting objects into layout layout = QVBoxLayout() #Q vertical box layout, can do horizontal #layout = QWidget() layout.addWidget(self.hospital_address_label) layout.addWidget(self.hospital_address); self.setLayout(self.hospital_address.setFixedWidth(600)) layout.addWidget(self.location_label) layout.addWidget(self.location); self.setLayout(self.location.setFixedWidth(600)) layout.addWidget(self.sales_label) layout.addWidget(self.sales); self.setLayout(self.sales.setFixedWidth(600)) layout.addWidget(self.product_number_label) layout.addWidget(self.product_number); self.setLayout(self.product_number.setFixedWidth(600)) layout.addWidget(self.serial_number_label) layout.addWidget(self.serial_number); self.setLayout(self.serial_number.setFixedWidth(600)) layout.addWidget(self.completed_date_label) layout.addWidget(self.completed_date); self.setLayout(self.completed_date.setFixedWidth(600)) layout.addWidget(self.job_number_label) layout.addWidget(self.job_number); self.setLayout(self.job_number.setFixedWidth(600)) layout.addWidget(self.completed_per_instruction_box) layout.addWidget(self.completed_by_factory_box) layout.addWidget(self.not_comp_not_affected_box) layout.addWidget(self.not_comp_required_parts_box) layout.addWidget(self.not_comp_refuse_box) layout.addWidget(self.customer_name_label) layout.addWidget(self.customer_name); self.setLayout(self.customer_name.setFixedWidth(600)) layout.addWidget(self.customer_title_label) layout.addWidget(self.customer_title); self.setLayout(self.customer_title.setFixedWidth(600)) layout.addWidget(self.branch_region_dealer_label) layout.addWidget(self.branch_region_dealer); self.setLayout(self.branch_region_dealer.setFixedWidth(600)) layout.addWidget(self.customer_services_engineer_label) layout.addWidget(self.customer_services_engineer); self.setLayout(self.customer_services_engineer.setFixedWidth(600)) layout.addWidget(self.signed_date_label) layout.addWidget(self.signed_date); self.setLayout(self.signed_date.setFixedWidth(600)) layout.addWidget(write2pdf) layout.addWidget(self.contact_label) #set the layout self.setLayout(layout) #connecting the objects to a trigger action self.connect(write2pdf, SIGNAL("clicked()"), self.write_to_data) #pre setting values json_data = data.get_json() self.hospital_address.setText(str(json_data["hospital_address"])) self.location.setText(str(json_data["location"])) self.sales.setText(str(json_data["sales"])) self.product_number.setText(str(json_data["product_number"])) self.serial_number.setText(str(json_data["serial_number"])) self.completed_date.setText(str(json_data["completed_date"])) self.job_number.setText(str(json_data["job_number"])) if json_data["completed_per_instruction"] is True: self.completed_per_instruction_box.setChecked(1) if json_data["completed_by_factory"] is True: self.completed_by_factory_box.setChecked(1) if json_data["not_comp_not_affected"] is True: self.not_comp_not_affected_box.setChecked(1) if json_data["not_comp_required_parts"] is True: self.not_comp_required_parts_box.setChecked(1) if json_data["not_comp_refused"] is True: self.not_comp_refuse_box.setChecked(1) self.customer_name.setText(str(json_data["customer_name"])) self.customer_title.setText(str(json_data["customer_title"])) self.branch_region_dealer.setText(str(json_data["branch_region_dealer"])) self.customer_services_engineer.setText(str(json_data["customer_services_engineer"])) self.signed_date.setText(str(json_data["signed_date"])) self.db_path = None self.mtr_path = None