日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

python连接ALM

發布時間:2023/12/15 python 44 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python连接ALM 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

VBS腳本:

Public Function makeConnection(ByVal qcHostName$, qcDomain$, qcProject$, _
qcUser$, qcPassword$, Optional qcPort) As Boolean

'------------------------------------------------------------------------
' This routine makes the connection to the gobal TDConnection object
' (declared at the project level as Global tdc as TDConnection)
' and connects the user to the specified project.
'-----------------------------------------------------------------------
Dim qcServer As String
Const fName = "makeConnection" 'For error message

On Error GoTo makeConnectionErr
errmsg = ""

' Construct server argument using format:
' "http://server:port/qcbin"
qcServer = "http://" & qcHostName

If Not (IsMissing(qcPort)) Then
If Len(qcPort) > 0 Then qcServer = qcServer & ":" & qcPort
End If

qcServer = qcServer & "/qcbin"

' Check status (for demonstration purposes only).
' MsgBox tdc.LoggedIn 'Error: OTA Server is not connected
' MsgBox tdc.Connected 'False
' MsgBox tdc.ServerName 'Blank string

' Create the connection.
errmsg = "Failed to create TDConnection"
If (tdc Is Nothing) Then Set tdc = New TDConnection
If (tdc Is Nothing) Then GoTo makeConnectionErr
errmsg = ""

' Check status
' On Error Resume Next
' Debug.Print "Initial Status: "
' Debug.Print "LoggedIn", """" & tdc.LoggedIn & """"
' Debug.Print "LoggedIn Error", err.Description
' Debug.Print "Connected", """" & tdc.Connected & """"
' Debug.Print "ServerName", """" & tdc.ServerName & """"
' Debug.Print "ProjectName", """" & tdc.ProjectName & """"
' Debug.Print "ProjectName Error", err.Description
' Debug.Print "ProjectConnected", """" & tdc.ProjectConnected & """"
' Debug.Print "ProjectConnected Error", err.Description
' Debug.Print
' On Error GoTo makeConnectionErr
'
' Initial Status:
' LoggedIn Error OTA server is not connected.
' Connected "False"
' ServerName ""
' ProjectName Error OTA server is not connected.
' ProjectConnected Error OTA server is not connected.

tdc.InitConnectionEx qcServer
' Check status.
' On Error Resume Next
' Debug.Print "After InitConnectionEx: "
' Debug.Print "LoggedIn", """" & tdc.LoggedIn & """"
' Debug.Print "Connected", """" & tdc.Connected & """"
' Debug.Print "ServerName", """" & tdc.ServerName & """"
' Debug.Print "ProjectName", """" & tdc.ProjectName & """"
' Debug.Print "ProjectConnected", """" & tdc.ProjectConnected & """"
' Debug.Print
' On Error GoTo makeConnectionErr
''
'' After InitConnectionEx:
' LoggedIn "False"
' Connected "True"
' ServerName "http://server06/qcbin/wcomsrv.dll"
' ProjectName ""
' ProjectConnected "False"

' Log on to server.
tdc.Login qcUser, qcPassword

' Check status.
' Debug.Print "After Login: "
' Debug.Print "LoggedIn", """" & tdc.LoggedIn & """"
' Debug.Print "Connected", """" & tdc.Connected & """"
' Debug.Print "ServerName", """" & tdc.ServerName & """"
' Debug.Print "ProjectName", """" & tdc.ProjectName & """"
' Debug.Print "ProjectConnected", """" & tdc.ProjectConnected & """"
' Debug.Print
' After Login:
' LoggedIn "True"
' Connected "True"
' ServerName "http://server06/qcbin/wcomsrv.dll"
' ProjectName ""
' ProjectConnected "False"

' Connect to the project and user.
tdc.Connect qcDomain, qcProject

' Exit status.
' Debug.Print "After Connect: "
' Debug.Print "LoggedIn", """" & tdc.LoggedIn & """"
' Debug.Print "Connected", """" & tdc.Connected & """"
' Debug.Print "ServerName", """" & tdc.ServerName & """"
' Debug.Print "ProjectName", """" & tdc.ProjectName & """"
' Debug.Print "ProjectConnected", """" & tdc.ProjectConnected & """"
' Debug.Print
'
' After Connect:
' LoggedIn "True"
' Connected "True"
' ServerName "http://server06/qcbin/wcomsrv.dll"
' ProjectName "ota_doc"
' ProjectConnected "True"

makeConnection = True
Exit Function

makeConnectionErr:
makeConnection = False
ErrHandler err, fName, err.Description & vbCrLf & errmsg

End Function


Python腳本:

? ? def makeConnect(self):
? ? ? ? from win32com.client import Dispatch
? ? ? ? tdc = Dispatch("TDApiOle80.TDConnection") ? ?
? ? ? ? tdc.InitConnection(self.info['qcServer']) ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? #ALM服務器名,如:http://192.168.1.10:8080/qcbin
? ? ? ? tdc.Login(self.info['qcUser'],self.info['qcPassword']) ? ? ? ? ?#用戶名,密碼
? ? ? ? tdc.Connect(self.info['qcDomain'],self.info['qcProject']) ? ?#域,項目
? ? ? ? print tdc.Connected ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?#如果已連接,則為True,還有其它屬性,請參考VBS腳本

? ? ? ? return tdc

總結

以上是生活随笔為你收集整理的python连接ALM的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。