mirror of
https://github.com/openvswitch/ovs
synced 2025-09-01 23:05:29 +00:00
tests: test-jsonrpc.py whitespace cleanup.
Pleases pep8.
This commit is contained in:
@@ -23,6 +23,7 @@ import ovs.jsonrpc
|
|||||||
import ovs.poller
|
import ovs.poller
|
||||||
import ovs.stream
|
import ovs.stream
|
||||||
|
|
||||||
|
|
||||||
def handle_rpc(rpc, msg):
|
def handle_rpc(rpc, msg):
|
||||||
done = False
|
done = False
|
||||||
reply = None
|
reply = None
|
||||||
@@ -43,11 +44,12 @@ def handle_rpc(rpc, msg):
|
|||||||
else:
|
else:
|
||||||
rpc.error(errno.EPROTO)
|
rpc.error(errno.EPROTO)
|
||||||
sys.stderr.write("unsolicited JSON-RPC reply or error\n")
|
sys.stderr.write("unsolicited JSON-RPC reply or error\n")
|
||||||
|
|
||||||
if reply:
|
if reply:
|
||||||
rpc.send(reply)
|
rpc.send(reply)
|
||||||
return done
|
return done
|
||||||
|
|
||||||
|
|
||||||
def do_listen(name):
|
def do_listen(name):
|
||||||
error, pstream = ovs.stream.PassiveStream.open(name)
|
error, pstream = ovs.stream.PassiveStream.open(name)
|
||||||
if error:
|
if error:
|
||||||
@@ -98,6 +100,7 @@ def do_listen(name):
|
|||||||
poller.block()
|
poller.block()
|
||||||
pstream.close()
|
pstream.close()
|
||||||
|
|
||||||
|
|
||||||
def do_request(name, method, params_string):
|
def do_request(name, method, params_string):
|
||||||
params = ovs.json.from_string(params_string)
|
params = ovs.json.from_string(params_string)
|
||||||
msg = ovs.jsonrpc.Message.create_request(method, params)
|
msg = ovs.jsonrpc.Message.create_request(method, params)
|
||||||
@@ -123,11 +126,12 @@ def do_request(name, method, params_string):
|
|||||||
if error:
|
if error:
|
||||||
sys.stderr.write("error waiting for reply: %s\n" % os.strerror(error))
|
sys.stderr.write("error waiting for reply: %s\n" % os.strerror(error))
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
print ovs.json.to_string(msg.to_json())
|
print ovs.json.to_string(msg.to_json())
|
||||||
|
|
||||||
rpc.close()
|
rpc.close()
|
||||||
|
|
||||||
|
|
||||||
def do_notify(name, method, params_string):
|
def do_notify(name, method, params_string):
|
||||||
params = ovs.json.from_string(params_string)
|
params = ovs.json.from_string(params_string)
|
||||||
msg = ovs.jsonrpc.Message.create_notify(method, params)
|
msg = ovs.jsonrpc.Message.create_notify(method, params)
|
||||||
@@ -152,6 +156,7 @@ def do_notify(name, method, params_string):
|
|||||||
|
|
||||||
rpc.close()
|
rpc.close()
|
||||||
|
|
||||||
|
|
||||||
def main(argv):
|
def main(argv):
|
||||||
try:
|
try:
|
||||||
options, args = getopt.gnu_getopt(
|
options, args = getopt.gnu_getopt(
|
||||||
@@ -198,6 +203,7 @@ def main(argv):
|
|||||||
|
|
||||||
func(*args)
|
func(*args)
|
||||||
|
|
||||||
|
|
||||||
def usage():
|
def usage():
|
||||||
sys.stdout.write("""\
|
sys.stdout.write("""\
|
||||||
%s: JSON-RPC test utility for Python
|
%s: JSON-RPC test utility for Python
|
||||||
@@ -214,6 +220,6 @@ Other options:
|
|||||||
""")
|
""")
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main(sys.argv)
|
main(sys.argv)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user