#10408 closed enhancement (fixed)
trac-admin: more descriptive error message on invalid env path
Reported by: | Owned by: | Remy Blank | |
---|---|---|---|
Priority: | normal | Milestone: | 1.0 |
Component: | admin/console | Version: | 0.12.2 |
Severity: | minor | Keywords: | bitesized |
Cc: | Thijs Triemstra | Branch: | |
Release Notes: | |||
API Changes: | |||
Internal Changes: |
Description
When wrong path is specified to trac-admin
you get the following confusing message:
$ trac-admin /var/trac upgrade Error: Command not found
Attachments (1)
Change History (13)
comment:1 by , 13 years ago
Keywords: | bitesized added |
---|---|
Milestone: | → next-major-0.1X |
Type: | defect → enhancement |
comment:2 by , 13 years ago
Cc: | added |
---|
comment:3 by , 13 years ago
I just finish to read the HowToContribute section, then I downloaded and setup the enviroment. Then I decided to fix a bitesized ticket.
I cloned the repository and I ran the "trac-admin" command and I saw a different message:
trac-admin /var/trac upgrade Error: IOError: [Errno 2] No such file or directory: '/var/trac/VERSION'
This error message need to be improved?
comment:4 by , 13 years ago
I see that the error message is improved already, but it can give an additional user-friendly hint.
comment:5 by , 13 years ago
The message is not ideal, as it references /var/trac/VERSION
and not the path entered on the command line. Ideally, we should check for the existence of the environment path and show a message if it doesn't exist, even before trying to open it.
comment:7 by , 12 years ago
Milestone: | next-major-0.1X → 1.0 |
---|---|
Owner: | set to |
Severity: | normal → minor |
Well, the message is misleading as there's no such environment variable VERSION
. We're talking about the file <trac-env>/VERSION
here!
follow-up: 10 comment:8 by , 12 years ago
-
trac/env.py
diff --git a/trac/env.py b/trac/env.py index 468e37d..ee0adfc 100644
a b class Environment(Component, ComponentManager): 364 364 def verify(self): 365 365 """Verify that the provided path points to a valid Trac environment 366 366 directory.""" 367 with open(os.path.join(self.path, 'VERSION'), 'r') as fd: 368 assert fd.read(26) == 'Trac Environment Version 1' 367 368 try: 369 with open(os.path.join(self.path, 'VERSION'), 'r') as fd: 370 assert fd.read(26) == 'Trac Environment Version 1' 371 except: 372 raise TracError(_('Trac environment is not found on the given path:\n %(enviroment_path)s.', 373 enviroment_path = os.path.join(self.path))) 369 374 370 375 def get_db_cnx(self): 371 376 """Return a database connection from the connection pool
comment:9 by , 12 years ago
Could you also please replace the use of assert
? It becomes a no-op when compiled with -O
. And use read()
instead of read(26)
, so that we differentiate between 'Trac Environment Version 1' and 'Trac Environment Version 13'. Actually, the best would be to use trac.util.read_file()
.
comment:10 by , 12 years ago
That's not my patch, bit I can edit it no problem (somebody need to insert from trac.util import read_file
:
-
trac/env.py
diff --git a/trac/env.py b/trac/env.py index 468e37d..ee0adfc 100644
a b class Environment(Component, ComponentManager): 364 364 def verify(self): 365 365 """Verify that the provided path points to a valid Trac environment 366 366 directory.""" 367 with open(os.path.join(self.path, 'VERSION'), 'r') as fd: 368 assert fd.read(26) == 'Trac Environment Version 1' 367 368 try: 369 if not read_file(os.path.join(self.path, 'VERSION')).startswith('Trac Environment Version 1'): 370 raise TracError(_('Bad VERSION content.')) 371 except: 372 raise TracError(_('Trac environment is not found on the given path:\n %(enviroment_path)s.', 373 enviroment_path = self.path)) 369 374 370 375 def get_db_cnx(self): 371 376 """Return a database connection from the connection pool
comment:12 by , 12 years ago
Owner: | changed from | to
---|
Yes, this could be improved.