def update_employee(self): start, end = self.txt_position.get_buffer().get_bounds() self.employee.position = self.txt_position.get_buffer().get_text(start, end, False) start, end = self.txt_department.get_buffer().get_bounds() self.employee.department = self.txt_department.get_buffer().get_text(start, end, False) carnet = Carnet(self.employee) carnet.create()
def update_employee(self): start, end = self.txt_position.get_buffer().get_bounds() self.employee.position = self.txt_position.get_buffer().get_text( start, end, False) start, end = self.txt_department.get_buffer().get_bounds() self.employee.department = self.txt_department.get_buffer().get_text( start, end, False) carnet = Carnet(self.employee) carnet.create()
def mine_block(self): if self.public_key == None: return None hashed_last_block = hash_block(self.get_last_blockchain_value()) proof = self.proof_of_work() block = Block(len(self.__chain), hashed_last_block, self.__date_de_introdus, proof) for rez in block.rezultate: if not Carnet.verify_rezultat(rez): return None self.__chain.append(block) self.__date_de_introdus = [] self.save_data() for node in self.__peer_nodes: url = 'http://{}/broadcast_block'.format(node) block_convertit = block.__dict__.copy() block_convertit['rezultate'] = [ rez.to_ordered_dict() for rez in block_convertit['rezultate'] ] try: response = requests.post(url, json={'block': block_convertit}) if response.status_code == 400 or response.status_code == 500: print('bloc aiurea') if response.status_code == 409: self.resolve_conflicts = True except requests.exceptions.ConnectionError: continue return block
def add_nota(self, emitator, receptor, info_didactic, semnatura, is_receiving=False): rezultat = Rezultat(emitator, receptor, info_didactic, semnatura) print(rezultat) if not Carnet.verify_rezultat(rezultat): return False self.__date_de_introdus.append(rezultat) self.save_data() if not is_receiving: for node in self.__peer_nodes: url = 'http://{}/broadcast_note'.format(node) try: response = requests.post( url, json={ 'emitator': emitator, 'receptor': receptor, 'info_didactic': info_didactic.to_ordered_dict(), 'semnatura': semnatura }) if response.status_code == 400 or response.status_code == 500: print('nota aiurea') return False except requests.exceptions.ConnectionError: continue return True
return jsonify(response), 201 @app.route('/profesor/<cheie>', methods=['DELETE']) def remove_profesor(cheie): if cheie == '' or cheie == None: response = {'message': 'Nu am gasit date'} return jsonify(response), 400 blockchain.remove_profesor(cheie) response = { 'message': 'Nod sters', 'all_profesori': blockchain.get_profesori() } return jsonify(response), 200 @app.route('/profesori', methods=['GET']) def get_profesori(): response = {'all_profesori': blockchain.get_profesori()} return jsonify(response), 200 if __name__ == '__main__': parser = ArgumentParser() parser.add_argument('-p', '--port', type=int, default=51328) args = parser.parse_args() port = args.port carnet = Carnet(port) blockchain = Blockchain(carnet.public_key, port) app.run(host='0.0.0.0', port=port)
def on_btn_take_picture_clicked(self, widget): status = execute_cmd("python camera.py %s" % self.employee.pid) if status == 0: carnet = Carnet(self.employee) carnet.create() self.load_image(self.employee.pid)
screen.addstr(7, 4, "4 - Exit") screen.refresh() x = screen.getch() if x == ord('1'): person_id = get_param("Enter the person ID:") emp = Employee(person_id) if emp.pid is not None: screen.clear() screen.border(0) screen.addstr(2, 4, "Name:") addstr_bold(2, 14, emp.name.encode(code)) screen.addstr(3, 4, "Surname:") addstr_bold(3, 14, emp.surname.encode(code)) screen.addstr(7, 4, "Press any key to cotinue...") screen.refresh() screen.getch() curses.endwin() status = execute_cmd("python camera.py %s" % person_id) if status == 0: carnet = Carnet(emp) carnet.create() curses.endwin()