KeyError if default alias is not present. #945

Closed
opened 2010-02-11 14:07:40 +00:00 by jdn · 2 comments
Owner

I noticed that when I issue the command:

tahoe stats -d storage/

(notice the missing alias)
I get this KeyError:

Traceback (most recent call last):
  File "allmydata-tahoe-1.6.0/support/bin/tahoe", line 8, in <module>
    load_entry_point('allmydata-tahoe==1.6.0', 'console_scripts', 'tahoe')()
  File "allmydata-tahoe-1.6.0/src/allmydata/scripts/runner.py", line 102, in run
    rc = runner(sys.argv[1:])
  File "allmydata-tahoe-1.6.0/src/allmydata/scripts/runner.py", line 89, in runner
    rc = cli.dispatch[command](so)
  File "allmydata-tahoe-1.6.0/src/allmydata/scripts/cli.py", line 488, in stats
    rc = tahoe_manifest.stats(options)
  File "allmydata-tahoe-1.6.0/src/allmydata/scripts/tahoe_manifest.py", line 140, in stats
    return StatsGrabber().run(options)
  File "allmydata-tahoe-1.6.0/src/allmydata/scripts/slow_operation.py", line 20, in run
    rootcap, path = get_alias(options.aliases, where, DEFAULT_ALIAS)
  File "allmydata-tahoe-1.6.0/src/allmydata/scripts/common.py", line 150, in get_alias
    return aliases[default], path
KeyError: 'tahoe' 

I guess it is because the default alias "tahoe" is not defined, thus I have made the attached patch of src/scripts/common.py. The patch raises an UnknowAliasError instead of the KeyError.

149a150,151
>         if default not in aliases:
>             raise UnknownAliasError("Unknown default alias '%s', please create it with 'tahoe add-alias' or 'tahoe create-alias'." % default)

I am not sure that the message is as one would like.

I noticed that when I issue the command: > tahoe stats -d storage/ (notice the missing alias) I get this [KeyError](wiki/KeyError): ``` Traceback (most recent call last): File "allmydata-tahoe-1.6.0/support/bin/tahoe", line 8, in <module> load_entry_point('allmydata-tahoe==1.6.0', 'console_scripts', 'tahoe')() File "allmydata-tahoe-1.6.0/src/allmydata/scripts/runner.py", line 102, in run rc = runner(sys.argv[1:]) File "allmydata-tahoe-1.6.0/src/allmydata/scripts/runner.py", line 89, in runner rc = cli.dispatch[command](so) File "allmydata-tahoe-1.6.0/src/allmydata/scripts/cli.py", line 488, in stats rc = tahoe_manifest.stats(options) File "allmydata-tahoe-1.6.0/src/allmydata/scripts/tahoe_manifest.py", line 140, in stats return StatsGrabber().run(options) File "allmydata-tahoe-1.6.0/src/allmydata/scripts/slow_operation.py", line 20, in run rootcap, path = get_alias(options.aliases, where, DEFAULT_ALIAS) File "allmydata-tahoe-1.6.0/src/allmydata/scripts/common.py", line 150, in get_alias return aliases[default], path KeyError: 'tahoe' ``` I guess it is because the default alias "tahoe" is not defined, thus I have made the attached patch of src/scripts/common.py. The patch raises an [UnknowAliasError](wiki/UnknowAliasError) instead of the [KeyError](wiki/KeyError). ``` 149a150,151 > if default not in aliases: > raise UnknownAliasError("Unknown default alias '%s', please create it with 'tahoe add-alias' or 'tahoe create-alias'." % default) ``` I am not sure that the message is as one would like.
tahoe-lafs added the
code-frontend-cli
trivial
defect
1.6.0
labels 2010-02-11 14:07:40 +00:00
tahoe-lafs added this to the undecided milestone 2010-02-11 14:07:40 +00:00
Author
Owner

Attachment default_alias_common.patch (193 bytes) added

**Attachment** default_alias_common.patch (193 bytes) added
davidsarah commented 2010-02-12 03:00:22 +00:00
Author
Owner

Duplicate of #939, which has a more complete fix.

Duplicate of #939, which has a more complete fix.
tahoe-lafs added
major
duplicate
and removed
trivial
labels 2010-02-12 03:00:22 +00:00
tahoe-lafs modified the milestone from undecided to 1.7.0 2010-02-12 03:00:22 +00:00
tahoe-lafs modified the milestone from 1.7.0 to 1.6.1 2010-02-15 18:49:01 +00:00
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Reference: tahoe-lafs/trac-2024-07-25#945
No description provided.