< Home

Returning Event Execution Results

Interface Name

Returning event execution results

Application Phase

Execution phase of resident scripts

API Prototype

result1_value, result2_description = ops.result(status)

Description

Parameter

Description

Value

status

Indicates the user script execution result.

The value 0 indicates that the user script is executed successfully, and the value 1 indicates that the user script fails to be executed.

Return Value

The result1_value and result2_description in the API prototype indicate return values.

The first return value 0 indicates that an event is executed successfully, and the first return value 1 indicates that an event fails to be executed.

The second return value is a string of characters indicating the results.

Usage Description

This API indicates the event execution result. The value 0 indicates that an event is executed successfully, and the value 1 indicates that an event fails to be executed. If the result function is invoked for multiple times, the value returned by the first result function takes effect.

Example

When a subscription event is matched, the device reads the content entered on a user terminal, and returns the execution result based on the content.

value, err_str = ops.terminal.read(512 ,30, vty=None) # Read the user input from the current user terminal.
print("\r\no.terminal.read.value1:", value)
print("\r\no.terminal.read:", err_str)
#If the user enters yes, 1 is returned. If the user enters no or other information, 0 is returned.
if value == "yes":
	ops.result(1)
if value == "no":
	ops.result(0)
ops.result(0)
Copyright © Huawei Technologies Co., Ltd.
Copyright © Huawei Technologies Co., Ltd.
< Previous topic