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

wxGUI/psmap: fix show correct error message if Ghostscript isn't installed (required for rendering output PDF file) on the OS MS Windows platform #2420

Merged
merged 5 commits into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
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
38 changes: 30 additions & 8 deletions gui/wxpython/psmap/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,8 +404,14 @@ def OnCmdDone(self, event):

if event.userData["pdfname"]:
if sys.platform == "win32":
import platform

arch = platform.architecture()[0]
pdf_rendering_prog = "gswin64c"
if "32" in arch:
pdf_rendering_prog = "gswin32c"
command = [
"gswin32c",
pdf_rendering_prog,
"-P-",
"-dSAFER",
"-dCompatibilityLevel=1.4",
Expand All @@ -427,14 +433,23 @@ def OnCmdDone(self, event):
"-f",
event.userData["filename"],
]
title = _("Program {} is not available.").format(pdf_rendering_prog)
message = _("{title} Please install it to create PDF.\n\n").format(
title=title
)
else:
pdf_rendering_prog = "ps2pdf"
command = [
"ps2pdf",
pdf_rendering_prog,
"-dPDFSETTINGS=/prepress",
"-r1200",
event.userData["filename"],
event.userData["pdfname"],
]
message = _(
"Program {} is not available."
" Please install it to create PDF.\n\n "
).format(pdf_rendering_prog)
try:
proc = grass.Popen(command)
ret = proc.wait()
Expand All @@ -447,13 +462,20 @@ def OnCmdDone(self, event):
else:
self.SetStatusText(_("PDF generated"), 0)
except OSError as e:
GError(
parent=self,
message=_(
"Program ps2pdf is not available. Please install it to create PDF.\n\n %s"
if sys.platform == "win32":
dlg = HyperlinkDialog(
self,
title=title,
message=message + str(e),
hyperlink="https://www.ghostscript.com/releases/gsdnld.html",
hyperlinkLabel=_("You can download {} version here.").format(
arch
),
)
% e,
)
dlg.ShowModal()
dlg.Destroy()
return
GError(parent=self, message=message + str(e))

elif not event.userData["temp"]:
self.SetStatusText(_("PostScript file generated"), 0)
Expand Down
2 changes: 1 addition & 1 deletion gui/wxpython/psmap/g.gui.psmap.html
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ <h3>CARTOGRAPHIC COMPOSER TOOLBAR</h3>
<dd> Generates hardcopy map output in PostScript/EPS file.</dd>
<dt><img src="icons/pdf-export.png" alt="icon">&nbsp;
<em>Generate hardcopy map output in PDF</em></dt>
<dd> Generates hardcopy map output in PDF using ps2pdf.</dd>
<dd> Generates hardcopy map output in PDF using ps2pdf or <a href="https://www.ghostscript.com/releases/gsdnld.html">Ghostscript gswin32c/gswin64c</a> (OS MS Windows platform only).</dd>

</dl>

Expand Down