Edgewall Software
Modify

Opened 15 years ago

Closed 15 years ago

Last modified 15 years ago

#8920 closed defect (fixed)

traceback on help in uninitialized environment

Reported by: anatoly techtonik <techtonik@…> Owned by: Remy Blank
Priority: normal Milestone: 0.12
Component: admin/console Version: 0.12dev
Severity: normal Keywords:
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description

(virtlast) M:\p\python\trac\virtlast>trac-admin _testenv
Welcome to trac-admin 0.12dev-r8987
Interactive Trac administration console.
Copyright (c) 2003-2009 Edgewall Software

Type:  '?' or 'help' for help on commands.

Trac [M:\p\python\trac\virtlast\_testenv]> ?
trac-admin - The Trac Administration Console 0.12dev-r8987
Failed to open environment. (2, 'No such file or directory')
Traceback (most recent call last):
  File "m:\p\python\trac\trac-0.12dev\trac\admin\console.py", line 157, in env
    self.__env = Environment(self.envname)
  File "m:\p\python\trac\trac-0.12dev\trac\env.py", line 214, in __init__
    self.verify()
  File "m:\p\python\trac\trac-0.12dev\trac\env.py", line 285, in verify
    fd = open(os.path.join(self.path, 'VERSION'), 'r')
IOError: [Errno 2] No such file or directory: 'M:\\p\\python\\trac\\virtlast\\_testenv\\VERSION'

Attachments (2)

8920.patch (519 bytes ) - added by Carsten Klein <carsten.klein@…> 15 years ago.
Proposed patch for resolving the issue
8920.patch.2 (620 bytes ) - added by Carsten Klein <carsten.klein@…> 15 years ago.
Corrected version of the patch

Download all attachments as: .zip

Change History (13)

comment:1 by Remy Blank, 15 years ago

Milestone: 0.120.12.1
Owner: set to Remy Blank

You mean, _testenv doesn't exist yet? That's a bit cosmetic, but yeah, it should give a more useful message.

comment:2 by anatoly techtonik <techtonik@…>, 15 years ago

Exactly. I actually wanted to get help on "initenv" command before issuing it with all required params.

comment:3 by Remy Blank, 15 years ago

You can use trac-admin help initenv (i.e. without specifying the environment).

comment:4 by Carsten Klein <carsten.klein@…>, 15 years ago

I think that the line

Failed to open environment. (2, 'No such file or directory')

provides sufficient information, so that we actually could close this, or, alternatively:

create the environment.

comment:5 by Carsten Klein <carsten.klein@…>, 15 years ago

Actually, this seems to be far more complex, as arbitrary commands entered will lead to exception traces such as below:

Trac [/tmp/test]> ragga
Failed to open environment. (2, 'No such file or directory')
Traceback (most recent call last):
  File "/usr/local/lib/python2.6/dist-packages/Trac-0.12dev_r0-py2.6.egg/trac/admin/console.py", line 158, in env
    self.__env = Environment(self.envname)
  File "/usr/local/lib/python2.6/dist-packages/Trac-0.12dev_r0-py2.6.egg/trac/env.py", line 216, in __init__
    self.verify()
  File "/usr/local/lib/python2.6/dist-packages/Trac-0.12dev_r0-py2.6.egg/trac/env.py", line 295, in verify
    fd = open(os.path.join(self.path, 'VERSION'), 'r')
IOError: [Errno 2] No such file or directory: '/tmp/test/VERSION'
AttributeError: 'NoneType' object has no attribute 'components'
Failed to open environment. (2, 'No such file or directory')
Traceback (most recent call last):
  File "/usr/local/lib/python2.6/dist-packages/Trac-0.12dev_r0-py2.6.egg/trac/admin/console.py", line 158, in env
    self.__env = Environment(self.envname)
  File "/usr/local/lib/python2.6/dist-packages/Trac-0.12dev_r0-py2.6.egg/trac/env.py", line 216, in __init__
    self.verify()
  File "/usr/local/lib/python2.6/dist-packages/Trac-0.12dev_r0-py2.6.egg/trac/env.py", line 295, in verify
    fd = open(os.path.join(self.path, 'VERSION'), 'r')
IOError: [Errno 2] No such file or directory: '/tmp/test/VERSION'
Traceback (most recent call last):
  File "/usr/local/bin/trac-admin", line 8, in <module>
    load_entry_point('Trac==0.12dev-r0', 'console_scripts', 'trac-admin')()
  File "/usr/local/lib/python2.6/dist-packages/Trac-0.12dev_r0-py2.6.egg/trac/admin/console.py", line 542, in run
    admin.run()
  File "/usr/local/lib/python2.6/dist-packages/Trac-0.12dev_r0-py2.6.egg/trac/admin/console.py", line 135, in run
    self.cmdloop()
  File "/usr/lib/python2.6/cmd.py", line 142, in cmdloop
    stop = self.onecmd(line)
  File "/usr/local/lib/python2.6/dist-packages/Trac-0.12dev_r0-py2.6.egg/trac/admin/console.py", line 122, in onecmd
    self.env.log.error("Exception in trac-admin command: %s",
AttributeError: 'NoneType' object has no attribute 'log'

comment:6 by Carsten Klein <carsten.klein@…>, 15 years ago

I would propose that when invoking trac with a non existing location or a location that is not a trac environment (whatever the criterias for this would be) will abort the operation and yield an appropriate message such as "Please use 'trac-admin <env-path> initenv' for initializing the environment first.".

in reply to:  6 comment:7 by Carsten Klein <carsten.klein@…>, 15 years ago

Replying to Carsten Klein <carsten.klein@…>:

I would propose that when invoking trac with a non existing location or a location that is not a trac environment (whatever the criterias for this would be) will abort the operation and yield an appropriate message such as "Please use 'trac-admin <env-path> initenv' for initializing the environment first.".

in case of an existing, non-empty location the operation should be aborted with an error message such as

"The specified location is not a trac environment." or something similar.

comment:8 by Carsten Klein <carsten.klein@…>, 15 years ago

See the proposed patch for resolving the issue.

by Carsten Klein <carsten.klein@…>, 15 years ago

Attachment: 8920.patch added

Proposed patch for resolving the issue

comment:9 by Carsten Klein <carsten.klein@…>, 15 years ago

Here is a corrected version of the patch. The former would cause trac-admin to stop working. Yet, when first integrating it, it seemed to work fine…

by Carsten Klein <carsten.klein@…>, 15 years ago

Attachment: 8920.patch.2 added

Corrected version of the patch

comment:10 by Remy Blank, 15 years ago

Milestone: 0.12.10.12
Resolution: fixed
Status: newclosed

The proper fix was a bit more involved, see [9400].

comment:11 by Carsten Klein <carsten.klein@…>, 15 years ago

Oh dear me, the previous patch did not do it, except preventing new environments from being created.

However, I found a solution, checking for 'initenv' not in args, but your solution seems more elaborate.

Thanks for working this out, great job!

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Remy Blank.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Remy Blank 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.