SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 2 of 2
  1. #1
    Junior Member
    Join Date
    Nov 2010
    Posts
    3
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    QC COM interfaces with VAPI-XP-PYTHON

    Hi,

    I'm trying to use the IResourceStorage Interface of a QCResource instance in Python but it simply doesn't work (Python's complaining).

    Here's a little bit of vb code that just does what I want:

    Set oResource = TDConnection.QCResourceFactory
    Set oFilter = oResource.Filter

    oFilter.Filter("RSC_FILE_NAME") = "comms.py"

    Set oResourceList = oFilter.NewList

    If oResourceList.Count = 1 Then
    Set oFile = oResourceList.Item(1)
    TDOutput.Print oFile.FileName
    oFile.DownloadResource "", True
    End If

    It translates into (Python):

    oResource = TDConnection.QCResourceFactory
    oFilter = oResource.Filter
    oFilter.SetFilter("RSC_FILE_NAME", "comms.py")


    oResourceList = oFilter.NewList()

    if oResourceList.Count == 1:
    oFile = oResourceList.Item(1)
    TDOutput.Print(oFile.FileName)
    oFile.DownloadResource("", True) -> AttributeError: 'com_error' object has no attribute 'hresult' [Error] (L179: c0): Traceback (most recent call last): File "<Script Block >", line 179, in Test_Main
    oFile.DownloadResource("", True) File "C:\Python25\lib\site-packages\win32com\client\dynamic.py", line 503, in __getattr__ if details.hresult in ERRORS_BAD_CONTEXT:AttributeError: 'com_error' object has no attribute 'hresult'
    Test < resources > is completed.

    Then I have tried to manually get the IResourceStorage interface with the following code but it failed:
    myQCInterface = rsc._oleobj_.QueryInterface(pythoncom.IID_IResourc eStorage) # where rsc is a COM instance of QCResource
    --> [Error] (L64: c0): Traceback (most recent call last): File "<Script Block >", line 64, in Test_Main myQCInterface = rsc._oleobj_.QueryInterface(pythoncom.IID_IResourc eStorage) AttributeError: 'module' object has no attribute 'IID_IResourceStorage' [Error] (L64: c0): Traceback (most recent call last): File "<Script Block >", line 64, in Test_Main myQCInterface = rsc._oleobj_.QueryInterface(pythoncom.IID_IResourc eStorage) AttributeError: 'module' object has no attribute 'IID_IResourceStorage'

    I must add that I'm no Python expert but it seemed to me that if a COM object implements an interface I should be able to call the imethods as if they were public method of the object.

    Any help welcome and thank you in advance.

    Pat

  2. #2
    Junior Member
    Join Date
    Nov 2010
    Posts
    3
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: QC COM interfaces with VAPI-XP-PYTHON

    This is now resolved. I couldn't access the COM interfaces because I had another version of python installed on my computer (conflict).
    Fix:
    1/ uninstall all flavours of Python (even ActivePython)
    2/ reboot the computer
    3/ install ActivePyhton

    --> You're good to go

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Search Engine Optimisation provided by DragonByte SEO v2.0.36 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 12.50%
vBulletin Optimisation provided by vB Optimise v2.6.4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.2.8 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominate (Lite) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 04:28 PM.

Copyright BetaSoft Inc.