提交 90de3141 编写于 作者: X Xiangquan Xiao

Cyber: Prepare for python3 by running 2to3 tool.

上级 3ebf453f
......@@ -27,7 +27,7 @@ from cyber_py import cyber_time
def print_channel_type(channel_name):
msgtype = cyber.ChannelUtils.get_msgtype(channel_name)
print channel_name, " type is [", msgtype, "]"
print(channel_name, " type is [", msgtype, "]")
def _channel_cmd_type(argv):
......@@ -56,7 +56,7 @@ class CyberChannelBw(object):
self.window_size = window_size
if window_size <= 0 or window_size > 50000:
self.window_size = 100
print "bw window_size: ", self.window_size
print("bw window_size: ", self.window_size)
def callback_bw(self, rawdata):
with self.lock:
......@@ -158,7 +158,7 @@ class CyberChannelHz(object):
if window_size <= 0 or window_size > 50000:
window_size = 50000
self.window_size = window_size
print "hz window_size: ", window_size
print("hz window_size: ", window_size)
def callback_hz(self, m):
with self.lock:
......@@ -255,33 +255,33 @@ def print_role(rolsattr_rawdata):
msg = RoleAttributes()
msg.ParseFromString(rolsattr_rawdata)
except DecodeError:
print "RoleAttributes ParseFromString failed. size is ", len(rolsattr_rawdata)
print("RoleAttributes ParseFromString failed. size is ", len(rolsattr_rawdata))
return
print "\troleid\t\t", msg.id
print "\thostname\t", msg.host_name
print "\tprocessid\t", msg.process_id
print "\tnodename\t", msg.node_name
print "\tmsgtype\t\t", msg.message_type
print("\troleid\t\t", msg.id)
print("\thostname\t", msg.host_name)
print("\tprocessid\t", msg.process_id)
print("\tnodename\t", msg.node_name)
print("\tmsgtype\t\t", msg.message_type)
def channel_info(channel_name):
channlesinfo_dict = cyber.ChannelUtils.get_channels_info()
time.sleep(1)
if len(channlesinfo_dict) == 0:
print "channelsinfo dict is null"
print("channelsinfo dict is null")
return
# for key in channlesinfo_dict.keys():
# print key
if channel_name != "":
print channel_name
print(channel_name)
for role_data in channlesinfo_dict[channel_name]:
print_role(role_data)
else:
channels = sorted(channlesinfo_dict.keys())
print "The number of channels is: ", len(channels)
print("The number of channels is: ", len(channels))
for channel in channels:
print channel
print(channel)
for role_data in channlesinfo_dict[channel]:
print_role(role_data)
......@@ -312,9 +312,9 @@ def _channel_cmd_info(argv):
def print_channel_list():
channels = sorted(cyber.ChannelUtils.get_channels())
print "The number of channels is: ", len(channels)
print("The number of channels is: ", len(channels))
for channel in channels:
print channel
print(channel)
def _channel_cmd_list(argv):
......@@ -346,7 +346,7 @@ class CyberChannelecho(object):
# print raw_data # str
msgtype = cyber.ChannelUtils.get_msgtype(self.channel_name, 0)
print cyber.ChannelUtils.get_debugstring_rawmsgdata(msgtype, raw_data)
print(cyber.ChannelUtils.get_debugstring_rawmsgdata(msgtype, raw_data))
def channel_echo(channel_name):
......
......@@ -354,11 +354,11 @@ def start(launch_file=''):
if process_name is None:
process_name = 'mainboard_default_' + str(os.getpid())
process_name = process_name.strip()
if dictionary.has_key(str(process_name)):
if str(process_name) in dictionary:
dictionary[str(process_name)] += 1
else:
dictionary[str(process_name)] = 1
if not dag_dict.has_key(str(process_name)):
if str(process_name) not in dag_dict:
dag_dict[str(process_name)] = [str(dag_conf)]
else:
dag_dict[str(process_name)].append(str(dag_conf))
......
......@@ -30,23 +30,23 @@ def print_node_info(node_name, sleep_s=2):
msg.ParseFromString(roleattr_rawdata)
assert(node_name == msg.node_name)
except:
print "RoleAttributes ParseFromString failed. size is ", len(roleattr_rawdata)
print("RoleAttributes ParseFromString failed. size is ", len(roleattr_rawdata))
return
print "nodename\t", msg.node_name
print "processid\t", msg.process_id
print "hostname\t", msg.host_name
print("nodename\t", msg.node_name)
print("processid\t", msg.process_id)
print("hostname\t", msg.host_name)
print "[Reading Channels]:"
print("[Reading Channels]:")
reader_channels = sorted(cyber.NodeUtils.get_readersofnode(node_name, 0))
for channel in reader_channels:
print channel
print ""
print(channel)
print("")
print "[Writing Channels]:"
print("[Writing Channels]:")
writer_channels = sorted(cyber.NodeUtils.get_writersofnode(node_name, 0))
for channel in writer_channels:
print channel
print ""
print(channel)
print("")
def _node_cmd_info(argv):
......@@ -77,10 +77,10 @@ def _node_cmd_info(argv):
def print_node_list():
nodes = cyber.NodeUtils.get_nodes()
print "The number of nodes is: ", len(nodes)
print("The number of nodes is: ", len(nodes))
nodes.sort()
for node_name in nodes:
print node_name
print(node_name)
def _node_cmd_list(argv):
......
......@@ -30,13 +30,14 @@ def print_service_info(service_name, sleep_s=2):
msg.ParseFromString(roleattr_rawdata)
assert(service_name == msg.service_name)
except:
print "RoleAttributes ParseFromString failed. size is ", len(roleattr_rawdata), ", service name: ", service_name
print("RoleAttributes ParseFromString failed. size is ", len(roleattr_rawdata),
", service name: ", service_name)
return
print msg.service_name
print "\tprocessid\t", msg.process_id
print "\tnodename\t", msg.node_name
print "\thostname\t", msg.host_name
print ""
print(msg.service_name)
print("\tprocessid\t", msg.process_id)
print("\tnodename\t", msg.node_name)
print("\thostname\t", msg.host_name)
print("")
def _service_cmd_info(argv):
......@@ -67,9 +68,9 @@ def _service_cmd_info(argv):
def print_service_list():
services = sorted(cyber.ServiceUtils.get_services())
print "The number of services is: ", len(services)
print("The number of services is: ", len(services))
for service_name in services:
print service_name
print(service_name)
def _service_cmd_list(argv):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册