最近我在我的 Pycharm 上安装了 Pyshark。这是我的代码:
import pyshark
cap = pyshark.FileCapture('/root/captures/initialize_db.pcap')
print (dir(cap[184]['DB-LSP-DISC']))
当我运行时,我得到了答案以及一些警告:
['DATA_LAYER', '__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattr__', '__getattribute__', '__getstate__', '__gt__', '__hash__', '__init__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__setstate__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_all_fields', '_field_prefix', '_get_all_field_lines', '_get_all_fields_with_alternates', '_get_field_or_layer_repr', '_get_field_repr', '_layer_name', '_sanitize_field_name', 'field_names', 'get', 'get_field', 'get_field_by_showname', 'get_field_value', 'json_array', 'json_key', 'json_member', 'json_object', 'json_value_number', 'json_value_string', 'layer_name', 'pretty_print', 'raw_mode']
Exception ignored in: <bound method BaseEventLoop.__del__ of <_UnixSelectorEventLoop running=False closed=True debug=False>>
Traceback (most recent call last):
File "/usr/lib/python3.5/asyncio/base_events.py", line 510, in __del__
File "/usr/lib/python3.5/asyncio/unix_events.py", line 65, in close
File "/usr/lib/python3.5/asyncio/unix_events.py", line 146, in remove_signal_handler
File "/usr/lib/python3.5/signal.py", line 47, in signal
TypeError: signal handler must be signal.SIG_IGN, signal.SIG_DFL, or a callable object
Exception ignored in: <generator object Capture._packets_from_tshark_sync at 0x7f4787d2eba0>
Traceback (most recent call last):
File "/root/PycharmProjects/Dropbox/venv/lib/python3.5/site-packages/pyshark/capture/capture.py", line 229, in _packets_from_tshark_sync
File "/usr/lib/python3.5/asyncio/base_events.py", line 443, in run_until_complete
File "/usr/lib/python3.5/asyncio/base_events.py", line 357, in _check_closed
RuntimeError: Event loop is closed
sys:1: RuntimeWarning: coroutine 'Capture._cleanup_subprocess' was never awaited
Exception ignored in: <bound method BaseSubprocessTransport.__del__ of <_UnixSubprocessTransport closed pid=20639 running stdout=<_UnixReadPipeTransport closing fd=7 open>>>
Traceback (most recent call last):
File "/usr/lib/python3.5/asyncio/base_subprocess.py", line 131, in __del__
File "/usr/lib/python3.5/asyncio/base_subprocess.py", line 106, in close
File "/usr/lib/python3.5/asyncio/unix_events.py", line 414, in close
File "/usr/lib/python3.5/asyncio/unix_events.py", line 442, in _close
File "/usr/lib/python3.5/asyncio/base_events.py", line 572, in call_soon
File "/usr/lib/python3.5/asyncio/base_events.py", line 357, in _check_closed
RuntimeError: Event loop is closed
我在虚拟环境中运行 Python 3.5.3。