MCPcopy Create free account
hub / github.com/ElementsProject/lightning / dumpcap_usable

Function dumpcap_usable

tests/fixtures.py:91–119  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

89
90
91def dumpcap_usable():
92 def have_binary(name):
93 return shutil.which(name) is not None
94
95 if not have_binary("dumpcap") or not have_binary("tshark"):
96 return False
97
98 try:
99 with tempfile.TemporaryDirectory() as td:
100 pcap = Path(td) / "probe.pcap"
101
102 proc = subprocess.Popen(
103 [
104 "dumpcap",
105 "-i", "lo",
106 "-w", str(pcap),
107 "-f", "tcp",
108 ],
109 stdout=subprocess.DEVNULL,
110 stderr=subprocess.DEVNULL,
111 )
112
113 time.sleep(0.2)
114 proc.terminate()
115 proc.wait(timeout=1)
116
117 return pcap.exists() and pcap.stat().st_size > 0
118 except (PermissionError, subprocess.SubprocessError, OSError):
119 return False
120
121
122class TcpCapture:

Callers 1

tcp_captureFunction · 0.85

Calls 2

have_binaryFunction · 0.85
waitMethod · 0.45

Tested by

no test coverage detected