#12359 closed defect (fixed)
TracError: Unknown trac-admin command "copystatic"
Reported by: | Ryan J Ollos | Owned by: | Jun Omae |
---|---|---|---|
Priority: | normal | Milestone: | 1.0.11 |
Component: | admin/web | Version: | |
Severity: | normal | Keywords: | |
Cc: | Branch: | ||
Release Notes: |
Unknown |
||
API Changes: |
Added |
||
Internal Changes: |
Description
From the logs:
[pid 23657 140015545095936] 2016-02-16 02:44:34,470 Trac[formatter] ERROR: Macro TracAdminHelp(copystatic) failed: Traceback (most recent call last): File "/usr/local/virtualenv/1.1dev/lib/python2.7/site-packages/trac/wiki/formatter.py", line 798, in _macro_formatter return macro.ensure_inline(macro.process(args)) File "/usr/local/virtualenv/1.1dev/lib/python2.7/site-packages/trac/wiki/formatter.py", line 375, in process text = self.processor(text) File "/usr/local/virtualenv/1.1dev/lib/python2.7/site-packages/trac/wiki/formatter.py", line 347, in _macro_processor text) File "/usr/local/virtualenv/1.1dev/lib/python2.7/site-packages/trac/admin/console.py", line 588, in expand_macro command=content)) TracError: Unknown trac-admin command "copystatic"
Previously there was a copystatic
command: [6894].
Attachments (0)
Change History (6)
comment:1 by , 9 years ago
comment:2 by , 9 years ago
Another solution is that expand_macro()
raises ProcessorError
(or new MacroError
exception) for incorrect arguments, etc. and Formatter
renders the exception as system_message
.
-
trac/admin/console.py
diff --git a/trac/admin/console.py b/trac/admin/console.py index 8385c806f..2e64fbff3 100755
a b from trac.util.text import console_print, exception_to_unicode, printout, \ 36 36 from trac.util.translation import _, ngettext, has_babel, cleandoc_ 37 37 from trac.versioncontrol.api import RepositoryManager 38 38 from trac.wiki.admin import WikiAdmin 39 from trac.wiki.formatter import ProcessorError 39 40 from trac.wiki.macros import WikiMacroBase 40 41 41 42 … … class TracAdminHelpMacro(WikiMacroBase): 550 551 cmd_mgr = AdminCommandManager(self.env) 551 552 doc = cmd_mgr.get_command_help(arg) 552 553 if not doc: 553 raise TracError(_('Unknown trac-admin command "%(command)s"',554 command=content))554 raise ProcessorError(_('Unknown trac-admin command ' 555 '"%(command)s"', command=content)) 555 556 else: 556 557 doc = TracAdmin.all_docs(self.env) 557 558 buf = StringIO.StringIO() -
trac/admin/tests/console.py
diff --git a/trac/admin/tests/console.py b/trac/admin/tests/console.py index 93227d6d0..18c6f7602 100644
a b from trac.util.datefmt import format_date, get_date_format_hint, \ 53 53 get_datetime_format_hint 54 54 from trac.util.translation import get_available_locales, has_babel 55 55 from trac.web.tests.session import _prep_session_table 56 from trac.wiki.formatter import ProcessorError 56 57 57 58 STRIP_TRAILING_SPACE = re.compile(r'( +)$', re.MULTILINE) 58 59 … … class TracAdminHelpMacroTestCase(unittest.TestCase): 1399 1400 help = unicode(macro.expand_macro(None, None, 'unicode-help')) 1400 1401 self.assertTrue(unicode_help in help) 1401 1402 1403 def test_invalid_command(self): 1404 macro = TracAdminHelpMacro(self.env) 1405 try: 1406 macro.expand_macro(None, None, 'copystatic') 1407 self.fail('ProcessorError not raised') 1408 except ProcessorError, e: 1409 self.assertEqual('Unknown trac-admin command "copystatic"', 1410 unicode(e)) 1411 1402 1412 1403 1413 def suite(): 1404 1414 suite = unittest.TestSuite() -
trac/wiki/formatter.py
diff --git a/trac/wiki/formatter.py b/trac/wiki/formatter.py index 969074947..360f05612 100644
a b class Formatter(object): 787 787 args = fullmatch.group('macroargs') 788 788 try: 789 789 return macro.ensure_inline(macro.process(args)) 790 except ProcessorError, e: 791 return system_message(e) 790 792 except Exception, e: 791 793 self.env.log.error('Macro %s(%s) failed:%s', name, args, 792 794 exception_to_unicode(e, traceback=True))
comment:3 by , 9 years ago
Owner: | set to |
---|---|
Status: | new → assigned |
Thanks, I didn't know about ProcessorError
. I'll push your changes.
comment:4 by , 9 years ago
API Changes: | modified (diff) |
---|---|
Release Notes: | modified (diff) |
Resolution: | → fixed |
Status: | assigned → closed |
Committed to 1.0-stable in [14563], merged to trunk in [14564]. MacroError
documented in TracDev/Exceptions@14.
comment:5 by , 9 years ago
Owner: | changed from | to
---|
Proposed change is to return a
system_message
rather than raising aTracError
:trac/admin/console.py
aise TracError(_('Unknown trac-admin command "%(command)s"',command=content))trac/admin/tests/console.py