使用 msn 协议运行twisted.words 示例时出现问题

发布于 2024-07-17 13:04:20 字数 3095 浏览 14 评论 0原文

我目前正在尝试使用 Twisted 库专门扭曲单词来尝试与 MSN 进行交互。 但是,当我运行twisted提供的示例脚本时,出现错误。 具体来说,错误可以在这里找到 http://i42.tinypic.com/wl945w.jpg 。 该脚本可以在这里找到 http://twistedmatrix.com/projects/words /documentation/examples/msn_example.py

平台是带有 Python 2.6 的 Vista

编辑:完整输出:

Email (passport): [email protected]
Password: ******
2009-04-25 10:52:49-0300 [-] Log opened.
2009-04-25 10:52:49-0300 [-] Starting factory <twisted.internet.protocol.ClientFactory instance at 0x9d87e8c>
2009-04-25 10:52:55-0300 [Dispatch,client] Starting factory <twisted.words.protocols.msn.NotificationFactory instance at 0x9e28bcc>
2009-04-25 10:52:55-0300 [Dispatch,client] Stopping factory <twisted.internet.protocol.ClientFactory instance at 0x9d87e8c>
2009-04-25 10:52:55-0300 [Notification,client] Unhandled Error
    Traceback (most recent call last):
      File "/usr/local/lib/python2.5/site-packages/twisted/python/log.py", line 84, in callWithLogger
        return callWithContext({"system": lp}, func, *args, **kw)
      File "/usr/local/lib/python2.5/site-packages/twisted/python/log.py", line 69, in callWithContext
        return context.call({ILogContext: newCtx}, func, *args, **kw)
      File "/usr/local/lib/python2.5/site-packages/twisted/python/context.py", line 59, in callWithContext
        return self.currentContext().callWithContext(ctx, func, *args, **kw)
      File "/usr/local/lib/python2.5/site-packages/twisted/python/context.py", line 37, in callWithContext
        return func(*args,**kw)
    --- <exception caught here> ---
      File "/usr/local/lib/python2.5/site-packages/twisted/internet/selectreactor.py", line 146, in _doReadOrWrite
        why = getattr(selectable, method)()
      File "/usr/local/lib/python2.5/site-packages/twisted/internet/tcp.py", line 460, in doRead
        return self.protocol.dataReceived(data)
      File "/usr/local/lib/python2.5/site-packages/twisted/protocols/basic.py", line 238, in dataReceived
        why = self.lineReceived(line)
      File "/usr/local/lib/python2.5/site-packages/twisted/words/protocols/msn.py", line 651, in lineReceived
        handler(params.split())
      File "/usr/local/lib/python2.5/site-packages/twisted/words/protocols/msn.py", line 827, in handle_USR
        d = _login(f.userHandle, f.password, f.passportServer, authData=params[3])
      File "/usr/local/lib/python2.5/site-packages/twisted/words/protocols/msn.py", line 182, in _login
        reactor.connectSSL(_parsePrimitiveHost(nexusServer)[0], 443, fac, ClientContextFactory())
    exceptions.TypeError: 'NoneType' object is not callable

2009-04-25 10:52:55-0300 [Notification,client] Stopping factory <twisted.words.protocols.msn.NotificationFactory instance at 0x9e28bcc>

I am currently trying to use the Twisted library specifically twisted words to try and interat with MSN. However when i run the sample script provided by twisted , i get an error. Specifically the error is found here http://i42.tinypic.com/wl945w.jpg . The script can be found over here http://twistedmatrix.com/projects/words/documentation/examples/msn_example.py.

Platform is Vista with Python 2.6

EDIT: Full output:

