Topic "Session event handler through COM interface using pywin32"

Author Message
[View user's profile]

Joined: 2016-06-24
Posts: 1
Location: Kazakhstan
I try to use pywin32 to work with webdav server using COM interface. All work good, but now I want to see file transfer progress and try to handle FileTransferProgress event of session object. But with no luck.
Simple python 3.5 script:
# -*- coding: utf-8
import win32com.client as win32

class WinScp_ISessionEvents:
    def OnFileTransferProgress(self, e):

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 = ""
    winscp_session_option.UserName = "user"
    winscp_session_option.Password = "password"
    win32.WithEvents(wcpSession, WinScp_ISessionEvents)
    wcpSession.PutFiles('E:\Exchange\File.xls', '/File.xls')

its crash with error:
C:\Miniconda3\python.exe E:/backup_1c/
Traceback (most recent call last):
  File "E:/backup_1c/", line 16, in <module>
  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

According to error message the problem is wrong function name in WinScp_ISessionEvents class. I have tried a lot of name variants such as OnFileTransferProgress, FileTransferProgress, Session_OnFileTransferProgress, Session_FileTransferProgress, etc. But error still raised.
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 27106
Location: Prague, Czechia
Your duplicate post on Stack Overflow:

You can post new topics in this forum


What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!


About donations

$9   $19   $49   $99

About donations


WinSCP Privacy Policy

WinSCP License