#7748 closed enhancement (fixed)
[patch] detect when Enscript is not installed
Reported by: | Owned by: | Remy Blank | |
---|---|---|---|
Priority: | normal | Milestone: | 0.11.3 |
Component: | rendering | Version: | 0.11-stable |
Severity: | normal | Keywords: | patch |
Cc: | Branch: | ||
Release Notes: | |||
API Changes: | |||
Internal Changes: |
Description
trac.log is full of tracebacks about failed Enscript executions. Enscript is not installed and won't be. The patch here checks if Enscript is installed before reporting supported mimetypes.
2008-10-23 00:24:01,436 Trac[__init__] WARNING: HTML preview using <trac.mimeview.enscript.EnscriptRenderer object at 0x40edae8c> failed (Running (enscript --color -h -q --language=html -p - -Ecpp) failed: 127, sh: line 1: enscript: command not found .) Traceback (most recent call last): File "/home/.december/trex/inst/lib/python2.4/site-packages/Trac-0.11.1-py2.4.egg/trac/mimeview/api.py", line 635, in render rendered_content, filename, url) File "/home/.december/trex/inst/lib/python2.4/site-packages/Trac-0.11.1-py2.4.egg/trac/mimeview/enscript.py", line 145, in render raise Exception, err Exception: Running (enscript --color -h -q --language=html -p - -Ecpp) failed: 127, sh: line 1: enscript: command not found
Attachments (2)
Change History (10)
by , 16 years ago
Attachment: | enscript.not_installed.patch.txt added |
---|
comment:1 by , 16 years ago
Milestone: | → 0.11.3 |
---|
Good idea, but I'd rather do something like an auto-disable after the first failure.
comment:2 by , 16 years ago
Is it possible to disable a component? I thought it is not, because components do not return anything on initialization and TracDev/ComponentArchitecture is also silent about this.
comment:3 by , 16 years ago
Owner: | set to |
---|
by , 16 years ago
Attachment: | 7748-disable-enscript-r7716.patch added |
---|
Patch against 0.11-stable disabling enscript after the first execution error
follow-up: 6 comment:4 by , 16 years ago
The patch above disables EnscriptRenderer
when invocation of enscript
fails. An environment reload is required to re-enable it.
Christian, is that what you had in mind?
comment:5 by , 16 years ago
Seems good, but it would be even better if log message is expanded with the information that Enscript is getting disabled. And it's still would be nice to look for enscript executable in PATHs.
comment:6 by , 16 years ago
Replying to rblank:
The patch above disables
EnscriptRenderer
when invocation ofenscript
fails. An environment reload is required to re-enable it.Christian, is that what you had in mind?
Yes, something similar:
-
trac/mimeview/enscript.py
140 140 141 141 np = NaivePopen(cmdline, content.encode('utf-8'), capturestderr=1) 142 142 if np.errorlevel or np.err: 143 self.env.enabled[self.__class__] = False 143 144 err = 'Running (%s) failed: %s, %s.' % (cmdline, np.errorlevel, 144 145 np.err) 145 146 raise Exception, err
(sorry untested, not much time for Trac those days ;-) )
comment:7 by , 16 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Fixed in [7719] by disabling the component in the ComponentManager
. I have also made clear in the error message that EnscriptRenderer
is disabled.
About searching for enscript on PATH
, this is already done, as enscript is run through os.system()
, which uses exec()
which uses PATH
to find the executable if it doesn't contain a /
. At least it works on *nix, not sure about Windows. I have enscript_path = enscript
in my trac.ini
and the executable is found.
comment:8 by , 16 years ago
Type: | defect → enhancement |
---|
find_executable() function looks for executable in PATH without executing it, because it is not a good idea to spawn a new system process just to ensure that executable is not available.
find_executable() returns full path for executable. This path can then be executed without shell environment with functions other than os.system() that allow to intercept input/output stream directly instead of file reading/writing/reading cycle as it is now.
It is also recommended to replace os.system() calls with functions from subprocess module.
check if enscript command is available