本文整理汇总了Python中PyQt5.QtNetwork.QSslSocket.supportsSsl方法的典型用法代码示例。如果您正苦于以下问题:Python QSslSocket.supportsSsl方法的具体用法?Python QSslSocket.supportsSsl怎么用?Python QSslSocket.supportsSsl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtNetwork.QSslSocket
的用法示例。
在下文中一共展示了QSslSocket.supportsSsl方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: version
# 需要导入模块: from PyQt5.QtNetwork import QSslSocket [as 别名]
# 或者: from PyQt5.QtNetwork.QSslSocket import supportsSsl [as 别名]
def version():
"""Return a string with various version informations."""
lines = ["qutebrowser v{}".format(qutebrowser.__version__)]
gitver = _git_str()
if gitver is not None:
lines.append("Git commit: {}".format(gitver))
lines += [
'',
'{}: {}'.format(platform.python_implementation(),
platform.python_version()),
'Qt: {}, runtime: {}'.format(QT_VERSION_STR, qVersion()),
'PyQt: {}'.format(PYQT_VERSION_STR),
]
lines += _module_versions()
if QSslSocket is not None and QSslSocket.supportsSsl():
ssl_version = QSslSocket.sslLibraryVersionString()
else:
ssl_version = 'unavailable'
lines += [
'Webkit: {}'.format(qWebKitVersion()),
'Harfbuzz: {}'.format(os.environ.get('QT_HARFBUZZ', 'system')),
'SSL: {}'.format(ssl_version),
'',
'Frozen: {}'.format(hasattr(sys, 'frozen')),
'Platform: {}, {}'.format(platform.platform(),
platform.architecture()[0]),
]
lines += _os_info()
return '\n'.join(lines)
示例2: check_ssl_support
# 需要导入模块: from PyQt5.QtNetwork import QSslSocket [as 别名]
# 或者: from PyQt5.QtNetwork.QSslSocket import supportsSsl [as 别名]
def check_ssl_support():
"""Check if SSL support is available."""
try:
from PyQt5.QtNetwork import QSslSocket
except ImportError:
ok = False
else:
ok = QSslSocket.supportsSsl()
if not ok:
text = "Fatal error: Your Qt is built without SSL support."
_die(text)
示例3: check_backend_ssl_support
# 需要导入模块: from PyQt5.QtNetwork import QSslSocket [as 别名]
# 或者: from PyQt5.QtNetwork.QSslSocket import supportsSsl [as 别名]
def check_backend_ssl_support(backend):
"""Check for full SSL availability when we know the backend."""
from PyQt5.QtNetwork import QSslSocket
from qutebrowser.utils import log, usertypes
text = ("Could not initialize QtNetwork SSL support. If you use "
"OpenSSL 1.1 with a PyQt package from PyPI (e.g. on Archlinux "
"or Debian Stretch), you need to set LD_LIBRARY_PATH to the path "
"of OpenSSL 1.0. This only affects downloads.")
if not QSslSocket.supportsSsl():
if backend == usertypes.Backend.QtWebKit:
_die("Could not initialize SSL support.")
else:
assert backend == usertypes.Backend.QtWebEngine
log.init.warning(text)
示例4: handle
# 需要导入模块: from PyQt5.QtNetwork import QSslSocket [as 别名]
# 或者: from PyQt5.QtNetwork.QSslSocket import supportsSsl [as 别名]
def handle(self, argv: List[str]) -> int:
""" Parse options, setup logs and manager and dispatch execution. """
# Pre-configure the logging to catch early errors
configure(console_level="DEBUG", command_name="early")
options = self.parse_cli(argv)
if hasattr(options, "local_folder"):
options.local_folder = normalize_and_expand_path(options.local_folder)
if hasattr(options, "nxdrive_home"):
options.nxdrive_home = normalize_and_expand_path(options.nxdrive_home)
command = getattr(options, "command", "launch")
handler = getattr(self, command, None)
if not handler:
raise RuntimeError(f"No handler implemented for command {command}")
self._configure_logger(command, options)
log.info(f"Command line: argv={argv!r}, options={options!r}")
log.info(f"Running on version {self.get_version()}")
if QSslSocket:
has_ssl_support = QSslSocket.supportsSsl()
log.info(f"SSL support: {has_ssl_support!r}")
if not has_ssl_support:
if Options.is_frozen:
raise RuntimeError("No SSL support, packaging must have failed.")
else:
options.ca_bundle = None
options.ssl_no_verify = True
# We cannot use fail_on_error=True because options is a namespace
# and contains a lot of inexistant Options values.
Options.update(options, setter="cli", fail_on_error=False)
if command != "uninstall":
self._install_faulthandler()
self.manager = self.get_manager()
return handler(options)
示例5: _handle_ssl_support
# 需要导入模块: from PyQt5.QtNetwork import QSslSocket [as 别名]
# 或者: from PyQt5.QtNetwork.QSslSocket import supportsSsl [as 别名]
def _handle_ssl_support(fatal=False):
"""Check for full SSL availability.
If "fatal" is given, show an error and exit.
"""
text = ("Could not initialize QtNetwork SSL support. If you use "
"OpenSSL 1.1 with a PyQt package from PyPI (e.g. on Archlinux "
"or Debian Stretch), you need to set LD_LIBRARY_PATH to the path "
"of OpenSSL 1.0. This only affects downloads.")
if QSslSocket.supportsSsl():
return
if fatal:
errbox = msgbox.msgbox(parent=None,
title="SSL error",
text="Could not initialize SSL support.",
icon=QMessageBox.Critical,
plain_text=False)
errbox.exec_()
sys.exit(usertypes.Exit.err_init)
assert not fatal
log.init.warning(text)
示例6: NetworkManager
# 需要导入模块: from PyQt5.QtNetwork import QSslSocket [as 别名]
# 或者: from PyQt5.QtNetwork.QSslSocket import supportsSsl [as 别名]
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with qutebrowser. If not, see <http://www.gnu.org/licenses/>.
"""Our own QNetworkAccessManager."""
from PyQt5.QtCore import pyqtSlot, pyqtSignal, PYQT_VERSION, QCoreApplication
from PyQt5.QtNetwork import QNetworkAccessManager, QNetworkReply
try:
from PyQt5.QtNetwork import QSslSocket
except ImportError:
SSL_AVAILABLE = False
else:
SSL_AVAILABLE = QSslSocket.supportsSsl()
from qutebrowser.config import config
from qutebrowser.utils import message, log, usertypes, utils, objreg
from qutebrowser.browser import cookies
from qutebrowser.browser.network import qutescheme, networkreply
HOSTBLOCK_ERROR_STRING = '%HOSTBLOCK%'
class NetworkManager(QNetworkAccessManager):
"""Our own QNetworkAccessManager.
Attributes:
示例7: check_ssl
# 需要导入模块: from PyQt5.QtNetwork import QSslSocket [as 别名]
# 或者: from PyQt5.QtNetwork.QSslSocket import supportsSsl [as 别名]
def check_ssl():
if not QSslSocket.supportsSsl():
pytest.skip("QtNetwork SSL not supported")
示例8: version
# 需要导入模块: from PyQt5.QtNetwork import QSslSocket [as 别名]
# 或者: from PyQt5.QtNetwork.QSslSocket import supportsSsl [as 别名]
def version():
"""Return a string with various version informations."""
lines = ["qutebrowser v{}".format(qutebrowser.__version__)]
gitver = _git_str()
if gitver is not None:
lines.append("Git commit: {}".format(gitver))
lines.append("Backend: {}".format(_backend()))
lines += [
'',
'{}: {}'.format(platform.python_implementation(),
platform.python_version()),
'Qt: {}'.format(earlyinit.qt_version()),
'PyQt: {}'.format(PYQT_VERSION_STR),
'',
]
lines += _module_versions()
lines += [
'pdf.js: {}'.format(_pdfjs_version()),
'sqlite: {}'.format(sql.version()),
'QtNetwork SSL: {}\n'.format(QSslSocket.sslLibraryVersionString()
if QSslSocket.supportsSsl() else 'no'),
]
qapp = QApplication.instance()
if qapp:
style = qapp.style()
lines.append('Style: {}'.format(style.metaObject().className()))
importpath = os.path.dirname(os.path.abspath(qutebrowser.__file__))
lines += [
'Platform: {}, {}'.format(platform.platform(),
platform.architecture()[0]),
]
dist = distribution()
if dist is not None:
lines += [
'Linux distribution: {} ({})'.format(dist.pretty, dist.parsed.name)
]
lines += [
'Frozen: {}'.format(hasattr(sys, 'frozen')),
"Imported from {}".format(importpath),
"Qt library executable path: {}, data path: {}".format(
QLibraryInfo.location(QLibraryInfo.LibraryExecutablesPath),
QLibraryInfo.location(QLibraryInfo.DataPath)
)
]
if not dist or dist.parsed == Distribution.unknown:
lines += _os_info()
lines += [
'',
'Paths:',
]
for name, path in sorted(_path_info().items()):
lines += ['{}: {}'.format(name, path)]
return '\n'.join(lines)
示例9: createRequest
# 需要导入模块: from PyQt5.QtNetwork import QSslSocket [as 别名]
# 或者: from PyQt5.QtNetwork.QSslSocket import supportsSsl [as 别名]
def createRequest(self, op, request, outgoingData=None):
"""
Public method to create a request.
@param op the operation to be performed
(QNetworkAccessManager.Operation)
@param request reference to the request object (QNetworkRequest)
@param outgoingData reference to an IODevice containing data to be sent
(QIODevice)
@return reference to the created reply object (QNetworkReply)
"""
scheme = request.url().scheme()
if scheme == "https" and \
(not SSL_AVAILABLE or not QSslSocket.supportsSsl()):
from .NetworkProtocolUnknownErrorReply import \
NetworkProtocolUnknownErrorReply
return NetworkProtocolUnknownErrorReply(scheme, self)
import Helpviewer.HelpWindow
if op == QNetworkAccessManager.PostOperation and \
outgoingData is not None:
outgoingDataByteArray = outgoingData.peek(1024 * 1024)
Helpviewer.HelpWindow.HelpWindow.passwordManager().post(
request, outgoingDataByteArray)
reply = None
if scheme in self.__schemeHandlers:
reply = self.__schemeHandlers[scheme]\
.createRequest(op, request, outgoingData)
if reply is not None:
return reply
# give GreaseMonkey the chance to create a request
reply = Helpviewer.HelpWindow.HelpWindow.greaseMonkeyManager()\
.createRequest(op, request, outgoingData)
if reply is not None:
return reply
req = QNetworkRequest(request)
if req.rawHeader(b"X-Eric6-UserLoadAction") == QByteArray(b"1"):
req.setRawHeader(b"X-Eric6-UserLoadAction", QByteArray())
req.setAttribute(QNetworkRequest.User + 200, "")
else:
req.setAttribute(
QNetworkRequest.User + 200, req.rawHeader(b"Referer"))
if hasattr(QNetworkRequest, 'HttpPipeliningAllowedAttribute'):
req.setAttribute(
QNetworkRequest.HttpPipeliningAllowedAttribute, True)
if not self.__acceptLanguage.isEmpty():
req.setRawHeader(b"Accept-Language", self.__acceptLanguage)
# AdBlock code
if op == QNetworkAccessManager.GetOperation:
if self.__adblockNetwork is None:
self.__adblockNetwork = \
Helpviewer.HelpWindow.HelpWindow.adBlockManager().network()
reply = self.__adblockNetwork.block(req)
if reply is not None:
reply.setParent(self)
return reply
# set cache policy
if op == QNetworkAccessManager.GetOperation:
urlHost = req.url().host()
for host in Preferences.getHelp("NoCacheHosts"):
if host in urlHost:
req.setAttribute(
QNetworkRequest.CacheLoadControlAttribute,
QNetworkRequest.AlwaysNetwork)
break
else:
req.setAttribute(
QNetworkRequest.CacheLoadControlAttribute,
Preferences.getHelp("CachePolicy"))
else:
req.setAttribute(
QNetworkRequest.CacheLoadControlAttribute,
QNetworkRequest.AlwaysNetwork)
# Do Not Track feature
if self.__doNotTrack:
req.setRawHeader(b"DNT", b"1")
req.setRawHeader(b"X-Do-Not-Track", b"1")
# Send referer header?
if not self.__sendReferer and \
req.url().host() not in Preferences.getHelp("SendRefererWhitelist"):
req.setRawHeader(b"Referer", b"")
reply = QNetworkAccessManager.createRequest(
self, op, req, outgoingData)
self.requestCreated.emit(op, req, reply)
return reply
示例10: print
# 需要导入模块: from PyQt5.QtNetwork import QSslSocket [as 别名]
# 或者: from PyQt5.QtNetwork.QSslSocket import supportsSsl [as 别名]
# Copyright 2019, Kay Hayen, mailto:[email protected]
#
# Python test originally created or extracted from other peoples work. The
# parts from me are licensed as below. It is at least Free Software where
# it's copied from other people. In these cases, that will normally be
# indicated.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from PyQt5.QtNetwork import QSslSocket
print("SSL support: %r" % (QSslSocket.supportsSsl(),))