Adopt COM-Server Wrapper from Python to Julia

Hi,

this morning I tried again to get it into operation in Python and today managed
to do it in the right manner:

import win32com.client
from os.path import exists as file_exists

IFileManager_Object = win32com.client.Dispatch("COM_ServerName")

FN_iFile = 'C:/data/data_log/Data_Types/iFile/iFile'

if (not file_exists(FN_iFile)):
    raise TypeError("File not found!")

COM_ServerObject.Open(FN_iFile)
n_channels = COM_ServerObject.GetChannelCount('')

If the documentation of your COM-Server is not complete, the python script makepy.py by “mhammond” helps to figure out which function are available.

The same code under Julia looks like this:

# Create COM server via Python Interface
# first: install "pywin32" via conda:
# using Conda; Conda.add("pywin32")

using PyCall
pwc = pyimport("win32com.client")

COM_ServerObject = pwc.Dispatch("COM_ServerName")

FN_iFile = raw"C:\data\data_log\Data_Types\iFile\ifile_name";
if ~isfile(FN_iFile)
    error("file \"" * FN_mat * "\" does not exist!\n")
end

COM_ServerObject.Open(FN_iFile);
n_channels = COM_ServerObject.GetChannelCount("")

1 Like