diff --git a/qutebrowser/network/networkmanager.py b/qutebrowser/network/networkmanager.py index c8f2bd547..75e7016eb 100644 --- a/qutebrowser/network/networkmanager.py +++ b/qutebrowser/network/networkmanager.py @@ -63,8 +63,8 @@ class NetworkManager(QNetworkAccessManager): """ scheme = req.url().scheme() - logging.debug("new req, scheme {}, handlers {}".format(scheme, - self._scheme_handlers)) + logging.debug("new req, scheme {}, handlers {}".format( + scheme, self._scheme_handlers)) if scheme in self._scheme_handlers: reply = self._scheme_handlers[scheme].createRequest( op, req, outgoing_data) diff --git a/qutebrowser/network/qutescheme.py b/qutebrowser/network/qutescheme.py index 548a7bf33..694d07e82 100644 --- a/qutebrowser/network/qutescheme.py +++ b/qutebrowser/network/qutescheme.py @@ -102,10 +102,8 @@ class QuteSchemeHandler(SchemeHandler): A QNetworkReply. """ - # FIXME handle unknown pages # FIXME adjust URLutils based on handlers - logging.debug('request: {}'.format(request)) data = handle(urlstring(request.url())) return SpecialNetworkReply(request, data, "text/html", self.parent()) diff --git a/qutebrowser/network/schemehandler.py b/qutebrowser/network/schemehandler.py index 3a78c88d1..4d803c42f 100644 --- a/qutebrowser/network/schemehandler.py +++ b/qutebrowser/network/schemehandler.py @@ -20,16 +20,15 @@ """Base class for custom scheme handlers.""" -import logging - from PyQt5.QtNetwork import QNetworkReply, QNetworkRequest from PyQt5.QtCore import pyqtSlot, QObject, QIODevice, QByteArray, QTimer + class SchemeHandler(QObject): """Abstract base class for custom scheme handlers.""" - def createRequest(self, op, request, outgoingData=None): + def createRequest(self, op, request, outgoingData): """Create a new request. Args: @@ -43,11 +42,11 @@ class SchemeHandler(QObject): Raise: NotImplementedError because this needs to be overwritten by subclasses. + """ raise NotImplementedError - class SpecialNetworkReply(QNetworkReply): """QNetworkReply subclass for special data.""" @@ -77,6 +76,8 @@ class SpecialNetworkReply(QNetworkReply): QByteArray.number(len(fileData))) self.setAttribute(QNetworkRequest.HttpStatusCodeAttribute, 200) self.setAttribute(QNetworkRequest.HttpReasonPhraseAttribute, "OK") + # For some reason, a segfault will be triggered if these lambdas aren't + # there. pylint: disable=unnecessary-lambda QTimer.singleShot(0, lambda: self.metaDataChanged.emit()) QTimer.singleShot(0, lambda: self.readyRead.emit()) QTimer.singleShot(0, lambda: self.finished.emit()) @@ -93,7 +94,6 @@ class SpecialNetworkReply(QNetworkReply): bytes available (int) """ - logging.debug("bytes available: {}".format(len(self._data))) return len(self._data) + super().bytesAvailable() def readData(self, maxlen): @@ -108,7 +108,6 @@ class SpecialNetworkReply(QNetworkReply): """ len_ = min(maxlen, len(self._data)) buf = bytes(self._data[:len_]) - logging.debug("readdata, len {}, maxlen {}, buf {}".format(len(self._data), maxlen, buf)) self._data = self._data[len_:] return buf diff --git a/qutebrowser/utils/config.py b/qutebrowser/utils/config.py index d27980e24..9b319545f 100644 --- a/qutebrowser/utils/config.py +++ b/qutebrowser/utils/config.py @@ -261,7 +261,7 @@ class Config(ConfigParser): not self.always_save): logging.warning("Not saving config (dir {}, config {})".format( self._configdir, 'loaded' if self._config_loaded - else 'not loaded')) + else 'not loaded')) return if not os.path.exists(self._configdir): os.makedirs(self._configdir, 0o755)