2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-31 06:15:47 +00:00

tests: test-jsonrpc.py whitespace cleanup.

Pleases pep8.
This commit is contained in:
Ethan Jackson
2011-09-23 15:24:10 -07:00
parent d2dc8f5806
commit e60a5e2637

View File

@@ -23,6 +23,7 @@ import ovs.jsonrpc
import ovs.poller
import ovs.stream
def handle_rpc(rpc, msg):
done = False
reply = None
@@ -43,11 +44,12 @@ def handle_rpc(rpc, msg):
else:
rpc.error(errno.EPROTO)
sys.stderr.write("unsolicited JSON-RPC reply or error\n")
if reply:
rpc.send(reply)
return done
def do_listen(name):
error, pstream = ovs.stream.PassiveStream.open(name)
if error:
@@ -98,6 +100,7 @@ def do_listen(name):
poller.block()
pstream.close()
def do_request(name, method, params_string):
params = ovs.json.from_string(params_string)
msg = ovs.jsonrpc.Message.create_request(method, params)
@@ -123,11 +126,12 @@ def do_request(name, method, params_string):
if error:
sys.stderr.write("error waiting for reply: %s\n" % os.strerror(error))
sys.exit(1)
print ovs.json.to_string(msg.to_json())
rpc.close()
def do_notify(name, method, params_string):
params = ovs.json.from_string(params_string)
msg = ovs.jsonrpc.Message.create_notify(method, params)
@@ -152,6 +156,7 @@ def do_notify(name, method, params_string):
rpc.close()
def main(argv):
try:
options, args = getopt.gnu_getopt(
@@ -198,6 +203,7 @@ def main(argv):
func(*args)
def usage():
sys.stdout.write("""\
%s: JSON-RPC test utility for Python
@@ -214,6 +220,6 @@ Other options:
""")
sys.exit(0)
if __name__ == '__main__':
main(sys.argv)