Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions netsim/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,10 @@ def parse_node_params(node, prefix, node_params, runner_id):
].strip()
break
if node["param_parser"] == "iroh_ticket_v2" and line.startswith(
"NodeTicket"
"Ticket with our home relay and direct addresses:"
):
node_params[node_name] = line[
len("NodeTicket: ") :
].strip()
next_line = next(f)
node_params[node_name] = next_line.strip()
break
return node_params

Expand Down
12 changes: 9 additions & 3 deletions netsim/parsing/netsim.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json
import re
import os
import humanfriendly

Expand Down Expand Up @@ -35,7 +36,7 @@ def parse_iroh_output(lines, size):
transfer_lines = [
line
for line in lines
if "Transferred" in line and "in" in line and "/s" in line
if ("Transferred" in line or "Received" in line) and "in" in line and "/s" in line
]
if not transfer_lines:
raise Exception("bad run")
Expand All @@ -51,7 +52,12 @@ def parse_iroh_output(lines, size):

def parse_humanized_output(line):
"""Convert human-readable size to megabits."""
bytes_size = humanfriendly.parse_size(line.split(", ")[-1], binary=True)
x = re.search("\((.*)\/s", line)
if x is None:
raise Exception("Line does not match bytesize pattern")

match = x.groups()[0]
bytes_size = humanfriendly.parse_size(match, binary=True)
return bytes_size * 8 / 1e6


Expand Down Expand Up @@ -84,7 +90,7 @@ def parse_magic_iroh_client(lines):
s["transfer_success"] = (
"true"
if any(
"Transferred" in line and "in" in line and "/s" in line for line in lines
"Received" in line and "in" in line and "/s" in line for line in lines
)
else "false"
)
Expand Down
Loading