Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some tshark_path problems. #565

Merged
merged 5 commits into from
Jul 8, 2022
Merged

Conversation

miaotony
Copy link
Contributor

@miaotony miaotony commented Jul 4, 2022

Get config.ini from the current directory first, then the pyshark module directory.
Check if the file exists before reading it.

In the src/pyshark/tshark/tshark.py, also check if config.ini exists before adding it to possible_paths.

The priority that tshark_path loads will be:
user provided tshark_path > config.ini in the current directory > config.ini in the pyshark module directory > system env

This PR will fix the issue #564 .

src/pyshark/config.py Outdated Show resolved Hide resolved
@miaotony
Copy link
Contributor Author

miaotony commented Jul 6, 2022

I have used pathlib instead of os.path in config.py.

But you have to pay attention to the different behaviors between PurePath.parent and os.path.dirname().

Just like below.

>>> os.path.dirname(r'C:\adsf\\asdfd\\')
'C:\\adsf\\\\asdfd'
>>> os.path.dirname(r'C:\adsf\\asdfd\\adsf.exe')
'C:\\adsf\\\\asdfd'
>>> Path(r'C:\adsf\\asdfd\\').parent
WindowsPath('C:/adsf')
>>> Path(r'C:\adsf\\asdfd\\adsf.exe').parent
WindowsPath('C:/adsf/asdfd')

src/pyshark/config.py Outdated Show resolved Hide resolved
@KimiNewt KimiNewt merged commit 0c18493 into KimiNewt:master Jul 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants