@@ -92,9 +92,9 @@ def __init__(self, name=None, nodes=None, topology=None, network_config_file=Non
9292 self .nodes = nodes
9393 self .topology = construct_topology_config (topology , self .nodes )
9494 if not force :
95- answer = input ("Do you want to add/replace the network {} in the file {} "
96- " with a network constisting of the nodes {}? (yes/no) "
97- . format ( self . name , self . _network_config_file , self .nodes ) )
95+ answer = input (f "Do you want to add/replace the network { self . name } in the "
96+ f"file { self . _network_config_file } with a network consisting "
97+ f"of the nodes { self .nodes } ? (yes/no)" )
9898 if answer not in ["yes" , "y" ]:
9999 raise RuntimeError ("User did not want to replace network in file" )
100100 networks_config .add_network (node_names = self .nodes , network_name = self .name , topology = self .topology )
@@ -106,18 +106,17 @@ def __init__(self, name=None, nodes=None, topology=None, network_config_file=Non
106106 node_names = networks_config .get_node_names (self .name )
107107 self .topology = networks_config .networks [self .name ].topology
108108 else :
109- raise ValueError ("Network {} is not in the file {}\n "
110- "If you wish to add this network to the file, use the"
111- "--new flag." .format (self .name , self ._network_config_file ))
109+ raise ValueError (f"Network { self .name } is not in the file { self ._network_config_file } \n "
110+ f"If you wish to add this network to the file, use the --new flag." )
112111 if nodes is None :
113112 self .nodes = node_names
114113 else :
115114 self .nodes = nodes
116115 for node_name in self .nodes :
117116 if node_name not in node_names :
118- raise ValueError ("Node {} is not in the current network {} in the file {} \n "
119- "If you wish to overwrite the current network in the file, use the "
120- " --new flag.". format ( node_name , self . name , self . _network_config_file ) )
117+ raise ValueError (f "Node { node_name } is not in the current network { self . name } "
118+ f"in the file { self . _network_config_file } \n If you wish to overwrite "
119+ f"the current network in the file, use the --new flag." )
121120
122121 self ._setup_processes ()
123122
@@ -138,7 +137,7 @@ def running(self):
138137 self ._running = False
139138 break
140139 except Exception as err :
141- self ._logger .exception ("Got unexpected exception when trying to connect: {}" . format ( err ) )
140+ self ._logger .exception ("Got unexpected exception when trying to connect: %s" , err )
142141 raise err
143142 else :
144143 self ._logger .debug ("Network %s is now running" , self .name )
@@ -156,10 +155,10 @@ def _setup_processes(self):
156155 mp .set_start_method ("spawn" , force = True )
157156 for node in self .nodes :
158157 process_virtual = mp .Process (
159- target = start_vnode , args = (node , self .name , get_log_level ()), name = "VirtNode {}" . format ( node )
158+ target = start_vnode , args = (node , self .name , get_log_level ()), name = f "VirtNode { node } "
160159 )
161160 process_qnodeos = mp .Process (
162- target = start_qnodeos , args = (node , self .name , get_log_level ()), name = "QnodeOSNode {}" . format ( node )
161+ target = start_qnodeos , args = (node , self .name , get_log_level ()), name = f "QnodeOSNode { node } "
163162 )
164163 self .processes += [process_virtual , process_qnodeos ]
165164
@@ -191,14 +190,15 @@ def stop(self):
191190 Stops the network.
192191 """
193192 self ._running = False
194- self ._logger .info ("Stopping network with name {}" . format ( self .name ) )
193+ self ._logger .info ("Stopping network with name %s" , self .name )
195194 for p in self .processes :
196195 while p .is_alive ():
197196 time .sleep (0.1 )
198197 try :
199198 p .terminate ()
200199 except Exception as err :
201- self ._logger ("Could not terminate one of the processes in the network due to error: {}" .format (err ))
200+ self ._logger .warning ("Could not terminate one of the processes in the"
201+ "network due to error: %s" , err )
202202
203203
204204def construct_topology_config (topology , nodes ):
0 commit comments