예제 #1
0
    def borrow_book(self):
        # 선택한 리스트의 책 대출하기
        book = self.listbox.selectedItems()[0].text()
        print(book)
        try:
            sock = socket.create_connection(self.server_address)
            data = Protocol.LibraryRequest(command="borrow",user_id = self.user_data.userId, certkey=self.user_data.certkey)
            data.book_title = book
            with sock.makefile("rwb",0) as sfd:
                sfd.write(data.serialize())
                # recv_data = parser.parse(sfd)
                # print(__file__ + " " + recv_data)

        except Exception as e:
            print(e)
        else:
            sock.close()

        return
예제 #2
0
    def loadBookList(self):
        # connect to server and request book list
        try:
            sock = socket.create_connection(self.server_address)
            data = Protocol.LibraryRequest(command="load",user_id = self.user_data.userId, certkey=self.user_data.certkey)
            with sock.makefile("rwb",0) as sfd:
                sfd.write(data.serialize())
                # for r in sfd:
                #     recv_data = Protocol.BookData.parse(r)
                #     print(recv_data)
                # recv_data = parser.parse(sfd)

            self.listbox.addItem(QListWidgetItem("cosmos"))
            self.listbox.addItem(QListWidgetItem("little_prince"))

        except Exception as e:
            print(e)
        else:
            sock.close()