aboutsummaryrefslogtreecommitdiffstats
path: root/examples/network
diff options
context:
space:
mode:
Diffstat (limited to 'examples/network')
-rw-r--r--examples/network/blockingfortuneclient/blockingfortuneclient.py27
-rw-r--r--examples/network/downloader/downloader.py3
-rw-r--r--examples/network/fortuneclient/fortuneclient.py28
-rw-r--r--examples/network/fortuneserver/fortuneserver.py20
-rw-r--r--examples/network/googlesuggest/googlesuggest.py3
-rw-r--r--examples/network/threadedfortuneserver/threadedfortuneserver.py10
6 files changed, 45 insertions, 46 deletions
diff --git a/examples/network/blockingfortuneclient/blockingfortuneclient.py b/examples/network/blockingfortuneclient/blockingfortuneclient.py
index f467cf8d4..d0dd7e0ad 100644
--- a/examples/network/blockingfortuneclient/blockingfortuneclient.py
+++ b/examples/network/blockingfortuneclient/blockingfortuneclient.py
@@ -5,12 +5,13 @@
"""PySide6 port of the network/blockingfortunclient example from Qt v5.x, originating from PyQt"""
from PySide6.QtCore import (Signal, QDataStream, QMutex, QMutexLocker,
- QThread, QWaitCondition)
+ QThread, QWaitCondition)
from PySide6.QtGui import QIntValidator
from PySide6.QtWidgets import (QApplication, QDialogButtonBox, QGridLayout,
- QLabel, QLineEdit, QMessageBox, QPushButton, QWidget)
+ QLabel, QLineEdit, QMessageBox, QPushButton,
+ QWidget)
from PySide6.QtNetwork import (QAbstractSocket, QHostAddress, QNetworkInterface,
- QTcpSocket)
+ QTcpSocket)
class FortuneThread(QThread):
@@ -109,7 +110,7 @@ class BlockingClient(QWidget):
port_label.setBuddy(self._port_line_edit)
self._status_label = QLabel(
- "This example requires that you run the Fortune Server example as well.")
+ "This example requires that you run the Fortune Server example as well.")
self._status_label.setWordWrap(True)
self._get_fortune_button = QPushButton("Get Fortune")
@@ -144,7 +145,7 @@ class BlockingClient(QWidget):
def request_new_fortune(self):
self._get_fortune_button.setEnabled(False)
self.thread.request_new_fortune(self._host_line_edit.text(),
- int(self._port_line_edit.text()))
+ int(self._port_line_edit.text()))
def show_fortune(self, nextFortune):
if nextFortune == self._current_fortune:
@@ -158,22 +159,22 @@ class BlockingClient(QWidget):
def display_error(self, socketError, message):
if socketError == QAbstractSocket.HostNotFoundError:
QMessageBox.information(self, "Blocking Fortune Client",
- "The host was not found. Please check the host and port "
- "settings.")
+ "The host was not found. Please check the host and port "
+ "settings.")
elif socketError == QAbstractSocket.ConnectionRefusedError:
QMessageBox.information(self, "Blocking Fortune Client",
- "The connection was refused by the peer. Make sure the "
- "fortune server is running, and check that the host name "
- "and port settings are correct.")
+ "The connection was refused by the peer. Make sure the "
+ "fortune server is running, and check that the host name "
+ "and port settings are correct.")
else:
QMessageBox.information(self, "Blocking Fortune Client",
- f"The following error occurred: {message}.")
+ f"The following error occurred: {message}.")
self._get_fortune_button.setEnabled(True)
def enable_get_fortune_button(self):
- self._get_fortune_button.setEnabled(self._host_line_edit.text() != '' and
- self._port_line_edit.text() != '')
+ self._get_fortune_button.setEnabled(self._host_line_edit.text() != ''
+ and self._port_line_edit.text() != '')
if __name__ == '__main__':
diff --git a/examples/network/downloader/downloader.py b/examples/network/downloader/downloader.py
index f989adf30..fba0cb980 100644
--- a/examples/network/downloader/downloader.py
+++ b/examples/network/downloader/downloader.py
@@ -35,7 +35,8 @@ class DownloaderWidget(QWidget):
self.link_box.setPlaceholderText("Download Link ...")
self._open_folder_action = self.dest_box.addAction(
- qApp.style().standardIcon(QStyle.SP_DirOpenIcon), QLineEdit.TrailingPosition
+ qApp.style().standardIcon(QStyle.SP_DirOpenIcon), # noqa: F821
+ QLineEdit.TrailingPosition
)
self._open_folder_action.triggered.connect(self.on_open_folder)
diff --git a/examples/network/fortuneclient/fortuneclient.py b/examples/network/fortuneclient/fortuneclient.py
index 2b7ecfb85..e88e5e35b 100644
--- a/examples/network/fortuneclient/fortuneclient.py
+++ b/examples/network/fortuneclient/fortuneclient.py
@@ -6,12 +6,11 @@
import sys
-from PySide6.QtCore import QDataStream, QTimer, Qt
+from PySide6.QtCore import QDataStream, QTimer
from PySide6.QtGui import QIntValidator
from PySide6.QtNetwork import QAbstractSocket, QTcpSocket
from PySide6.QtWidgets import (QApplication, QDialog, QDialogButtonBox, QGridLayout,
- QLabel, QLineEdit, QMessageBox, QPushButton,
- QVBoxLayout, QWidget)
+ QLabel, QLineEdit, QMessageBox, QPushButton)
class Client(QDialog):
@@ -32,7 +31,7 @@ class Client(QDialog):
port_label.setBuddy(self._port_line_edit)
self._status_label = QLabel("This examples requires that you run "
- "the Fortune Server example as well.")
+ "the Fortune Server example as well.")
self._get_fortune_button = QPushButton("Get Fortune")
self._get_fortune_button.setDefault(True)
@@ -41,8 +40,7 @@ class Client(QDialog):
quit_button = QPushButton("Quit")
button_box = QDialogButtonBox()
- button_box.addButton(self._get_fortune_button,
- QDialogButtonBox.ActionRole)
+ button_box.addButton(self._get_fortune_button, QDialogButtonBox.ActionRole)
button_box.addButton(quit_button, QDialogButtonBox.RejectRole)
self._tcp_socket = QTcpSocket(self)
@@ -70,7 +68,7 @@ class Client(QDialog):
self._block_size = 0
self._tcp_socket.abort()
self._tcp_socket.connectToHost(self._host_line_edit.text(),
- int(self._port_line_edit.text()))
+ int(self._port_line_edit.text()))
def read_fortune(self):
instr = QDataStream(self._tcp_socket)
@@ -100,23 +98,23 @@ class Client(QDialog):
pass
elif socketError == QAbstractSocket.HostNotFoundError:
QMessageBox.information(self, "Fortune Client",
- "The host was not found. Please check the host name and "
- "port settings.")
+ "The host was not found. Please check the host name and "
+ "port settings.")
elif socketError == QAbstractSocket.ConnectionRefusedError:
QMessageBox.information(self, "Fortune Client",
- "The connection was refused by the peer. Make sure the "
- "fortune server is running, and check that the host name "
- "and port settings are correct.")
+ "The connection was refused by the peer. Make sure the "
+ "fortune server is running, and check that the host name "
+ "and port settings are correct.")
else:
reason = self._tcp_socket.errorString()
QMessageBox.information(self, "Fortune Client",
- f"The following error occurred: {reason}.")
+ f"The following error occurred: {reason}.")
self._get_fortune_button.setEnabled(True)
def enable_get_fortune_button(self):
- self._get_fortune_button.setEnabled(bool(self._host_line_edit.text() and
- self._port_line_edit.text()))
+ self._get_fortune_button.setEnabled(bool(self._host_line_edit.text()
+ and self._port_line_edit.text()))
if __name__ == '__main__':
diff --git a/examples/network/fortuneserver/fortuneserver.py b/examples/network/fortuneserver/fortuneserver.py
index 0ddc1f02a..a94a49f42 100644
--- a/examples/network/fortuneserver/fortuneserver.py
+++ b/examples/network/fortuneserver/fortuneserver.py
@@ -11,7 +11,7 @@ from PySide6.QtCore import QByteArray, QDataStream, QIODevice, Qt
from PySide6.QtNetwork import QTcpServer
from PySide6.QtWidgets import (QApplication, QDialog, QHBoxLayout,
QLabel, QMessageBox, QPushButton,
- QVBoxLayout, QWidget)
+ QVBoxLayout)
class Server(QDialog):
@@ -27,21 +27,21 @@ class Server(QDialog):
if not self._tcp_server.listen():
reason = self._tcp_server.errorString()
QMessageBox.critical(self, "Fortune Server",
- f"Unable to start the server: {reason}.")
+ f"Unable to start the server: {reason}.")
self.close()
return
port = self._tcp_server.serverPort()
status_label.setText(f"The server is running on port {port}.\nRun the "
- "Fortune Client example now.")
+ "Fortune Client example now.")
self.fortunes = (
- "You've been leading a dog's life. Stay off the furniture.",
- "You've got to think about tomorrow.",
- "You will be surprised by a loud noise.",
- "You will feel hungry again in another hour.",
- "You might have mail.",
- "You cannot kill time without injuring eternity.",
- "Computers are not intelligent. They only think they are.")
+ "You've been leading a dog's life. Stay off the furniture.",
+ "You've got to think about tomorrow.",
+ "You will be surprised by a loud noise.",
+ "You will feel hungry again in another hour.",
+ "You might have mail.",
+ "You cannot kill time without injuring eternity.",
+ "Computers are not intelligent. They only think they are.")
quit_button.clicked.connect(self.close)
self._tcp_server.newConnection.connect(self.send_fortune)
diff --git a/examples/network/googlesuggest/googlesuggest.py b/examples/network/googlesuggest/googlesuggest.py
index 3cb9f757d..d3fc67c05 100644
--- a/examples/network/googlesuggest/googlesuggest.py
+++ b/examples/network/googlesuggest/googlesuggest.py
@@ -120,12 +120,11 @@ class GSuggestCompletion(QObject):
@Slot(QNetworkReply)
def handle_network_data(self, network_reply: QNetworkReply):
- url = network_reply.url()
if network_reply.error() == QNetworkReply.NoError:
choices: List[str] = []
response: QByteArray = network_reply.readAll()
- xml = QXmlStreamReader(response)
+ xml = QXmlStreamReader(str(response))
while not xml.atEnd():
xml.readNext()
if xml.tokenType() == QXmlStreamReader.StartElement:
diff --git a/examples/network/threadedfortuneserver/threadedfortuneserver.py b/examples/network/threadedfortuneserver/threadedfortuneserver.py
index 60900708e..c75e2bc57 100644
--- a/examples/network/threadedfortuneserver/threadedfortuneserver.py
+++ b/examples/network/threadedfortuneserver/threadedfortuneserver.py
@@ -7,11 +7,11 @@
import random
from PySide6.QtCore import (Signal, QByteArray, QDataStream, QIODevice,
- QThread, Qt)
+ QThread, Qt)
from PySide6.QtWidgets import (QApplication, QDialog, QHBoxLayout, QLabel,
- QMessageBox, QPushButton, QVBoxLayout)
+ QMessageBox, QPushButton, QVBoxLayout)
from PySide6.QtNetwork import (QHostAddress, QNetworkInterface, QTcpServer,
- QTcpSocket)
+ QTcpSocket)
class FortuneThread(QThread):
@@ -75,7 +75,7 @@ class Dialog(QDialog):
if not self.server.listen():
reason = self.server.errorString()
QMessageBox.critical(self, "Threaded Fortune Server",
- f"Unable to start the server: {reason}.")
+ f"Unable to start the server: {reason}.")
self.close()
return
@@ -89,7 +89,7 @@ class Dialog(QDialog):
port = self.server.serverPort()
status_label.setText(f"The server is running on\n\nIP: {ip_address}\nport: {port}\n\n"
- "Run the Fortune Client example now.")
+ "Run the Fortune Client example now.")
quit_button.clicked.connect(self.close)