Modify

Opened 17 years ago

Closed 14 years ago

Last modified 10 years ago

#1372 closed defect (duplicate)

[PATCH] crashes if there are non-project directories or other files in directory containing projects

Reported by: Max Zorloff Owned by: Noah Kantrowitz
Priority: high Component: ProjectMenuPlugin
Severity: major Keywords:
Cc: Trac Release: 0.10

Description (last modified by Ryan J Ollos)

the error is something like this:

Traceback (most recent call last):
  File "/usr/local/lib/python2.5/site-packages/trac/web/main.py", line 387, in dispatch_request
    dispatcher.dispatch(req)
  File "/usr/local/lib/python2.5/site-packages/trac/web/main.py", line 208, in dispatch
    chrome.populate_hdf(req, chosen_handler)
  File "/usr/local/lib/python2.5/site-packages/trac/web/chrome.py", line 319, in populate_hdf
    for category, name, text in contributor.get_navigation_items(req):
  File "build/bdist.linux-i686/egg/projectmenu/web_ui.py", line 21, in get_navigation_items
    proj_env = _open_environment(os.path.join(search_path, project))
  File "/usr/local/lib/python2.5/site-packages/trac/web/main.py", line 58, in _open_environment
    env_cache[env_path] = open_environment(env_path)
  File "/usr/local/lib/python2.5/site-packages/trac/env.py", line 434, in open_environment
    env = Environment(env_path)
  File "/usr/local/lib/python2.5/site-packages/trac/env.py", line 126, in __init__
    self.verify()
  File "/usr/local/lib/python2.5/site-packages/trac/env.py", line 174, in verify
    fd = open(os.path.join(self.path, 'VERSION'), 'r')
IOError: [Errno 2] No such file or directory: '/home/mmm/VERSION'

Attachments (0)

Change History (5)

comment:1 Changed 17 years ago by pj@…

This patch is fairly self explanatory and fixes this bug.

Index: projectmenu/web_ui.py
===================================================================
--- projectmenu/web_ui.py       (revision 2669)
+++ projectmenu/web_ui.py       (working copy)
@@ -18,11 +18,17 @@
         
         for project in os.listdir(search_path):
             if project != this_project:
-                proj_env = _open_environment(os.path.join(search_path, project))
+               try:
+                    proj_env = _open_environment(os.path.join(search_path, project))
                 
-                proj_elm = tag.OPTION(proj_env.project_name, value=posixpath.join(base_url, project))
+                    proj_elm = tag.OPTION(proj_env.project_name, value=posixpath.join(base_url, project))
                 
-                projects.append((proj_elm, proj_env.project_name))
+                    projects.append((proj_elm, proj_env.project_name))
+               except IOError:
+                   # IOError means there was a problem reading this
+                   # potential trac instance - it's probably not really
+                   # an instance, so skip it
+                   pass  
         projects.sort(lambda a,b: cmp(a[1],b[1])) # Sort on the project names
         projects.insert(0, (tag.OPTION(self.env.project_name, value=''), None))

Version 0, edited 17 years ago by pj@… (next)

comment:2 Changed 17 years ago by anonymous

I applied this patches on à 0.10 environement and it works perfectly.

thanks

comment:3 Changed 14 years ago by Adrian Fritz

Resolution: duplicate
Status: newclosed
Summary: crashes if there are non-project directories or other files in directory containing projects[PATCH] crashes if there are non-project directories or other files in directory containing projects

Seems to be a duplicate of #1301, which also have a [PATCH]. Please reopen if different case.

comment:4 Changed 10 years ago by Ryan J Ollos

Description: modified (diff)

comment:5 Changed 10 years ago by Ryan J Ollos

In 14053:

2.0dev: Skip directories that aren't Trac environments. Fixes #1301, Refs #1372.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Noah Kantrowitz.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


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

 
Note: See TracTickets for help on using tickets.