Email (passport): [email protected]
Password: ******
2009-04-25 10:52:49-0300 [-] Log opened.
2009-04-25 10:52:49-0300 [-] Starting factory <twisted.internet.protocol.ClientFactory instance at 0x9d87e8c>
2009-04-25 10:52:55-0300 [Dispatch,client] Starting factory <twisted.words.protocols.msn.NotificationFactory instance at 0x9e28bcc>
2009-04-25 10:52:55-0300 [Dispatch,client] Stopping factory <twisted.internet.protocol.ClientFactory instance at 0x9d87e8c>
2009-04-25 10:52:55-0300 [Notification,client] Unhandled Error
    Traceback (most recent call last):
      File "/usr/local/lib/python2.5/site-packages/twisted/python/log.py", line 84, in callWithLogger
        return callWithContext({"system": lp}, func, *args, **kw)
      File "/usr/local/lib/python2.5/site-packages/twisted/python/log.py", line 69, in callWithContext
        return context.call({ILogContext: newCtx}, func, *args, **kw)
      File "/usr/local/lib/python2.5/site-packages/twisted/python/context.py", line 59, in callWithContext
        return self.currentContext().callWithContext(ctx, func, *args, **kw)
      File "/usr/local/lib/python2.5/site-packages/twisted/python/context.py", line 37, in callWithContext
        return func(*args,**kw)
    --- <exception caught here> ---
      File "/usr/local/lib/python2.5/site-packages/twisted/internet/selectreactor.py", line 146, in _doReadOrWrite
        why = getattr(selectable, method)()
      File "/usr/local/lib/python2.5/site-packages/twisted/internet/tcp.py", line 460, in doRead
        return self.protocol.dataReceived(data)
      File "/usr/local/lib/python2.5/site-packages/twisted/protocols/basic.py", line 238, in dataReceived
        why = self.lineReceived(line)
      File "/usr/local/lib/python2.5/site-packages/twisted/words/protocols/msn.py", line 651, in lineReceived
        handler(params.split())
      File "/usr/local/lib/python2.5/site-packages/twisted/words/protocols/msn.py", line 827, in handle_USR
        d = _login(f.userHandle, f.password, f.passportServer, authData=params[3])
      File "/usr/local/lib/python2.5/site-packages/twisted/words/protocols/msn.py", line 182, in _login
        reactor.connectSSL(_parsePrimitiveHost(nexusServer)[0], 443, fac, ClientContextFactory())
    exceptions.TypeError: 'NoneType' object is not callable

2009-04-25 10:52:55-0300 [Notification,client] Stopping factory <twisted.words.protocols.msn.NotificationFactory instance at 0x9e28bcc>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

烟沫凡尘 2024-07-24 13:04:20

由于 MSN 涉及 SSL 连接,因此您必须安装 pyOpenSSL 才能使用它。 看来你可能不知道。 不过,对于 Twisted 来说,这并不是报告这种缺失依赖关系的好方法。 我建议在 Twisted 问题跟踪器中提交票证以改进此报告。

Since MSN involves SSL connections, you must have pyOpenSSL installed in order to use it. It seems as though you probably do not. This isn't a very good way for Twisted to be reporting this missing dependency, though. I recommend filing a ticket in the Twisted issue tracker for improving this reporting.

守望孤独 2024-07-24 13:04:20

发生了什么

当您尝试调用 None 对象时,会出现此异常。 看看这个:

>>> a = str
>>> a() # it's ok, a string is a callable class
''
>>> a = None
>>> a() # it fails, None a special Singleton not meant to be called

Traceback (most recent call last):
  File "<pyshell#4>", line 1, in <module>
    a()
TypeError: 'NoneType' object is not callable

你能做什么

你不能这样猜测,所以你需要进行一些调试。

显然,最后一行(refactor.connectSSL ...)包含三个对象调用,其中一个对象是 None 。

如果您不喜欢调试器,您可以做的第一件事是获取该行的每个元素并在其之前添加:

assert object1 is None 
assert object2 is None

然后您将获得异常的来源。 然后检查一下为什么这个对象被设置为None。 您可能需要检查文档以了解在哪种情况下某些可能已初始化它的方法返回 None 。

愿力量...

What happened

This exception you get is when you try to call an object that is None. Check this out :

>>> a = str
>>> a() # it's ok, a string is a callable class
''
>>> a = None
>>> a() # it fails, None a special Singleton not meant to be called

Traceback (most recent call last):
  File "<pyshell#4>", line 1, in <module>
    a()
TypeError: 'NoneType' object is not callable

What you can do

You can't guess it like that, so you'll need to make some debugging.

Apparently, the last line (refactor.connectSSL...) contains three object calls, and one of the object is None.

The first thing you can do, if you are not into debuggers, if to take each element of the line and add, just before it :

assert object1 is None 
assert object2 is None

Then you'll have the source of your Exception. After that, check why is this object set to None. You'll probably have to check the doc to see in which case some method that may have initilized it returns None.

May the force...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文