Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
% (name, os.strerror(error)))
sys.exit(1)
rpc = ovs.jsonrpc.Connection(stream)
error = rpc.send(msg)
if error:
sys.stderr.write("could not send request: %s\n" % os.strerror(error))
sys.exit(1)
error, msg = rpc.recv_block()
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_parse_type(type_string):
type_json = unbox_json(ovs.json.from_string(type_string))
type_ = ovs.db.types.Type.from_json(type_json)
print(ovs.json.to_string(type_.to_json(), sort_keys=True))
def send(self, msg):
if self.status:
return self.status
self.__log_msg("send", msg)
was_empty = len(self.output) == 0
self.output += ovs.json.to_string(msg.to_json())
if was_empty:
self.run()
return self.status
def __str__(self):
s = [Message.type_to_string(self.type)]
if self.method is not None:
s.append("method=\"%s\"" % self.method)
if self.params is not None:
s.append("params=" + ovs.json.to_string(self.params))
if self.result is not None:
s.append("result=" + ovs.json.to_string(self.result))
if self.error is not None:
s.append("error=" + ovs.json.to_string(self.error))
if self.id is not None:
s.append("id=" + ovs.json.to_string(self.id))
return ", ".join(s)
def send(self, msg):
if self.status:
return self.status
self.__log_msg("send", msg)
was_empty = len(self.output) == 0
self.output += ovs.json.to_string(msg.to_json())
if was_empty:
self.run()
return self.status
def to_string(self):
if self.type == ovs.db.types.IntegerType:
return '%d' % self.value
elif self.type == ovs.db.types.RealType:
return '%.15g' % self.value
elif self.type == ovs.db.types.BooleanType:
if self.value:
return 'true'
else:
return 'false'
elif self.type == ovs.db.types.StringType:
if Atom.__string_needs_quotes(self.value):
return ovs.json.to_string(self.value)
else:
return self.value
elif self.type == ovs.db.types.UuidType:
return str(self.value)