Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<h1>Example of using Python (win32com) to connect to HP Quality Center via OTA</h1> <p>HP Quality Center exposes a com based API called OTA.</p> <p>Documentation on this is downloadable from an QC server (OTA_API_Reference.chm) (Weirdly it is very hard to find online)</p> <p>The documentation uses VBScript (The officially supported internal language for QC) and you will need to mentally translate to Python. THis is usually very simple, but a couple of gotchas exist.</p> <p>You will need to install on your machine the Quality Center local code, this is on your windows PC if you have been able to get to QC through the web interface.</p> <p>You will also need to know the URL of the server and you username and password and the domain of the QC project you are working on.</p> <pre><code>from win32com.client import Dispatch conn = get_QCConnection() for bug in get_bugs(qcConn): print bug.Title put_QCConnection(conn) #below code needs to be in seperate module or at least above the fold but here # for clarity def get_QCConnection(): '''Get the hardcoded connection to the server and domain. Can be made a "real" engine if you try hard. Use makepy utility to determine if the version number has changed (TDApiOle80) but this works to current version''' QCConnection = Dispatch("TDApiOle80.TDConnection") url = "http://qc.example.com/qcbin" QCConnection.InitConnectionEx(url) QCConnection.login("USER", "PASS") QCConnection.Connect("google_projects", "Google_Chrome") return QCConnection def put_QCConnection(qcConn): #If one person logged in to QC changes *anything* on a bug, # they hold a global lock on writing to that bug till # thier session times out, so really really remember to logout # its painful to wait for your own session to time out qcConn.Logout() def get_bugs(qcConn): '''just following boiler plate from vbscript PS the SetFilter is not in QTA API, it uses Filter. But due to the workarounds in the very brilliant pythoncom code it supplies a virtual wrapper class called SetFilter - this is one of those gotchas ''' BugFactory = qcConn.BugFactory BugFilter = BugFactory.Filter BugFilter.SetFilter(u"Status", "New") #NB - a lot of fields in QC are malleable - and vary from site to site. #COntact your admins for a real list of fields you can adjust buglist = BugFilter.NewList() return buglist </code></pre> <p>This is not a bad basis for going forward, however I create a dummy class for defects and run something like:</p> <pre><code>dfcts = [defect(b) for b in buglist] </code></pre> <p>Then I can put worker code into defect class and keep things neater. One thing you want to do is keep access to the raw qc bug internal to the python wrapper class.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload