Python论坛  - 讨论区

标题:[python-chinese] 请教twisted.mail.pop3.AdvancedPOP3Client的用

2005年08月18日 星期四 15:37

Leo Jay python.leojay at gmail.com
Thu Aug 18 15:37:04 HKT 2005

我想从POP3服务器上得到email的信息,以面的程序出错。

from __future__ import generators

from twisted.internet.defer import deferredGenerator as dg,
waitForDeferred as wfd
from twisted.internet import protocol, reactor
from twisted.mail import pop3

class MyPOP3Client(pop3.AdvancedPOP3Client):
        
    def connectionMade(self):
        pop3.AdvancedPOP3Client.connectionMade(self)
        d = wfd(self.login('leojay, '123'))
        yield d
        print d.getResult()

        d = wfd(self.listSize())
        yield d
        print d.getResult()

    def connectionLost(self, reason):
        print reason
        reactor.stop()


def main():
    f = protocol.ClientFactory()
    f.protocol = MyPOP3Client
    reactor.connectTCP('localhost', 110, f)
    reactor.run()

if __name__ == '__main__':
    main()


出错信息为:
Traceback (most recent call last):
  File "D:\Python\Python24\Lib\site-packages\twisted\python\log.py",
line 56, in callWithLogger
    return callWithContext({"system": lp}, func, *args, **kw)
  File "D:\Python\Python24\Lib\site-packages\twisted\python\log.py",
line 41, in callWithContext
    return context.call({ILogContext: newCtx}, func, *args, **kw)
  File "D:\Python\Python24\Lib\site-packages\twisted\python\context.py",
line 52, in callWithContext
    return self.currentContext().callWithContext(ctx, func, *args, **kw)
  File "D:\Python\Python24\Lib\site-packages\twisted\python\context.py",
line 31, in callWithContext
    return func(*args,**kw)
---  ---
  File "D:\Python\Python24\Lib\site-packages\twisted\internet\selectreactor.py",
line 139, in _doReadOrWrite
    why = getattr(selectable, method)()
  File "D:\Python\Python24\Lib\site-packages\twisted\internet\tcp.py",
line 351, in doRead
    return self.protocol.dataReceived(data)
  File "D:\Python\Python24\Lib\site-packages\twisted\protocols\basic.py",
line 149, in dataReceived
    self.lineReceived(line)
  File "D:\Python\Python24\Lib\site-packages\twisted\mail\pop3client.py",
line 190, in lineReceived
    state = self.state
exceptions.AttributeError: MyPOP3Client instance has no attribute 'state'
[Failure instance: Traceback (failure with no frames):
exceptions.AttributeError: MyPOP3Client instance has no attribute
'state'
]

请问,正确的twisted.mail.pop3.AdvancedPOP3Client的用法是什么?我的方法不对吗?

-- 
Best Regards,
Leo Jay

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2005年08月19日 星期五 10:27

Leo Jay python.leojay at gmail.com
Fri Aug 19 10:27:00 HKT 2005

没有人要理我吗?

麻烦哪位帮帮我呀。
谢谢了

-- 
Best Regards,
Leo Jay

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2005年08月19日 星期五 10:39

梅劲松  stephen.cn at gmail.com
Fri Aug 19 10:39:09 HKT 2005

建议你提出详细具体的问题,如果你是想让人告诉你源代码,请到 google试看看你的运气。

在 05-8-19,Leo Jay<python.leojay at gmail.com> 写道:
> 没有人要理我吗?
> 
> 麻烦哪位帮帮我呀。
> 谢谢了
> 
> --
> Best Regards,
> Leo Jay
> 
> _______________________________________________
> python-chinese list
> python-chinese at lists.python.cn
> http://python.cn/mailman/listinfo/python-chinese
> 
> 
> 


-- 
梅劲松

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2005年08月19日 星期五 13:12

Leo Jay python.leojay at gmail.com
Fri Aug 19 13:12:23 HKT 2005

我写了呀,你没收到吗?

这是我昨天下午发到mailing list的email:
On 8/18/05, Leo Jay <python.leojay at gmail.com> wrote:
> 我想从POP3服务器上得到email的信息,以面的程序出错。
> 
> from __future__ import generators
> 
> from twisted.internet.defer import deferredGenerator as dg,
> waitForDeferred as wfd
> from twisted.internet import protocol, reactor
> from twisted.mail import pop3
> 
> class MyPOP3Client(pop3.AdvancedPOP3Client):
> 
>    def connectionMade(self):
>        pop3.AdvancedPOP3Client.connectionMade(self)
>        d = wfd(self.login('leojay, '123'))
>        yield d
>        print d.getResult()
> 
>        d = wfd(self.listSize())
>        yield d
>        print d.getResult()
> 
>    def connectionLost(self, reason):
>        print reason
>        reactor.stop()
> 
> 
> def main():
>    f = protocol.ClientFactory()
>    f.protocol = MyPOP3Client
>    reactor.connectTCP('localhost', 110, f)
>    reactor.run()
> 
> if __name__ == '__main__':
>    main()
> 
> 
> 出错信息为:
> Traceback (most recent call last):
>  File "D:\Python\Python24\Lib\site-packages\twisted\python\log.py",
> line 56, in callWithLogger
>    return callWithContext({"system": lp}, func, *args, **kw)
>  File "D:\Python\Python24\Lib\site-packages\twisted\python\log.py",
> line 41, in callWithContext
>    return context.call({ILogContext: newCtx}, func, *args, **kw)
>  File "D:\Python\Python24\Lib\site-packages\twisted\python\context.py",
> line 52, in callWithContext
>    return self.currentContext().callWithContext(ctx, func, *args, **kw)
>  File "D:\Python\Python24\Lib\site-packages\twisted\python\context.py",
> line 31, in callWithContext
>    return func(*args,**kw)
> ---  ---
>  File "D:\Python\Python24\Lib\site-packages\twisted\internet\selectreactor.py",
> line 139, in _doReadOrWrite
>    why = getattr(selectable, method)()
>  File "D:\Python\Python24\Lib\site-packages\twisted\internet\tcp.py",
> line 351, in doRead
>    return self.protocol.dataReceived(data)
>  File "D:\Python\Python24\Lib\site-packages\twisted\protocols\basic.py",
> line 149, in dataReceived
>    self.lineReceived(line)
>  File "D:\Python\Python24\Lib\site-packages\twisted\mail\pop3client.py",
> line 190, in lineReceived
>    state = self.state
> exceptions.AttributeError: MyPOP3Client instance has no attribute 'state'
> [Failure instance: Traceback (failure with no frames):
> exceptions.AttributeError: MyPOP3Client instance has no attribute
> 'state'
> ]
> 
> 请问,正确的twisted.mail.pop3.AdvancedPOP3Client的用法是什么?我的方法不对吗?
> 
> --
> Best Regards,
> Leo Jay
> 


On 8/19/05, 梅劲松 <stephen.cn at gmail.com> wrote:
> 建议你提出详细具体的问题,如果你是想让人告诉你源代码,请到 google试看看你的运气。

-- 
Best Regards,
Leo Jay

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2005年08月19日 星期五 13:41

梅劲松  stephen.cn at gmail.com
Fri Aug 19 13:41:30 HKT 2005

state在哪里没看到,是你的pop3client.py的问题,

在 05-8-19,Leo Jay<python.leojay at gmail.com> 写道:
> 我写了呀,你没收到吗?
> 
> 这是我昨天下午发到mailing list的email:
> On 8/18/05, Leo Jay <python.leojay at gmail.com> wrote:
> > 我想从POP3服务器上得到email的信息,以面的程序出错。
> >
> > from __future__ import generators
> >
> > from twisted.internet.defer import deferredGenerator as dg,
> > waitForDeferred as wfd
> > from twisted.internet import protocol, reactor
> > from twisted.mail import pop3
> >
> > class MyPOP3Client(pop3.AdvancedPOP3Client):
> >
> >    def connectionMade(self):
> >        pop3.AdvancedPOP3Client.connectionMade(self)
> >        d = wfd(self.login('leojay, '123'))
> >        yield d
> >        print d.getResult()
> >
> >        d = wfd(self.listSize())
> >        yield d
> >        print d.getResult()
> >
> >    def connectionLost(self, reason):
> >        print reason
> >        reactor.stop()
> >
> >
> > def main():
> >    f = protocol.ClientFactory()
> >    f.protocol = MyPOP3Client
> >    reactor.connectTCP('localhost', 110, f)
> >    reactor.run()
> >
> > if __name__ == '__main__':
> >    main()
> >
> >
> > 出错信息为:
> > Traceback (most recent call last):
> >  File "D:\Python\Python24\Lib\site-packages\twisted\python\log.py",
> > line 56, in callWithLogger
> >    return callWithContext({"system": lp}, func, *args, **kw)
> >  File "D:\Python\Python24\Lib\site-packages\twisted\python\log.py",
> > line 41, in callWithContext
> >    return context.call({ILogContext: newCtx}, func, *args, **kw)
> >  File "D:\Python\Python24\Lib\site-packages\twisted\python\context.py",
> > line 52, in callWithContext
> >    return self.currentContext().callWithContext(ctx, func, *args, **kw)
> >  File "D:\Python\Python24\Lib\site-packages\twisted\python\context.py",
> > line 31, in callWithContext
> >    return func(*args,**kw)
> > ---  ---
> >  File "D:\Python\Python24\Lib\site-packages\twisted\internet\selectreactor.py",
> > line 139, in _doReadOrWrite
> >    why = getattr(selectable, method)()
> >  File "D:\Python\Python24\Lib\site-packages\twisted\internet\tcp.py",
> > line 351, in doRead
> >    return self.protocol.dataReceived(data)
> >  File "D:\Python\Python24\Lib\site-packages\twisted\protocols\basic.py",
> > line 149, in dataReceived
> >    self.lineReceived(line)
> >  File "D:\Python\Python24\Lib\site-packages\twisted\mail\pop3client.py",
> > line 190, in lineReceived
> >    state = self.state
> > exceptions.AttributeError: MyPOP3Client instance has no attribute 'state'
> > [Failure instance: Traceback (failure with no frames):
> > exceptions.AttributeError: MyPOP3Client instance has no attribute
> > 'state'
> > ]
> >
> > 请问,正确的twisted.mail.pop3.AdvancedPOP3Client的用法是什么?我的方法不对吗?
> >
> > --
> > Best Regards,
> > Leo Jay
> >
> 
> 
> On 8/19/05, 梅劲松 <stephen.cn at gmail.com> wrote:
> > 建议你提出详细具体的问题,如果你是想让人告诉你源代码,请到 google试看看你的运气。
> 
> --
> Best Regards,
> Leo Jay
> 
> _______________________________________________
> python-chinese list
> python-chinese at lists.python.cn
> http://python.cn/mailman/listinfo/python-chinese
> 
> 
> 


-- 
梅劲松

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2005年08月19日 星期五 14:39

Leo Jay python.leojay at gmail.com
Fri Aug 19 14:39:36 HKT 2005

On 8/19/05, 梅劲松 <stephen.cn at gmail.com> wrote:
> state在哪里没看到,是你的pop3client.py的问题,
> 

我的pop3client.py的问题?
你是说我要重新装一遍twisted?

-- 
Best Regards,
Leo Jay

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2005年08月21日 星期日 13:59

梅劲松  stephen.cn at gmail.com
Sun Aug 21 13:59:31 HKT 2005

看到有个state的属性错误.

在 05-8-19,Leo Jay<python.leojay at gmail.com> 写道:
> On 8/19/05, 梅劲松 <stephen.cn at gmail.com> wrote:
> > state在哪里没看到,是你的pop3client.py的问题,
> >
> 
> 我的pop3client.py的问题?
> 你是说我要重新装一遍twisted?
> 
> --
> Best Regards,
> Leo Jay
> 
> _______________________________________________
> python-chinese list
> python-chinese at lists.python.cn
> http://python.cn/mailman/listinfo/python-chinese
> 
> 
> 


-- 
梅劲松

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2005年08月21日 星期日 20:13

Leo Jay python.leojay at gmail.com
Sun Aug 21 20:13:17 HKT 2005

D:\Python\Python24\Lib\site-packages\twisted\mail\pop3client.py是twisted自带的呀。不管我的事呀。

我重装了twisted也不行,还是一样的。 :(
是我的程序的问题吗?

源代码如下:

from __future__ import generators

from twisted.internet.defer import deferredGenerator as dg,
waitForDeferred as wfd
from twisted.internet import protocol, reactor
from twisted.mail import pop3

class MyPOP3Client(pop3.AdvancedPOP3Client):
        
    def connectionMade(self):
        d = wfd(self.login('leojay at leojay.com', '353'))
        yield d
        print d.getResult()

        d = wfd(self.listSize())
        yield d
        print d.getResult()

    def connectionLost(self, reason):
        print reason
        reactor.stop()


def main():
    f = protocol.ClientFactory()
    f.protocol = MyPOP3Client
    reactor.connectTCP('localhost', 110, f)
    reactor.run()

if __name__ == '__main__':
    main()




On 8/21/05, 梅劲松 <stephen.cn at gmail.com> wrote:
> 看到有个state的属性错误.
> 

-- 
Best Regards,
Leo Jay

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2005年08月22日 星期一 11:24

梅劲松  stephen.cn at gmail.com
Mon Aug 22 11:24:18 HKT 2005

你的程序在import的时候就报告,本来想帮你看一下的。


Traceback (most recent call last):
  File "C:\Documents and Settings\stephen\桌面\mail.py", line 2, in ?
    from twisted.internet.defer import deferredGenerator as
dg,waitForDeferred as wfd
ImportError: cannot import name deferredGenerator



在 05-8-21,Leo Jay<python.leojay at gmail.com> 写道:
> D:\Python\Python24\Lib\site-packages\twisted\mail\pop3client.py是twisted自带的呀。不管我的事呀。
> 
> 我重装了twisted也不行,还是一样的。 :(
> 是我的程序的问题吗?
> 
> 源代码如下:
> 
> from __future__ import generators
> 
> from twisted.internet.defer import deferredGenerator as dg,
> waitForDeferred as wfd
> from twisted.internet import protocol, reactor
> from twisted.mail import pop3
> 
> class MyPOP3Client(pop3.AdvancedPOP3Client):
> 
>    def connectionMade(self):
>        d = wfd(self.login('leojay at leojay.com', '353'))
>        yield d
>        print d.getResult()
> 
>        d = wfd(self.listSize())
>        yield d
>        print d.getResult()
> 
>    def connectionLost(self, reason):
>        print reason
>        reactor.stop()
> 
> 
> def main():
>    f = protocol.ClientFactory()
>    f.protocol = MyPOP3Client
>    reactor.connectTCP('localhost', 110, f)
>    reactor.run()
> 
> if __name__ == '__main__':
>    main()
> 
> 
> 
> 
> On 8/21/05, 梅劲松 <stephen.cn at gmail.com> wrote:
> > 看到有个state的属性错误.
> >
> 
> --
> Best Regards,
> Leo Jay
> 
> _______________________________________________
> python-chinese list
> python-chinese at lists.python.cn
> http://python.cn/mailman/listinfo/python-chinese
> 
> 
> 


-- 
梅劲松

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2005年08月22日 星期一 11:33

Leo Jay python.leojay at gmail.com
Mon Aug 22 11:33:26 HKT 2005

你的是什么版本的twisted?我的是2.0.1版本的。
我出的错是:
Traceback (most recent call last):
  File "D:\Python\Python24\Lib\site-packages\twisted\python\log.py",
line 56, in callWithLogger
    return callWithContext({"system": lp}, func, *args, **kw)
  File "D:\Python\Python24\Lib\site-packages\twisted\python\log.py",
line 41, in callWithContext
    return context.call({ILogContext: newCtx}, func, *args, **kw)
  File "D:\Python\Python24\Lib\site-packages\twisted\python\context.py",
line 52, in callWithContext
    return self.currentContext().callWithContext(ctx, func, *args, **kw)
  File "D:\Python\Python24\Lib\site-packages\twisted\python\context.py",
line 31, in callWithContext
    return func(*args,**kw)
---  ---
  File "D:\Python\Python24\Lib\site-packages\twisted\internet\selectreactor.py",
line 139, in _doReadOrWrite
    why = getattr(selectable, method)()
  File "D:\Python\Python24\Lib\site-packages\twisted\internet\tcp.py",
line 351, in doRead
    return self.protocol.dataReceived(data)
  File "D:\Python\Python24\Lib\site-packages\twisted\protocols\basic.py",
line 149, in dataReceived
    self.lineReceived(line)
  File "D:\Python\Python24\Lib\site-packages\twisted\mail\pop3client.py",
line 190, in lineReceived
    state = self.state
exceptions.AttributeError: MyPOP3Client instance has no attribute 'state'
[Failure instance: Traceback (failure with no frames):
exceptions.AttributeError: MyPOP3Client instance has no attribute
'state'
]


On 8/22/05, 梅劲松 <stephen.cn at gmail.com> wrote:
> 你的程序在import的时候就报告,本来想帮你看一下的。
> 
> 
> Traceback (most recent call last):
>  File "C:\Documents and Settings\stephen\桌面\mail.py", line 2, in ?
>    from twisted.internet.defer import deferredGenerator as
> dg,waitForDeferred as wfd
> ImportError: cannot import name deferredGenerator
> 
> 


-- 
Best Regards,
Leo Jay

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

如下红色区域有误,请重新填写。

    你的回复:

    请 登录 后回复。还没有在Zeuux哲思注册吗?现在 注册 !

    Zeuux © 2025

    京ICP备05028076号