def _setReply(self, job, contentType, content):
     '''
     @param: job QWebEngineUrlRequestJob
     @param: contentType QByteArray
     @param: content QByteArray
     '''
     buf = QBuffer(job)
     buf.open(QIODevice.ReadWrite)
     buf.write(content)
     buf.seek(0)
     job.reply(contentType, buf)
예제 #2
0
파일: web_view.py 프로젝트: zwpaper/calibre
def send_reply(rq, mime_type, data):
    if sip.isdeleted(rq):
        return
    # make the buf a child of rq so that it is automatically deleted when
    # rq is deleted
    buf = QBuffer(parent=rq)
    buf.open(QIODevice.OpenModeFlag.WriteOnly)
    # we have to copy data into buf as it will be garbage
    # collected by python
    buf.write(data)
    buf.seek(0)
    buf.close()
    rq.reply(mime_type.encode('ascii'), buf)
예제 #3
0
 def processPendingDatagrams(self):
     while self.udpSocket.hasPendingDatagrams():
         datagram, host, port = self.udpSocket.readDatagram(
             self.udpSocket.pendingDatagramSize())
         buf = QBuffer()
         b = buf.write(self.udpSocket.readAll())
         buf.seek(buf.pos() - b)
         image = QImage()
         image.loadFromData(buf.buffer())
         image.save(r"D:\test.png")