本文整理匯總了Python中SettingsLibrary.getAddCarUrl方法的典型用法代碼示例。如果您正苦於以下問題:Python SettingsLibrary.getAddCarUrl方法的具體用法?Python SettingsLibrary.getAddCarUrl怎麽用?Python SettingsLibrary.getAddCarUrl使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類SettingsLibrary
的用法示例。
在下文中一共展示了SettingsLibrary.getAddCarUrl方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: addCar
# 需要導入模塊: import SettingsLibrary [as 別名]
# 或者: from SettingsLibrary import getAddCarUrl [as 別名]
def addCar(hostname,port,numberOfCars):
for x in range(1, numberOfCars+1):
strId = str(x)
payload = SettingsLibrary.add_car_payload_template.substitute(id=strId,category="category"+strId,model="model"+strId,
manufacturer="manufacturer"+strId,
year=(2000+x%100))
print("payload formed after template substitution=")
print(payload)
# Send the POST request
resp = UtilLibrary.post(SettingsLibrary.getAddCarUrl(hostname,port),"admin", "admin",payload)
print("the response of the POST to add car=")
print(resp)
return resp
示例2: addCar
# 需要導入模塊: import SettingsLibrary [as 別名]
# 或者: from SettingsLibrary import getAddCarUrl [as 別名]
def addCar(hostname, port, numberOfCars):
"""Creates the specified number of cars based on Cars yang model using RESTCONF"""
for x in range(1, numberOfCars+1):
strId = str(x)
payload = SettingsLibrary.add_car_payload_template.substitute(
id=strId, category="category" + strId, model="model" + strId,
manufacturer="manufacturer" + strId,
year=(2000 + x % 100))
print("payload formed after template substitution=")
print(payload)
# Send the POST request
resp = UtilLibrary.post(SettingsLibrary.getAddCarUrl(hostname, port), "admin", "admin", payload)
print("the response of the POST to add car=")
print(resp)
time.sleep(5) # Let the add finish
return resp
示例3: addCar
# 需要導入模塊: import SettingsLibrary [as 別名]
# 或者: from SettingsLibrary import getAddCarUrl [as 別名]
def addCar(hostname, port, numberOfCars, *expected):
"""Creates the specified number of cars based on Cars yang model using RESTCONF"""
for x in range(1, numberOfCars + 1):
strId = str(x)
payload = SettingsLibrary.add_car_payload_template.substitute(
id=strId, category="category" + strId, model="model" + strId,
manufacturer="manufacturer" + strId,
year=(2000 + x % 100))
print("payload formed after template substitution=")
print(payload)
# Send the POST request
resp = UtilLibrary.post(SettingsLibrary.getAddCarUrl(hostname, port), "admin", "admin", payload)
print("the response of the POST to add car=")
print(resp)
if expected and str(resp.status_code) not in expected:
raise RuntimeError('Add car failed for {}:{} with status {}'.
format(hostname, port, resp.status_code))
return resp