Python 帕米的麻烦
我和帕米有点奇怪的麻烦 我已经编写了一个脚本,根据我在web上找到的recepie进行一些端口(25)转发,下面是重要的代码:Python 帕米的麻烦,python,debugging,pamie,Python,Debugging,Pamie,我和帕米有点奇怪的麻烦 我已经编写了一个脚本,根据我在web上找到的recepie进行一些端口(25)转发,下面是重要的代码: # forwardc2s(source, destination): # forwards from client to server. # Tries to post the message to ICE. def forwardc2s(source, destination): string = ' ' message = '
# forwardc2s(source, destination):
# forwards from client to server.
# Tries to post the message to ICE.
def forwardc2s(source, destination):
string = ' '
message = ''
while string:
string = source.recv(1024)
if string:
if string[:4] == 'DATA' or message <> '': # Put the entire text of the email into a variable: message
message = message + string
destination.sendall(string)
else:
posttotracker(message) # post message to tracker.
source.shutdown(socket.SHUT_RD)
destination.shutdown(socket.SHUT_WR)
这给了我一个错误,如下所示:
Unhandled exception in thread started by <function forwardc2s at 0x00E6C0B0>
Traceback (most recent call last):
File "main.py", line 2398, in forwardc2s
posttotracker(message) # post message to tracker.
File "main.py", line 2420, in posttotracker
ie = PAMIE('http://google.com/')
File "main.py", line 58, in __init__
self._ie = win32com.client.dynamic.Dispatch('InternetExplorer.Application')
File "c:\Python26\lib\site-packages\win32com\client\dynamic.py", line 112, in
Dispatch
IDispatch, userName = _GetGoodDispatchAndUserName(IDispatch,userName,clsctx)
File "c:\Python26\lib\site-packages\win32com\client\dynamic.py", line 104, in
_GetGoodDispatchAndUserName
return (_GetGoodDispatch(IDispatch, clsctx), userName)
File "c:\Python26\lib\site-packages\win32com\client\dynamic.py", line 84, in _
GetGoodDispatch
IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.II
D_IDispatch)
pywintypes.com_error: (-2147221008, 'CoInitialize has not been called.', None, N
one)
由启动的线程中未处理的异常
回溯(最近一次呼叫最后一次):
forwardc2s中的文件“main.py”,第2398行
posttotracker(消息)#将消息发布到跟踪器。
posttotracker中的文件“main.py”,第2420行
ie=PAMIE('http://google.com/')
文件“main.py”,第58行,在_init中__
self.\u ie=win32com.client.dynamic.Dispatch('InternetExplorer.Application'))
文件“c:\Python26\lib\site packages\win32com\client\dynamic.py”,第112行,在
派遣
IDispatch,userName=_GetGoodDispatchAndUserName(IDispatch,userName,clsctx)
文件“c:\Python26\lib\site packages\win32com\client\dynamic.py”,第104行,在
_GetGoodDispatchAndUserName
返回(_GetGoodDispatch(IDispatch,clsctx),用户名)
文件“c:\Python26\lib\site packages\win32com\client\dynamic.py”,第84行,在_
GetGoodDispatch
IDispatch=pythoncom.CoCreateInstance(IDispatch,None,clsctx,pythoncom.II
迪迪斯帕奇)
pywintypes.com_错误:(-2147221008,'尚未调用CoInitialize',无,N
一)
有趣的是,如果我在这个函数之外做了同样的事情(例如在主函数中),库就会完全按照预期工作
有什么想法吗
如果这些信息不够,请原谅,我只是一个初级python程序员。PAMIE对象在线程中不起作用强> 我最初是以线程的形式启动forwardc2s。当我把它作为函数调用时,一切都很好
请考虑这个问题解决了…非常感谢。PAMIE对象在线程中不工作强> 我最初是以线程的形式启动forwardc2s。当我把它作为函数调用时,一切都很好
请考虑这个问题解决了…非常感谢。哈哈,太棒了,如果没有这个=,我用谷歌搜索它的时间会比30秒长很多。)哈哈,现在是2012年,我再次用谷歌搜索这个问题,发现这个答案很有帮助,然后注意到我也留下了之前的评论。很棒的东西。哈哈,太棒了,如果没有这个=,我用谷歌搜索它的时间会比30秒长很多。)哈哈,现在是2012年,我再次用谷歌搜索了这个问题,发现这个答案很有帮助,然后注意到我也留下了之前的评论。好东西。
Unhandled exception in thread started by <function forwardc2s at 0x00E6C0B0>
Traceback (most recent call last):
File "main.py", line 2398, in forwardc2s
posttotracker(message) # post message to tracker.
File "main.py", line 2420, in posttotracker
ie = PAMIE('http://google.com/')
File "main.py", line 58, in __init__
self._ie = win32com.client.dynamic.Dispatch('InternetExplorer.Application')
File "c:\Python26\lib\site-packages\win32com\client\dynamic.py", line 112, in
Dispatch
IDispatch, userName = _GetGoodDispatchAndUserName(IDispatch,userName,clsctx)
File "c:\Python26\lib\site-packages\win32com\client\dynamic.py", line 104, in
_GetGoodDispatchAndUserName
return (_GetGoodDispatch(IDispatch, clsctx), userName)
File "c:\Python26\lib\site-packages\win32com\client\dynamic.py", line 84, in _
GetGoodDispatch
IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.II
D_IDispatch)
pywintypes.com_error: (-2147221008, 'CoInitialize has not been called.', None, N
one)