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

Add ability to provide cli options in binary mode #259

Merged
merged 2 commits into from
Jan 13, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions whois/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
)


def whois(url, command=False, flags=0, executable="whois", inc_raw=False, quiet=False, convert_punycode=True):
def whois(url, command=False, flags=0, executable="whois", executable_opts=None, inc_raw=False, quiet=False, convert_punycode=True):
# clean domain to expose netloc
ip_match = IPV4_OR_V6.match(url)
if ip_match:
Expand All @@ -38,7 +38,13 @@ def whois(url, command=False, flags=0, executable="whois", inc_raw=False, quiet=
domain = extract_domain(url)
if command:
# try native whois command
r = subprocess.Popen([executable, domain], stdout=subprocess.PIPE)
whois_command = [executable, domain]
if executable_opts:
if isinstance(executable_opts, list):
whois_command.extend(executable_opts)
else:
whois_command.append(executable_opts)
r = subprocess.Popen(whois_command, stdout=subprocess.PIPE)
text = r.stdout.read().decode()
else:
# try builtin client
Expand Down
Loading