The OPS supports resident scripts. When a resident script is executed, ops.result() returns the execution result, and ops.wait() suspends the script. After the script is triggered again, ops.wait() returns the result, and script execution continues.
# Return the script processing result to the OPS.
opsObj.result(status)
The result can also be returned using return. If neither of them is used, the default value 1 is returned. If both of them are used, the result returned by opsObj.result() takes effect. If opsObj.result() is called consecutively, the first result takes effect.
# Wait until the next event occurs and continue to execute the script.
opsObj.wait()
Method |
Description |
---|---|
opsObj |
Specifies an OPS object. It is obtained through ops.ops() instantiation. |
status |
Specifies a return value, indicating the script processing result sent to the OPS. The value 0 indicates a success (the original command is skipped). Other values are error codes. |
None
test.py import ops def ops_condition(_ops): _ops.cli.subscribe("con11","this",True,True,False,5) _ops.correlate("con11") return ret def ops_execute(_ops): a, des= _ops.context.save("wait1", 'ac1') _ops.result(1) _ops.wait() a, des= _ops.context.save("wait2", 'ac2') return 0