我正在使用rss2email
将一些 RSS 提要转换为邮件以便于使用。也就是说,我使用它是因为它今天以一种可怕的方式坏了:每次运行时,它只给我这个回溯:
Traceback (most recent call last):
File "/usr/share/rss2email/rss2email.py", line 740, in <module>
elif action == "list": list()
File "/usr/share/rss2email/rss2email.py", line 681, in list
feeds, feedfileObject = load(lock=0)
File "/usr/share/rss2email/rss2email.py", line 422, in load
feeds = pickle.load(feedfileObject)
TypeError: ("'str' object is not callable", 'sxOYAAuyzSx0WqN3BVPjE+6pgPU', ((2009, 3, 19, 1, 19, 31, 3, 78, 0), {}))
我能够从这个回溯中构建的唯一有用的事实是,保存其所有配置和运行时状态的文件以某种方式损坏~/.rss2email/feeds.dat
。rss2email
显然,rss2email
读取它的状态并cPickle
在每次运行时将其转储回去。
我什'sxOYAAuyzSx0WqN3BVPjE+6pgPU'
至在巨型 (>12MB)feeds.dat
文件中找到了包含上述字符串的行。在我未经训练的眼睛看来,转储似乎没有被截断或以其他方式损坏。
我可以尝试什么方法来重建文件?
Python 版本在 Debian/unstable 系统上为 2.5.4。
编辑
Peter Gibson 和 JF Sebastian 建议直接从 pickle 文件加载,我之前尝试过。显然,需要一个Feed
在 中定义的类rss2email.py
,所以这是我的脚本:
#!/usr/bin/python
import sys
# import pickle
import cPickle as pickle
sys.path.insert(0,"/usr/share/rss2email")
from rss2email import Feed
feedfile = open("feeds.dat", 'rb')
feeds = pickle.load(feedfile)
“普通”泡菜变体产生以下回溯:
Traceback (most recent call last):
File "./r2e-rescue.py", line 8, in <module>
feeds = pickle.load(feedfile)
File "/usr/lib/python2.5/pickle.py", line 1370, in load
return Unpickler(file).load()
File "/usr/lib/python2.5/pickle.py", line 858, in load
dispatch[key](self)
File "/usr/lib/python2.5/pickle.py", line 1133, in load_reduce
value = func(*args)
TypeError: 'str' object is not callable
该变体产生与调用自身cPickle
基本相同的东西
:r2e
Traceback (most recent call last):
File "./r2e-rescue.py", line 10, in <module>
feeds = pickle.load(feedfile)
TypeError: ("'str' object is not callable", 'sxOYAAuyzSx0WqN3BVPjE+6pgPU', ((2009, 3, 19, 1, 19, 31, 3, 78, 0), {}))
编辑 2
按照 JF Sebastian 的建议,将“printf 调试”放入Feed.__setstate__
我的测试脚本中,这些是 Python 退出前的最后几行。
u'http:/com/news.ars/post/20080924-everyone-declares-victory-in-smutfree-wireless-broadband-test.html': u'http:/com/news.ars/post/20080924-everyone-declares-victory-in-smutfree-wireless-broadband-test.html'},
'to': None,
'url': 'http://arstechnica.com/'}
Traceback (most recent call last):
File "./r2e-rescue.py", line 23, in ?
feeds = pickle.load(feedfile)
TypeError: ("'str' object is not callable", 'sxOYAAuyzSx0WqN3BVPjE+6pgPU', ((2009, 3, 19, 1, 19, 31, 3, 78, 0), {}))
同样的事情发生在使用 python 2.4.4-2 的 Debian/etch 盒子上。