| There is no RationalWiki without you. We are a small non-profit with no staff – we are hundreds of volunteers who document pseudoscience and crankery around the world every day. We will never allow ads because we must remain independent. We cannot rely on big donors with corresponding big agendas. We are not the largest website around, but we believe we play an important role in defending truth and objectivity. If everyone seeing this today donates $5, we will meet our goal for 2019. |
Fighting pseudoscience isn't free. We are 100% user-supported! Help and donate $5, $20 or whatever you can today with |
User:JeevesMkII/capturebot-http-diff
From RationalWiki
--- webkit2png.py.old 2014-04-01 18:33:58.000000000 +0100
+++ webkit2png.py 2014-04-01 18:33:10.000000000 +0100
@@ -44,6 +44,7 @@
self._page = QWebPage()
self.connect(self._page, SIGNAL("loadFinished(bool)"), self.__on_load_finished)
self.connect(self._page, SIGNAL("loadStarted()"), self.__on_load_started)
+ self.connect(self._page.networkAccessManager(), SIGNAL("finished(QNetworkReply *)"), self.__on_http_finished)
# The way we will use this, it seems to be unesseccary to have Scrollbars enabled
self._page.mainFrame().setScrollBarPolicy(Qt.Horizontal, Qt.ScrollBarAlwaysOff)
@@ -52,6 +53,7 @@
# Helper for multithreaded communication through signals
self.__loading = False
self.__loading_result = False
+ self.__http_ok = False;
# Loads "url" and renders it.
# Returns QImage-object on success.
@@ -75,7 +77,7 @@
logging.debug("Processing result")
- if self.__loading_result == False:
+ if !self.__loading_result || !self.__http_ok:
# raise RuntimeError("Failed to load %s" % url)
print "Failed to load %s" % url
return None
@@ -138,6 +140,11 @@
def __on_load_started(self):
logging.debug("loading started")
self.__loading = True
+
+ def __on_http_finished(self, reply):
+ logging.debug("HTTP response recieved with status code %d", reply.error())
+ self.__http_ok = (reply.error() == QNetworkReply.NoError)
+
# Eventhandler for "loadFinished(bool)" signal
def __on_load_finished(self, result):