Skip to content

Commit

Permalink
Detect ghostscript and default image viewer in FreeBSD (GenericMappin…
Browse files Browse the repository at this point in the history
…gTools#878)

Co-authored-by: Wei Ji <23487320+weiji14@users.noreply.github.com>
  • Loading branch information
2 people authored and Josh Sixsmith committed Dec 21, 2022
1 parent 94b301f commit 3f9e45a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pygmt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ 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", "freebsd", "darwin")):
cmds = ["gs"]
elif os_name == "win32":
cmds = ["gswin64c.exe", "gswin32c.exe"]
Expand Down
5 changes: 3 additions & 2 deletions pygmt/helpers/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,10 @@ 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", "freebsd")) and shutil.which("xdg-open"):
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

0 comments on commit 3f9e45a

Please sign in to comment.