MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / get

Method get

pager_lib/getmac/getmac.py:1163–1191  ·  view source on GitHub ↗
(self, arg="")

Source from the content-addressed store, hash-verified

1161 return check_path("/proc/net/route")
1162
1163 def get(self, arg=""): # type: (str) -> Optional[str]
1164 data = _read_file("/proc/net/route")
1165
1166 if data is not None and len(data) > 1:
1167 for line in data.split("\n")[1:-1]:
1168 line = line.strip()
1169 if not line:
1170 continue
1171
1172 # Some have tab separators, some have spaces
1173 if "\t" in line:
1174 sep = "\t"
1175 else:
1176 sep = " "
1177
1178 iface_name, dest = line.split(sep)[:2]
1179
1180 if dest == "00000000":
1181 return iface_name
1182
1183 if DEBUG:
1184 log.debug(
1185 "Failed to find default interface in data from "
1186 "'/proc/net/route', no destination of '00000000' was found"
1187 )
1188 elif DEBUG:
1189 log.warning("No data from /proc/net/route")
1190
1191 return None
1192
1193
1194class DefaultIfaceRouteCommand(Method):

Callers

nothing calls this directly

Calls 3

_read_fileFunction · 0.85
debugMethod · 0.80
warningMethod · 0.80

Tested by

no test coverage detected