cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

pywin32 - GetCollection vs. GetSelection

gubaer
Super Contributor

consider this trivial python script which retrievs the number of "Anwendungen" (applications) from MEGA:

 

import win32com.client.dynamic as w32

 

def main():
    env = w32.Dispatch("MegaRepository.CurrentEnv")
    root = env.GetRoot()
    col = root.GetCollection("Anwendung")

    # works fine
    print("GetCollection: # Anwendungen = %s" % col.Count)

 

    col = root.GetSelection("Select [Anwendung]")
    # fails, because Count isn't a known attribute
    print("GetSelection: # Anwendungen = %s" % col.Count)

 

if __name__ == '__main__':
    main()

 

Isn't GetSelection supposed to return a MegaCollection with an attribute Count, too?

 

3 Replies

Hello gubaer

 

For your information, MEGA Support is not aware of another customer using Pyhton

For quick administration scripts, most developpers use VB script

Jerome

gubaer
Super Contributor

Yes, this works fine in VBScript (in my case from within Excel). 

 

My findings after playing around with pywin32: pywin32 isn't compatible with the way MEGA provides COM objects. Don't know why exactly, but pywin32 can't deal with them. That's a pity because I'd like to use Python for my day to day quick and dirty scripts.

 

SVanSchoonlandt
Honored Contributor

Indeed, GetSelection returns a MegaCollection on which you can use the count.

 

In vbscript this works fine, I don't know phyton so I can not tell if it is something in the code