Modify

#10798 closed defect (fixed)

simplemultiproject plugin crashes

Reported by: vitali.sokhin@… Owned by: falkb
Priority: normal Component: SimpleMultiProjectPlugin
Severity: critical Keywords:
Cc: Trac Release: 0.12

Description

When simplemultiproject.admin.smpadminpanel is enabled I get the following traceback

Traceback (most recent call last):
  File "/usr/lib/python2.4/site-packages/trac/web/api.py", line 436, in send_error
    data, 'text/html')
  File "/usr/lib/python2.4/site-packages/trac/web/chrome.py", line 808, in render_template
    template = self.load_template(filename, method=method)
  File "/usr/lib/python2.4/site-packages/trac/web/chrome.py", line 768, in load_template
    self.templates = TemplateLoader(
  File "/usr/lib/python2.4/site-packages/trac/web/chrome.py", line 482, in get_all_templates_dirs
    dirs.extend(provider.get_templates_dirs() or [])
  File "build/bdist.linux-x86_64/egg/simplemultiproject/admin.py", line 133, in get_templates_dirs
  File "/usr/lib/python2.4/site-packages/pkg_resources.py", line 16, in ?
    import sys, os, zipimport, time, re, imp, new
  File "/usr/lib64/python2.4/os.py", line 133, in ?
    from os.path import (curdir, pardir, sep, pathsep, defpath, extsep, altsep,
ImportError: No module named path

Attachments (3)

Trac-milestone.jpg (30.5 KB) - added by vitali 18 months ago.
0.12-t10798-trac.log (13.7 KB) - added by jun66j5 18 months ago.
t10798-2.diff (1.6 KB) - added by jun66j5 18 months ago.

Download all attachments as: .zip

Change History (27)

comment:1 follow-up: Changed 19 months ago by falkb

  • Owner changed from crossroad to falkb
  • Status changed from new to assigned

The error happens deep down in a standard library function. I searched through the internet and have found #1536 where they found out the error happens if pydoc is not installed, which is a common requiry.

Vitali, please, could you try to install it, and then report back?

comment:2 in reply to: ↑ 1 Changed 19 months ago by anonymous

Replying to falkb:

The error happens deep down in a standard library function. I searched through the internet and have found #1536 where they found out the error happens if pydoc is not installed, which is a common requiry.

Vitali, please, could you try to install it, and then report back?

I installed epydoc.noarch 0:2.1-3.el5.rf, but it did not help. I get the same error when I enable admin panel
Is there a way to add projects withou admin panel?

comment:3 Changed 19 months ago by falkb

Well, the according code in SimpleMultiProjectPlugin is:

    def get_templates_dirs(self):
        from pkg_resources import resource_filename
        return [resource_filename(__name__, 'templates')]

You could try to hack it to something like

    def get_templates_dirs(self):
        return ['path_to_templates/templates']

or something like that. This way you avoid accessing the incompatible base library.

comment:4 follow-up: Changed 19 months ago by falkb

Vitali, this page says our problem function resource_filename() is located in setuptools . Have you properly installed that one?

comment:5 in reply to: ↑ 4 Changed 18 months ago by anonymous

Replying to falkb:

Vitali, this page says our problem function resource_filename() is located in setuptools . Have you properly installed that one?

I re-installed setuptools and also upgraded trac to 0.12.5, but the problem is the same

Traceback (most recent call last):
  File "/usr/lib/python2.4/site-packages/Trac-0.12.5-py2.4.egg/trac/web/api.py", line 458, in send_error
  File "/usr/lib/python2.4/site-packages/Trac-0.12.5-py2.4.egg/trac/web/chrome.py", line 836, in render_template
  File "/usr/lib/python2.4/site-packages/Trac-0.12.5-py2.4.egg/trac/web/chrome.py", line 796, in load_template
  File "/usr/lib/python2.4/site-packages/Trac-0.12.5-py2.4.egg/trac/web/chrome.py", line 511, in get_all_templates_dirs
  File "build/bdist.linux-x86_64/egg/simplemultiproject/admin.py", line 133, in get_templates_dirs
  File "/usr/lib/python2.4/site-packages/pkg_resources.py", line 16, in ?
    import sys, os, zipimport, time, re, imp, new
  File "/usr/lib64/python2.4/os.py", line 133, in ?
    from os.path import (curdir, pardir, sep, pathsep, defpath, extsep, altsep,
ImportError: No module named path

I'll try to hack get_templates_dirs

comment:6 follow-up: Changed 18 months ago by falkb

I must confess I never tried it with Python 2.4. Once I used Trac 0.12 I had Python 2.5, now I've got Trac 1.0 with Python 2.7 here.

comment:7 in reply to: ↑ 6 ; follow-up: Changed 18 months ago by vitali

Replying to falkb:

I must confess I never tried it with Python 2.4. Once I used Trac 0.12 I had Python 2.5, now I've got Trac 1.0 with Python 2.7 here.

I need to run trac on RHEL5 and it comes with Pyrthon 2.4.
I had run Trac 0.12 without any issue on Python 2.4 until I got the one described above

comment:8 in reply to: ↑ 7 ; follow-up: Changed 18 months ago by falkb

Replying to vitali:

I need to run trac on RHEL5 and it comes with Pyrthon 2.4.
I had run Trac 0.12 without any issue on Python 2.4 until I got the one described above

Python 2.4 is very old. I recommend at least 2.5 to you, look here how people had problems with setuptools and 2.4. In this link you can also see they use try-expect but I suspect it wouldn't help us to implement

    def get_templates_dirs(self):
        try:
            from pkg_resources import resource_filename
            return [resource_filename(__name__, 'templates')]
        except ImportError:
            return []

because then the calling code missed the path as described here in the Trac API docs.

Changed 18 months ago by vitali

comment:9 in reply to: ↑ 8 ; follow-up: Changed 18 months ago by vitali

Replying to falkb:

Replying to vitali:

I need to run trac on RHEL5 and it comes with Pyrthon 2.4.
I had run Trac 0.12 without any issue on Python 2.4 until I got the one described above

Python 2.4 is very old. I recommend at least 2.5 to you, look here how people had problems with setuptools and 2.4. In this link you can also see they use try-expect but I suspect it wouldn't help us to implement

    def get_templates_dirs(self):
        try:
            from pkg_resources import resource_filename
            return [resource_filename(__name__, 'templates')]
        except ImportError:
            return []

because then the calling code missed the path as described here in the Trac API docs.

Thank you very much for your quick and valuable responces.

I know that Python 2.4 is very old, and I'd gladly upgrade, but, unfortunately, it is not under my control.

Meanwhile, I replaced get_templates_dirs with a hard-coded path as you suggested:

def get_templates_dirs(self):
        return ['path_to_templates/templates']

Everything works fine, except Milestones, which does not have the Project field:



comment:10 in reply to: ↑ 9 ; follow-ups: Changed 18 months ago by falkb

Replying to vitali:

Everything works fine, except Milestones, which does not have the Project field:

As explained on wiki:SimpleMultiProjectPlugin#Example (Look for "Associate a milestone in a project"), you must use the Roadmap page to attach milestones to projects. Currently, there appropriate code for extending the pages in the Admin panel.

comment:11 in reply to: ↑ 10 Changed 18 months ago by falkb

Replying to falkb:

Currently, there appropriate code ...

Typo. Should be "Currently, there aint no appropriate code ..."

comment:12 in reply to: ↑ 10 ; follow-up: Changed 18 months ago by anonymous

As explained on wiki:SimpleMultiProjectPlugin#Example (Look for "Associate a milestone in a project"), you must use the Roadmap page to attach milestones to projects. Currently, there appropriate code for extending the pages in the Admin panel.

Everyhing works

Thank you very much for your help!!!

comment:13 in reply to: ↑ 12 Changed 18 months ago by falkb

Replying to anonymous:

Thank you very much for your help!!!

You're welcome. The problem still exists, that's why I think I keep this ticket open. Meanwhile I asked on the Trac development mailing-list

comment:14 follow-up: Changed 18 months ago by jun66j5

Reproduced. I checked log/trac.log and consider that simplemultiproject/version.py has two problems.

  1. Syntax error at ... if ... else ... with Python 2.4
  2. Import Error at import user_time with Trac 0.12.x

The following patch would be simple to remove using user_time.

  • simplemultiproject/version.py

     
    77from simplemultiproject.model import * 
    88 
    99#trac 
    10 from trac import __version__ as VERSION 
    1110from trac.attachment import AttachmentModule 
    1211from trac.config import ExtensionOption 
    1312from trac.core import * 
     
    2322                              get_datetime_format_hint, format_date, \ 
    2423                              format_datetime, from_utimestamp 
    2524 
    26 if VERSION > '0.12': 
    27     from trac.util.datefmt import user_time 
    28  
    2925from trac.web.api import IRequestHandler, IRequestFilter, ITemplateStreamFilter 
    3026from trac.web.chrome import add_link, add_notice, add_script, add_stylesheet, \ 
    3127                            add_warning, Chrome, INavigationContributor 
     
    229225 
    230226        if 'time' in req.args: 
    231227            time = req.args.get('time', '') 
    232             if VERSION <= '0.12': 
    233                 version.time = time and parse_date(time, req.tz, 'datetime') or None 
     228            if time: 
     229                version.time = parse_date(time, tzinfo=req.tz, 
     230                                          locale=req.locale, hint='datetime') 
    234231            else: 
    235                 version.time = user_time(req, parse_date, time, hint='datetime') if time else None 
     232                version.time = None 
    236233        else: 
    237234            version.time = None 
    238235 

comment:15 in reply to: ↑ 14 ; follow-up: Changed 18 months ago by falkb

Replying to jun66j5:

Reproduced. I checked log/trac.log and consider that simplemultiproject/version.py has two problems.

jun66j5, are you sure this is the right ticket? Your patch is for version.py though vitali reported a problem in admin.py. Second, your patch would revert [12453] which was a necessary port to make it work with Trac 1.0. What was the traceback in your case? Nevertheless thanks a lot for your attention to this problem here.

Changed 18 months ago by jun66j5

comment:16 in reply to: ↑ 15 Changed 18 months ago by jun66j5

Replying to falkb:

jun66j5, are you sure this is the right ticket? Your patch is for version.py though vitali reported a problem in admin.py.

Right. If failed on loading a plugin, import pkg_resouces.resource_filename failed. See attachment:0.12-t10798-trac.log.

Second, your patch would revert [12453] which was a necessary port to make it work with Trac 1.0. What was the traceback in your case?

If you want to work with Trac 0.12, it shouldn't use user_time.

Also, that code

    user_time(req, parse_date, time, hint='datetime')

works as the following with Trac 0.12 compatibility.

    parse_date(time, tzinfo=req.tz, locale=req.locale, hint='datetime')

comment:17 Changed 18 months ago by jun66j5

In addition, the check of Trac version is wrong. When Trac is 0.12.1 or later, that code will import user_time.

if VERSION > '0.12':
    from trac.util.datefmt import user_time

I think that it should be the following in that case.

try:
    from trac.util.datefmt import user_time
except ImportError:
    # if not needed, user_time = None
    def user_time(req, func, *args, **kwargs):
        """porting from 1.0-stable"""
        ...

comment:18 follow-ups: Changed 18 months ago by falkb

Hi jun66j5,

Replying to jun66j5:

Replying to falkb:

jun66j5, are you sure this is the right ticket? Your patch is for version.py though vitali reported a problem in admin.py.

Right. If failed on loading a plugin, import pkg_resouces.resource_filename failed. See attachment:0.12-t10798-trac.log.

Double-check: Do I understand right, that import error in admin.py is a subsequent error of a syntax error in version.py? And your patch includes the fix for admin.py as well?

If you want to work with Trac 0.12, it shouldn't use user_time.

Does it mean, your patch in 14 works for 0.12 _and_ 1.0?

comment:19 in reply to: ↑ 18 Changed 18 months ago by vitali

Double-check: Do I understand right, that import error in admin.py is a subsequent error of a syntax error in version.py? And your patch includes the fix for admin.py as well?

I did not connect it to the fail in admin.py, but I did see an error while compiling version.py

byte-compiling build/bdist.linux-x86_64/egg/simplemultiproject/version.py to version.pyc
  File "build/bdist.linux-x86_64/egg/simplemultiproject/version.py", line 235
    version.time = user_time(req, parse_date, time, hint='datetime') if time else None
                                                                      ^
SyntaxError: invalid syntax

Changed 18 months ago by jun66j5

comment:20 in reply to: ↑ 18 ; follow-up: Changed 18 months ago by jun66j5

Sorry. I've mistaken. New patch is here, t10798-2.diff.

Double-check: Do I understand right, that import error in admin.py is a subsequent error of a syntax error in version.py? And your patch includes the fix for admin.py as well?

Yes. The issue for admin.py is caused by SyntaxError and ImportError in version.py. The patch does NOT include any changes for admin.py, but it's right.

If you want to work with Trac 0.12, it shouldn't use user_time.

Does it mean, your patch in 14 works for 0.12 _and_ 1.0?

I tested with t10798-2.diff on Trac 0.12 and 1.0.

Vitali, could you please try the latest patch?

comment:21 follow-up: Changed 18 months ago by falkb

(In [12535]) Refs #10798: applied patch attachment:ticket:10798:t10798-2.diff of jun66j5 that fixes [12453]. Thanks a lot! Commit [12453] works for Trac 1.0 but led to Import errors in admin.py on Trac 0.12. This patch works for me with Trac 1.0.0

comment:22 in reply to: ↑ 20 Changed 18 months ago by vitali

Vitali, could you please try the latest patch?

t10798-2.diff works for me on Trac 0.12-5 with Python 2.4

Thank you very much

comment:23 in reply to: ↑ 21 ; follow-up: Changed 18 months ago by vitali

I also checked out [12535] to test, but when I tried to generate plugin .egg by running python setup.py bdist_egg

I got:

Traceback (most recent call last):
  File "setup.py", line 21, in ?
    entry_points = {'trac.plugins': ['simplemultiproject = simplemultiproject']}
  File "/usr/lib64/python2.4/distutils/core.py", line 149, in setup
    dist.run_commands()
  File "/usr/lib64/python2.4/distutils/dist.py", line 946, in run_commands
    self.run_command(cmd)
  File "/usr/lib64/python2.4/distutils/dist.py", line 966, in run_command
    cmd_obj.run()
  File "/usr/lib/python2.4/site-packages/setuptools/command/bdist_egg.py", line 167, in run
    self.run_command("egg_info")
  File "/usr/lib64/python2.4/distutils/cmd.py", line 333, in run_command
    self.distribution.run_command(command)
  File "/usr/lib64/python2.4/distutils/dist.py", line 966, in run_command
    cmd_obj.run()
  File "/usr/lib/python2.4/site-packages/setuptools/command/egg_info.py", line 171, in run
    self.find_sources()
  File "/usr/lib/python2.4/site-packages/setuptools/command/egg_info.py", line 252, in find_sources
    mm.run()
  File "/usr/lib/python2.4/site-packages/setuptools/command/egg_info.py", line 306, in run
    self.add_defaults()
  File "/usr/lib/python2.4/site-packages/setuptools/command/egg_info.py", line 333, in add_defaults
    rcfiles = list(walk_revctrl())
  File "/usr/lib/python2.4/site-packages/setuptools/command/sdist.py", line 45, in walk_revctrl
    for item in ep.load()(dirname):
  File "/usr/lib/python2.4/site-packages/setuptools/command/sdist.py", line 52, in _default_revctrl
    for path in finder(dirname,path):
  File "/usr/lib/python2.4/site-packages/setuptools/command/sdist.py", line 98, in entries_finder
    log.warn("unrecognized .svn/entries format in %s", dirname)
NameError: global name 'log' is not defined

comment:24 in reply to: ↑ 23 Changed 18 months ago by falkb

  • Resolution set to fixed
  • Status changed from assigned to closed

Replying to vitali:
...

File "/usr/lib/python2.4/site-packages/setuptools/command/sdist.py", line 98, in entries_finder

log.warn("unrecognized .svn/entries format in %s", dirname)

NameError: global name 'log' is not defined

Well, this is a known problem with a bad constellation of old versions of setuptool and svn. I've found some workarounds and tricks making it work somehow. I understood it as if setuptool has a little bug that bites you there. Just ask more here, if it doesn't work for you, maybe we can help you then.

Anyway, the actual problem is confirmed to be solved. Thanks a lot jun66j5.

Add Comment

Modify Ticket

Action
as closed .
as The resolution will be set. Next status will be 'closed'.
to The owner will be changed from falkb. Next status will be 'closed'.
The resolution will be deleted. Next status will be 'reopened'.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.