Information for others who can view this topic.
To start all this, you will need to install pywin32, for example from here http://sourceforge.net/projects/pywin32/files/pywin32/Build216/
First of all you will need to import pywin32
'''@author: www.qcintegration.com @mailto:contact@qcintegration.com''' import pywintypes import win32com.client as w32c from win32com.client import gencache, DispatchWithEvents, constants
Then, as a second operation, I include here the action on entering the server
def connect_server(qc, server): '''Connect to QC server input = str(http adress) output = bool(connected) TRUE/FALSE ''' try: qc.InitConnectionEx(server); except: text = "Unable connect to Quality Center database: '%s'"%(server); return qc.Connected; def connect_login(qc, username, password): '''Login to QC server input = str(UserName), str(Password) output = bool(Logged) TRUE/FALSE ''' try: qc.Login(username, password); except pywintypes.com_error, err: text = unicode(err[2][2]); return qc.LoggedIn; def connect_project(qc, domainname, projectname): '''Connect to Project in QC server input = str(DomainName), str(ProjectName) output = bool(ProjectConnected) TRUE/FALSE ''' try: qc.Connect(domainname, projectname) except pywintypes.com_error, err: text = "Repository of project '%s' in domain '%s' doesn't exist or is not accessible. Please contact your Site Administrator"%(projectname, domainname); return qc.ProjectConnected;
The second way that will include the OTAapi dll file
def qc_instance(): '''Create QualityServer instance under variable qc input = None output = bool(True/False)''' qc= None; try: qc = w32c.Dispatch("TDApiole80.TDConnection"); text = "DLL QualityCenter file correctly Dispatched" return True, qc; except: return False, qc;
Then the main method of connecting to QCserver
def qcConnect(server, username, password, domainname, projectname): print("Getting QC running files"); status, qc = qc_instance(); if status: print("Connecting to QC server"); if connect_server(qc, server):
And in the end, how to execute all these methods in one place with an example of use
if __name__ == "__main__": server= r"http://qualitycenterServer:8080/qcbin" username= "alex_qc" password= "" domainname= "DEFAULT" projectname= "QualityCenter_Demo" connection_status, text = qcConnect(server, username, password, domainname, projectname); print "connection_status:", connection_status
In case of any questions mailto: contact@qcintegration.com or directly to the web page: http://www.qcintegration.com