more updates to using f string
This commit is contained in:
parent
79cde8cd59
commit
7d2a615716
23 changed files with 248 additions and 251 deletions
|
@ -48,12 +48,11 @@ def main():
|
|||
logging.basicConfig(level=logging.INFO)
|
||||
options = parser.parse_options("emane80211")
|
||||
start = datetime.datetime.now()
|
||||
print(
|
||||
"running emane 80211 example: nodes(%s) time(%s)"
|
||||
% (options.nodes, options.time)
|
||||
logging.info(
|
||||
"running emane 80211 example: nodes(%s) time(%s)", options.nodes, options.time
|
||||
)
|
||||
example(options)
|
||||
print("elapsed time: %s" % (datetime.datetime.now() - start))
|
||||
logging.info("elapsed time: %s", datetime.datetime.now() - start)
|
||||
|
||||
|
||||
if __name__ == "__main__" or __name__ == "__builtin__":
|
||||
|
|
|
@ -6,7 +6,7 @@ DEFAULT_STEP = 1
|
|||
|
||||
|
||||
def parse_options(name):
|
||||
parser = argparse.ArgumentParser(description="Run %s example" % name)
|
||||
parser = argparse.ArgumentParser(description=f"Run {name} example")
|
||||
parser.add_argument(
|
||||
"-n",
|
||||
"--nodes",
|
||||
|
@ -25,8 +25,8 @@ def parse_options(name):
|
|||
options = parser.parse_args()
|
||||
|
||||
if options.nodes < 2:
|
||||
parser.error("invalid min number of nodes: %s" % options.nodes)
|
||||
parser.error(f"invalid min number of nodes: {options.nodes}")
|
||||
if options.time < 1:
|
||||
parser.error("invalid test time: %s" % options.time)
|
||||
parser.error(f"invalid test time: {options.time}")
|
||||
|
||||
return options
|
||||
|
|
|
@ -41,14 +41,12 @@ def example(options):
|
|||
first_node = session.get_node(2)
|
||||
last_node = session.get_node(options.nodes + 1)
|
||||
|
||||
print("starting iperf server on node: %s" % first_node.name)
|
||||
logging.info("starting iperf server on node: %s", first_node.name)
|
||||
first_node.node_net_cmd("iperf -s -D")
|
||||
first_node_address = prefixes.ip4_address(first_node)
|
||||
print("node %s connecting to %s" % (last_node.name, first_node_address))
|
||||
output = last_node.node_net_cmd(
|
||||
"iperf -t %s -c %s" % (options.time, first_node_address)
|
||||
)
|
||||
print(output)
|
||||
logging.info("node %s connecting to %s", last_node.name, first_node_address)
|
||||
output = last_node.node_net_cmd(f"iperf -t {options.time} -c {first_node_address}")
|
||||
logging.info(output)
|
||||
first_node.node_net_cmd("killall -9 iperf")
|
||||
|
||||
# shutdown session
|
||||
|
@ -59,9 +57,11 @@ def main():
|
|||
logging.basicConfig(level=logging.INFO)
|
||||
options = parser.parse_options("switch")
|
||||
start = datetime.datetime.now()
|
||||
print("running switch example: nodes(%s) time(%s)" % (options.nodes, options.time))
|
||||
logging.info(
|
||||
"running switch example: nodes(%s) time(%s)", options.nodes, options.time
|
||||
)
|
||||
example(options)
|
||||
print("elapsed time: %s" % (datetime.datetime.now() - start))
|
||||
logging.info("elapsed time: %s", datetime.datetime.now() - start)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
@ -45,11 +45,11 @@ def example(options):
|
|||
first_node = session.get_node(2)
|
||||
last_node = session.get_node(options.nodes + 1)
|
||||
|
||||
print("starting iperf server on node: %s" % first_node.name)
|
||||
logging.info("starting iperf server on node: %s", first_node.name)
|
||||
first_node.node_net_cmd("iperf -s -D")
|
||||
address = prefixes.ip4_address(first_node)
|
||||
print("node %s connecting to %s" % (last_node.name, address))
|
||||
last_node.node_net_cmd("iperf -t %s -c %s" % (options.time, address))
|
||||
logging.info("node %s connecting to %s", last_node.name, address)
|
||||
last_node.node_net_cmd(f"iperf -t {options.time} -c {address}")
|
||||
first_node.node_net_cmd("killall -9 iperf")
|
||||
|
||||
# shutdown session
|
||||
|
@ -61,9 +61,11 @@ def main():
|
|||
options = parser.parse_options("wlan")
|
||||
|
||||
start = datetime.datetime.now()
|
||||
print("running wlan example: nodes(%s) time(%s)" % (options.nodes, options.time))
|
||||
logging.info(
|
||||
"running wlan example: nodes(%s) time(%s)", options.nodes, options.time
|
||||
)
|
||||
example(options)
|
||||
print("elapsed time: %s" % (datetime.datetime.now() - start))
|
||||
logging.info("elapsed time: %s", datetime.datetime.now() - start)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue