I want to get file transfer progress info while files uploading to webdav server. I try to using WithEvents for set handler for Session object but it stops with error:
C:\Miniconda3\python.exe E:/backup_1c/winscp.py
Traceback (most recent call last):
File "E:/backup_1c/winscp.py", line 16, in <module>
wcpSession.open(winscp_session_option)
File "<COMObject WinSCP.Session>", line 2, in open
pywintypes.com_error: (-2147352567, 'Error.', (0, 'mscorlib', 'Member group not found. (Exception HRESULT: 0x80020003 (DISP_E_MEMBERNOTFOUND))', None, 0, -2147352573), None)
Process finished with exit code 1
Script code is:
# -*- coding: utf-8
import win32com.client as win32
class WinScp_ISessionEvents:
def OnFileTransferProgress(self, e):
print(e.FileProgress)
if __name__ == "__main__":
wcpSession = win32.dynamic.Dispatch('WinSCP.Session')
winscp_session_option = win32.dynamic.Dispatch('WinSCP.SessionOptions')
winscp_session_option.Protocol = 3
winscp_session_option.HostName = "webdav.yandex.ru/"
winscp_session_option.UserName = "user"
winscp_session_option.Password = "password"
win32.WithEvents(wcpSession, WinScp_ISessionEvents)
wcpSession.open(winscp_session_option)
wcpSession.PutFiles('E:\Exchange\File.xls', '/File.xls')
According to error message I have wrong function name in WinScp_ISessionEvents class, I have tried different names such as FileTransferProgress, Session_FileTransferProgress, wcpSession_FileTransferProgress, wcpSession_OnFileTransferProgress, and many many others.
The callstack shows a problem at the wcpSession.open
, not the win32.WithEvents
.
Isn't the problem that the method is .Open
, not .open
?
User contributions licensed under CC BY-SA 3.0