Skip to content

Commit b914104

Browse files
committed
enable PipeCaptures
This PR is a minified version of @CarlyAmars work[1], only enabling PipeCaptures. [1]: #280 Signed-off-by: Paul Spooren <mail@aparcar.org>
1 parent c89fc6e commit b914104

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/pyshark/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@ class UnsupportedVersionException(Exception):
1515
from pyshark.capture.file_capture import FileCapture
1616
from pyshark.capture.remote_capture import RemoteCapture
1717
from pyshark.capture.inmem_capture import InMemCapture
18+
from pyshark.capture.pipe_capture import PipeCapture

src/pyshark/capture/pipe_capture.py

+15
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,18 @@ def close(self):
5050
# Close pipe
5151
os.close(self._pipe)
5252
super(PipeCapture, self).close()
53+
54+
def sniff_continuously(self, packet_count=None):
55+
"""
56+
Captures from the set interface, returning a generator which returns packets continuously.
57+
58+
Can be used as follows:
59+
for packet in capture.sniff_continuously();
60+
print 'Woo, another packet:', packet
61+
62+
Note: you can also call capture.apply_on_packets(packet_callback) which should have a slight performance boost.
63+
64+
:param packet_count: an amount of packets to capture, then stop.
65+
"""
66+
# Retained for backwards compatibility and to add documentation.
67+
return self._packets_from_tshark_sync(packet_count=packet_count)

0 commit comments

Comments
 (0)