diff options
author | Adrian Herrmann <adrian.herrmann@qt.io> | 2023-12-05 13:00:27 +0100 |
---|---|---|
committer | Adrian Herrmann <adrian.herrmann@qt.io> | 2023-12-06 11:52:07 +0100 |
commit | 592c734e57b00040329b49dfbe11869980dff88a (patch) | |
tree | 79fa3498cb974e5026415971ec83107b92b65919 /examples/network | |
parent | c0329cff9d7378b8bf6a17baeb97bf5a240977fc (diff) |
Examples: Fix a number of flake8 errors (part 1)
First batch, including low-hanging fruit like Alignments, whitespaces,
line length, indents, etc.
Pick-to: 6.6
Change-Id: I55966876077f7fddfdc82cbe376677af9995f329
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'examples/network')
4 files changed, 32 insertions, 33 deletions
diff --git a/examples/network/blockingfortuneclient/blockingfortuneclient.py b/examples/network/blockingfortuneclient/blockingfortuneclient.py index 816ef67f5..d0dd7e0ad 100644 --- a/examples/network/blockingfortuneclient/blockingfortuneclient.py +++ b/examples/network/blockingfortuneclient/blockingfortuneclient.py @@ -110,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") @@ -145,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: @@ -159,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/fortuneclient/fortuneclient.py b/examples/network/fortuneclient/fortuneclient.py index b695c2ea8..e88e5e35b 100644 --- a/examples/network/fortuneclient/fortuneclient.py +++ b/examples/network/fortuneclient/fortuneclient.py @@ -31,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) @@ -40,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) @@ -69,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) @@ -99,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 d84c9dcfd..a94a49f42 100644 --- a/examples/network/fortuneserver/fortuneserver.py +++ b/examples/network/fortuneserver/fortuneserver.py @@ -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/threadedfortuneserver/threadedfortuneserver.py b/examples/network/threadedfortuneserver/threadedfortuneserver.py index bb86d9081..c75e2bc57 100644 --- a/examples/network/threadedfortuneserver/threadedfortuneserver.py +++ b/examples/network/threadedfortuneserver/threadedfortuneserver.py @@ -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) |