我正在运行位于以下位置的扭曲文档中的twisted.words msn协议示例:http://twistedmatrix.com/projects/words/documentation/examples/msn_example.py
我知道关于stackoverflow上的这个示例.py还有另一个问题,但这是一个完全不同的问题。当我运行该示例时,它的行为与预期一致。登录帐户并显示有关伙伴列表中用户的信息,但在完成此操作后,它会显示以下跟踪信息
> Traceback (most recent call last):
> File
> "c:\python26\lib\site-packages\twisted\python\log.py",
> line 84, in callWithLogger
> return callWithContext({"system": lp}, func, *args, **kw) File
> "c:\python26\lib\site-packages\twisted\python\log.py",
> line 69, in callWithContext
> return context.call({ILogContext: newCtx}, func, *args, **kw) File
> "c:\python26\lib\site-packages\twisted\python\context.py",
> line 59, in callWithContext
> return self.currentContext().callWithContext(ctx,
> func, *args, **kw) File
> "c:\python26\lib\site-packages\twisted\python\context.py",
> line 37, in callWithContext
> return func(*args,**kw)
> --- <exception caught here> --- File "c:\python26\lib\site-packages\twisted\internet\selectreactor.py",
> line 146, in _doReadOrWrite
> why = getattr(selectable, method)() File
> "c:\python26\lib\site-packages\twisted\internet\tcp.py",
> line 463, in doRead
> return self.protocol.dataReceived(data)
> File
> "c:\python26\lib\site-packages\twisted\protocols\basic.py", line 239, indataReceived
> return self.rawDataReceived(data) File
> "c:\python26\lib\site-packages\twisted\words\protocols\msn.py",
> line 676 in rawDataReceived
> self.gotMessage(m) File "c:\python26\lib\site-packages\twisted\words\protocols\msn.py",
> line 699, in gotMessage
> raise NotImplementedError exceptions.NotImplementedError:有人能帮我理解一下这是什么意思吗?
发布于 2009-08-25 07:10:32
它看起来像是改变了MSN服务器的操作方式,尽管它并不是真正意义上的协议改变。实际情况是,MSN服务器在客户端连接后立即向客户端发送一条消息,而Twisted words示例并未预料到这一点。
假设您正在从http://twistedmatrix.com/projects/words/documentation/examples/运行msn_example.py,您可以通过将以下代码添加到示例中(紧跟在listSynchronized函数的末尾)来运行该示例并查看发生了什么情况:
def gotMessage(self, message):
print message.headers
print message.getMessage()进行更改后,如果运行该示例,您应该会看到以下内容:
...
2009-08-25 00:03:23-0700 [Notification,client] {'Content-Type': 'text/x-msmsgsinitialemailnotification; charset=UTF-8', 'MIME-Version': '1.0'}
2009-08-25 00:03:23-0700 [Notification,client] Inbox-Unread: 1
2009-08-25 00:03:23-0700 [Notification,client] Folders-Unread: 0
2009-08-25 00:03:23-0700 [Notification,client] Inbox-URL: /cgi-bin/HoTMaiL
2009-08-25 00:03:23-0700 [Notification,client] Folders-URL: /cgi-bin/folders
2009-08-25 00:03:23-0700 [Notification,client] Post-URL: http://www.hotmail.com
2009-08-25 00:03:23-0700 [Notification,client]我们可以看到,服务器正在向客户端发送一条消息,其中指定了该帐户的未读电子邮件消息的数量。
希望这能有所帮助!
发布于 2009-08-07 13:48:12
gotMessage方法声称未实现。这很可能意味着您已经派生了一个子类,该类需要在子类中覆盖gotMessage,但是您还没有完成覆盖。
https://stackoverflow.com/questions/1244733
复制相似问题