Edgewall Software
Modify

Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#12183 closed defect (fixed)

Possible mistyped processor on TracDownload

Reported by: figaro Owned by: Ryan J Ollos
Priority: normal Milestone: 1.0.9
Component: general Version:
Severity: normal Keywords:
Cc: Branch:
Release Notes:

Added apachecon, genshi, nginx and pycon keywords to KNOWN_MIME_TYPES to prevent WikiProcessor errors in the TracGuide when Pygments is not installed.

API Changes:
Internal Changes:

Description (last modified by figaro)

At the bottom of page TracDownload the following is shown: Error: Failed to load processor apache No macro or processor named 'apache' found

This is possibly the result of a mistyped processor on that page.

Attachments (0)

Change History (13)

comment:1 by figaro, 5 years ago

Description: modified (diff)
Summary: Possible mistyped processor on TracDownload#LatestStableReleasePossible mistyped processor on TracDownload

Updated description and summary.

comment:2 by Ryan J Ollos, 5 years ago

This is due to a Pygments installation issue that I've noted in our internal issue tracker. However, the issue is also present on TracModWSGI which gets distributed with Trac so the errors will be seen whenever Pygments is not installed. We should probably add a known mimetype for the ApacheConf Lexer:

  • trac/mimeview/api.py

    diff --git a/trac/mimeview/api.py b/trac/mimeview/api.py
    index aae3172..96f2c72 100644
    a b KNOWN_MIME_TYPES = {  
    304304    'text/xml':                'xml',
    305305
    306306    # see also TEXT_X_TYPES below
     307    'text/x-apacheconf':       'apache',
    307308    'text/x-csrc':             'c xs',
    308309    'text/x-chdr':             'h',
    309310    'text/x-c++src':           'cc CC cpp C c++ C++',

comment:3 by Jun Omae, 5 years ago

That change looks good to me. We could add check of invalid wiki processors to checkwiki.py.

  • contrib/checkwiki.py

    diff --git a/contrib/checkwiki.py b/contrib/checkwiki.py
    index c9b8029ff..fbc874dbd 100755
    a b class DefaultWikiChecker(Formatter):  
    5151                self.__marks.append((fullmatch.start(0), fullmatch.end(0)))
    5252        return rv
    5353
     54    def handle_code_block(self, line, startmatch=None):
     55        prev_processor = getattr(self, 'code_processor', None)
     56        try:
     57            return self.__super.handle_code_block(line, startmatch)
     58        finally:
     59            processor = self.code_processor
     60            if startmatch and processor and processor != prev_processor and \
     61                    processor.error:
     62                self.__marks.append((startmatch.start(0), startmatch.end(0)))
     63
    5464    def format(self, text, out=None):
    5565        return self.__super.format(SourceWrapper(self, text), out)
    5666
    def main():  
    160170    if options.download:
    161171        download_default_pages(args, options.prefix)
    162172
    163     env = EnvironmentStub()
     173    env = EnvironmentStub(disable=['trac.mimeview.pygments.*'])
    164174    load_components(env)
    165175    with env.db_transaction:
    166176        for name in names:

The same issue raises on #!pycon in TracPlugins page.

$ python contrib/checkwiki.py | grep '#!' | sed -e 's/^\([^:]*\):[0-9]*:\(.*\)$/\1:\2/' | sort | uniq -c
      3 TracCgi:{{{#!apache
      1 TracFineGrainedPermissions:{{{#!apache
      3 TracInstall:{{{#!apache
      3 TracInterfaceCustomization:{{{#!apache
     18 TracModPython:{{{#!apache
     15 TracModWSGI:{{{#!apache
      4 TracPlugins:{{{#!apache
      1 TracPlugins:{{{#!pycon
      1 TracStandalone:{{{#!apache

comment:4 by Ryan J Ollos, 5 years ago

Milestone: 1.0.9
Owner: set to Ryan J Ollos
Release Notes: modified (diff)
Status: newassigned
Type: taskdefect

comment:2 change committed to 1.0-stable in [14277], merged to trunk in [14278].

The change in comment:3 seems like a good idea.

comment:5 by Jun Omae, 5 years ago

Thanks. Committed the patch in comment:3 to 1.0-stable in [14279]. The check has limitation which works only for top level processor names.

Last edited 5 years ago by Jun Omae (previous) (diff)

in reply to:  3 ; comment:6 by Ryan J Ollos, 5 years ago

Replying to jomae:

The same issue raises on #!pycon in TracPlugins page.

I can reproduce locally, but strangely the error is not raised on the TracPlugins page of t.e.o even though Pygments is not currently installed.

Should we add pycon to known mimetypes?:

  • trac/mimeview/api.py

    diff --git a/trac/mimeview/api.py b/trac/mimeview/api.py
    index 196e55b..d803f0d 100644
    a b KNOWN_MIME_TYPES = {  
    338338    'text/x-perl':             'pl pm PL',
    339339    'text/x-php':              'php3 php4',
    340340    'text/x-python':           'py',
     341    'text/x-python-doctest':   'pycon',
    341342    'text/x-pyrex':            'pyx',
    342343    'text/x-ruby':             'rb',
    343344    'text/x-scheme':           'scm',

comment:7 by Ryan J Ollos, 5 years ago

Looks like we also need to handle the genshi keyword, at least on the trunk:

  • trac/mimeview/api.py

    diff --git a/trac/mimeview/api.py b/trac/mimeview/api.py
    index baaaa0d..281a313 100644
    a b KNOWN_MIME_TYPES = {  
    301301    'application/x-dos-batch': 'bat batch cmd dos',
    302302    'application/x-sh':        'sh',
    303303    'application/x-csh':       'csh',
     304    'application/x-genshi':    'genshi',
    304305    'application/x-troff':     'nroff roff troff',
    305306    'application/x-yaml':      'yml yaml',

in reply to:  6 comment:8 by Peter Suter, 5 years ago

Replying to rjollos:

Replying to jomae:

The same issue raises on #!pycon in TracPlugins page.

I can reproduce locally, but strangely the error is not raised on the TracPlugins page of t.e.o even though Pygments is not currently installed.

Is that because it's in t.e.o's TracIni#mimeviewer-section:

[mimeviewer]
mime_map = application/x-genshi:genshi, application/x-genshi-text:genshitext, text/x-python-doctest:pycon, text/x-ini:ini, text/coffeescript:coffee

comment:9 by Ryan J Ollos, 5 years ago

Release Notes: modified (diff)
Resolution: fixed
Status: assignedclosed

Thanks for the explanation. I committed the changes in comment:6 and comment:7 to 1.0-stable in [14281], merged to trunk in [14282].

comment:10 by Ryan J Ollos, 5 years ago

I added nginx and apache to [mimeviewer] mime_map to prevent WikiProcessor errors when pygments is not installed.

Please let me know if you spot any other WikiProcessors on the site that are showing errors.

in reply to:  10 ; comment:11 by Ryan J Ollos, 5 years ago

Replying to Ryan J Ollos:

I added nginx and apache to [mimeviewer] mime_map to prevent WikiProcessor errors when pygments is not installed.

Removed apache, genshi and pycon keywords from [mimeviewer] mime_map since t.e.o has been upgraded to 1.2dev and those keywords are contained in KNOWN_MIME_TYPES.

comment:12 by Ryan J Ollos, 5 years ago

Release Notes: modified (diff)

Added nginx in [14285] to [mimeviewer] mime_map to prevent WikiProcessor errors when pygments is not installed. Merged in [14286].

in reply to:  11 comment:13 by Ryan J Ollos, 5 years ago

Replying to rjollos:

Replying to Ryan J Ollos:

I added nginx and apache to [mimeviewer] mime_map to prevent WikiProcessor errors when pygments is not installed.

Removed apache, genshi and pycon keywords from [mimeviewer] mime_map since t.e.o has been upgraded to 1.2dev and those keywords are contained in KNOWN_MIME_TYPES.

Removed nginx from mime_map since we are now running later than r14286.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Ryan J Ollos.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Ryan J Ollos to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.