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

Detect ghostscript and default image viewer in FreeBSD #878

Merged
merged 2 commits into from
Feb 12, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 5 additions & 1 deletion pygmt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,11 @@ def _get_ghostscript_version():
Get ghostscript version.
"""
os_name = sys.platform
if os_name.startswith("linux") or os_name == "darwin":
if (
os_name.startswith("linux")
or os_name.startswith("freebsd")
or os_name == "darwin"
):
seisman marked this conversation as resolved.
Show resolved Hide resolved
cmds = ["gs"]
elif os_name == "win32":
cmds = ["gswin64c.exe", "gswin32c.exe"]
Expand Down
9 changes: 7 additions & 2 deletions pygmt/helpers/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,14 @@ def launch_external_viewer(fname):

# Open the file with the default viewer.
# Fall back to the browser if can't recognize the operating system.
if sys.platform.startswith("linux") and shutil.which("xdg-open"):
os_name = sys.platform
if (
os_name.startswith("linux")
or os_name.startswith("freebsd")
and shutil.which("xdg-open")
):
seisman marked this conversation as resolved.
Show resolved Hide resolved
subprocess.run(["xdg-open", fname], check=False, **run_args)
elif sys.platform == "darwin": # Darwin is macOS
elif os_name == "darwin": # Darwin is macOS
subprocess.run(["open", fname], check=False, **run_args)
else:
webbrowser.open_new_tab("file://{}".format(fname))
Expand Down