aboutsummaryrefslogtreecommitdiffstats
path: root/examples/network
diff options
context:
space:
mode:
authorMatti Airas <matti.p.airas@nokia.com>2010-08-27 18:34:35 +0300
committerMatti Airas <matti.p.airas@nokia.com>2010-09-02 16:30:33 +0300
commitb5c22fb55c33e1fe2b348e6ea379a3cb7df841e0 (patch)
tree7eb3c7e29f85c498fbf8561d4294312385f83ec4 /examples/network
parentddfbe1581100b8a02483eae2330fc94d2ff7fa2e (diff)
fixed fortuneserver.py
Diffstat (limited to 'examples/network')
-rwxr-xr-xexamples/network/fortuneserver.py29
1 files changed, 15 insertions, 14 deletions
diff --git a/examples/network/fortuneserver.py b/examples/network/fortuneserver.py
index b0a7ee4..1725715 100755
--- a/examples/network/fortuneserver.py
+++ b/examples/network/fortuneserver.py
@@ -18,23 +18,24 @@ class Server(QtGui.QDialog):
self.tcpServer = QtNetwork.QTcpServer(self)
if not self.tcpServer.listen():
QtGui.QMessageBox.critical(self, self.tr("Fortune Server"),
- self.tr("Unable to start the server: %1.")
- .arg(self.tcpServer.errorString()))
+ self.tr("Unable to start the server: %(error)s.")
+ % {'error': self.tcpServer.errorString()})
self.close()
return
- self.statusLabel.setText(self.tr("The server is running on port %1.\n"
+ self.statusLabel.setText(self.tr("The server is running on port %(port)d.\n"
"Run the Fortune Client example now.")
- .arg(self.tcpServer.serverPort()))
-
- self.fortunes = QtCore.QStringList()
- (self.fortunes << self.tr("You've been leading a dog's life. Stay off the furniture.")
- << self.tr("You've got to think about tomorrow.")
- << self.tr("You will be surprised by a loud noise.")
- << self.tr("You will feel hungry again in another hour.")
- << self.tr("You might have mail.")
- << self.tr("You cannot kill time without injuring eternity.")
- << self.tr("Computers are not intelligent. They only think they are."))
+ % {'port': self.tcpServer.serverPort()})
+
+ self.fortunes = [
+ self.tr("You've been leading a dog's life. Stay off the furniture."),
+ self.tr("You've got to think about tomorrow."),
+ self.tr("You will be surprised by a loud noise."),
+ self.tr("You will feel hungry again in another hour."),
+ self.tr("You might have mail."),
+ self.tr("You cannot kill time without injuring eternity."),
+ self.tr("Computers are not intelligent. They only think they are."),
+ ]
self.connect(self.quitButton, QtCore.SIGNAL("clicked()"), self, QtCore.SLOT("close()"))
self.connect(self.tcpServer, QtCore.SIGNAL("newConnection()"), self.sendFortune)
@@ -55,7 +56,7 @@ class Server(QtGui.QDialog):
out = QtCore.QDataStream(block, QtCore.QIODevice.WriteOnly)
out.setVersion(QtCore.QDataStream.Qt_4_0)
out.writeUInt16(0)
- out << self.fortunes[random.randint(0, self.fortunes.count() - 1)]
+ out.writeString(self.fortunes[random.randint(0, len(self.fortunes) - 1)])
out.device().seek(0)
out.writeUInt16(block.size() - 2)