Пример #1
0
        def __authenticate_proxy(
            self,
            reply: QtNetwork.QNetworkProxy,
            authenticator: QtNetwork.QAuthenticator,
        ):
            if HAVE_FREECAD and FreeCAD.GuiUp:
                proxy_authentication = FreeCADGui.PySideUic.loadUi(
                    os.path.join(os.path.dirname(__file__),
                                 "proxy_authentication.ui"))
                # Show the right labels, etc.
                proxy_authentication.labelProxyAddress.setText(
                    f"{reply.hostName()}:{reply.port()}")
                if authenticator.realm():
                    proxy_authentication.labelProxyRealm.setText(
                        authenticator.realm())
                else:
                    proxy_authentication.labelProxyRealm.hide()
                    proxy_authentication.labelRealmCaption.hide()
                result = proxy_authentication.exec()
                if result == QtWidgets.QDialogButtonBox.Ok:
                    authenticator.setUser(
                        proxy_authentication.lineEditUsername.text())
                    authenticator.setPassword(
                        proxy_authentication.lineEditPassword.text())
            else:
                username = input("Proxy username: ")
                import getpass

                password = getpass.getpass()
                authenticator.setUser(username)
                authenticator.setPassword(password)
Пример #2
0
        def __authenticate_proxy(
            self,
            reply: QtNetwork.QNetworkProxy,
            authenticator: QtNetwork.QAuthenticator,
        ):
            """If proxy authentication is required, attempt to authenticate. If the GUI is running this displays
            a window asking for credentials. If the GUI is not running, it prompts on the command line."""
            if HAVE_FREECAD and FreeCAD.GuiUp:
                proxy_authentication = FreeCADGui.PySideUic.loadUi(
                    os.path.join(os.path.dirname(__file__),
                                 "proxy_authentication.ui"))
                proxy_authentication.setWindowFlag(
                    QtCore.Qt.WindowStaysOnTopHint, True)
                # Show the right labels, etc.
                proxy_authentication.labelProxyAddress.setText(
                    f"{reply.hostName()}:{reply.port()}")
                if authenticator.realm():
                    proxy_authentication.labelProxyRealm.setText(
                        authenticator.realm())
                else:
                    proxy_authentication.labelProxyRealm.hide()
                    proxy_authentication.labelRealmCaption.hide()
                result = proxy_authentication.exec()
                if result == QtWidgets.QDialogButtonBox.Ok:
                    authenticator.setUser(
                        proxy_authentication.lineEditUsername.text())
                    authenticator.setPassword(
                        proxy_authentication.lineEditPassword.text())
            else:
                username = input("Proxy username: ")
                import getpass

                password = getpass.getpass()
                authenticator.setUser(username)
                authenticator.setPassword(password)