Added more logging

This commit is contained in:
Jaime van Kessel 2016-07-15 15:03:47 +02:00
parent 53a9f5f622
commit 097d4c9e6b

View file

@ -388,6 +388,7 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice):
## Handler for all requests that have finished. ## Handler for all requests that have finished.
def _onFinished(self, reply): def _onFinished(self, reply):
status_code = reply.attribute(QNetworkRequest.HttpStatusCodeAttribute)
if reply.operation() == QNetworkAccessManager.GetOperation: if reply.operation() == QNetworkAccessManager.GetOperation:
if "printer" in reply.url().toString(): # Status update from printer. if "printer" in reply.url().toString(): # Status update from printer.
if reply.attribute(QNetworkRequest.HttpStatusCodeAttribute) == 200: if reply.attribute(QNetworkRequest.HttpStatusCodeAttribute) == 200:
@ -397,6 +398,7 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice):
self._spliceJSONData() self._spliceJSONData()
else: else:
Logger.log("w", "We got an unexpected status (%s) while requesting printer state", status_code)
pass # TODO: Handle errors pass # TODO: Handle errors
elif "print_job" in reply.url().toString(): # Status update from print_job: elif "print_job" in reply.url().toString(): # Status update from print_job:
if reply.attribute(QNetworkRequest.HttpStatusCodeAttribute) == 200: if reply.attribute(QNetworkRequest.HttpStatusCodeAttribute) == 200:
@ -416,6 +418,8 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice):
self.setTimeElapsed(0) self.setTimeElapsed(0)
self.setTimeTotal(0) self.setTimeTotal(0)
self.setJobName("") self.setJobName("")
else:
Logger.log("w", "We got an unexpected status (%s) while requesting print job state", status_code)
elif "snapshot" in reply.url().toString(): # Status update from image: elif "snapshot" in reply.url().toString(): # Status update from image:
if reply.attribute(QNetworkRequest.HttpStatusCodeAttribute) == 200: if reply.attribute(QNetworkRequest.HttpStatusCodeAttribute) == 200:
self._camera_image.loadFromData(reply.readAll()) self._camera_image.loadFromData(reply.readAll())