[python-win32] win32com confusion: PROPERTY with arguments vs.METHOD.
Mark Hammond
mhammond at skippinet.com.au
Sun Feb 11 13:36:56 CET 2007
If you can use makepy on your object, you should find 'SetRegister(args)'
works. Sadly, this isn't supported in objects without typelib support.
I've added the bones of this to the test suite, so let me know if you'd like
to help work on this...
Cheers,
Mark
> -----Original Message-----
> From: python-win32-bounces at python.org
> [mailto:python-win32-bounces at python.org]On Behalf Of bosch9y at arcor.de
> Sent: Friday, 9 February 2007 10:22 PM
> To: python-win32 at python.org
> Subject: [python-win32] win32com confusion: PROPERTY with arguments
> vs.METHOD.
>
>
> We use an IVI-COM Server for an Agilent power supply.
>
> The documentation defines "Status.Register" to be a PROPERTY,
> but also specifies arguments to be used when calling it
> (apparently a rare case we haven't come across before).
>
> Init code:
> >>> import win32com.client
> >>> o=win32com.client.Dispatch("AgilentN57xx.AgilentN57xx.1")
> >>> o.Initialize('UsbDevice1', False, True)
>
> It looks like "Status.Register" was a bound as a METHOD in win32com:
> >>> o.Status.Register
> <bound method CDispatch.Register of <COMObject <unknown>>>
>
> Trying to assign a value to it raises an exception:
> >>> o.Status.Register = 1
> Traceback (most recent call last):
> File "<interactive input>", line 1, in ?
> File
> "C:\Python23\Lib\site-packages\win32com\client\dynamic.py",
> line 543, in __setattr__
> raise AttributeError, "Property '%s.%s' can not be set." %
> (self._username_, attr)
> AttributeError: Property '<unknown>.Register' can not be set.
>
> The exception suggests that it really is a PROPERTY.
>
> Calling the "PROPERTY" as specified to read the power
> supply's status register (with main type=3, subtype=0) also
> raises an exception:
> >>> o.Status.Register(3,0)
> Traceback (most recent call last):
> File "<interactive input>", line 1, in ?
> File "<COMObject <unknown>>", line 2, in Register
> com_error: (-2147352573, 'Member not found.', None, None)
>
> We stepped through dynamic.py and it seems that 'win32com'
> gets confused in this case and mixes up METHOD and PROPERTY handling.
>
> All other COM METHODS and PROPERTIES work fine.
>
> Is this a win32com bug, or a misunderstanding on our part?
>
> Can anyone suggest a workaround?
>
> We use:
> PythonWin 2.3.5 (#62, Feb 9 2005, 16:17:08) [MSC v.1200 32
> bit (Intel)] on win32.
> Windows 2000
>
> Many thanks for your help !
>
>
> Fritz Bosch
>
> Please note that all mail to above address NOT originating
> from the list will be discarded.
> To reach me personally, replace '9' by '8'.
>
> Viel oder wenig? Schnell oder langsam? Unbegrenzt surfen +
> telefonieren
> ohne Zeit- und Volumenbegrenzung? DAS TOP ANGEBOT JETZT bei
> Arcor: günstig
> und schnell mit DSL - das All-Inclusive-Paket für clevere
> Doppel-Sparer,
> nur 44,85 inkl. DSL- und ISDN-Grundgebühr!
> http://www.arcor.de/rd/emf-dsl-2
> _______________________________________________
> Python-win32 mailing list
> Python-win32 at python.org
> http://mail.python.org/mailman/listinfo/python-win32
>
More information about the Python-win32
mailing list