the CLI should fail gracefully when tahoe: doesn't exist and no alias is specified #939

Closed
opened 2010-02-07 20:00:01 +00:00 by kevan · 15 comments
kevan commented 2010-02-07 20:00:01 +00:00
Owner

When I do 'tahoe ls' on a fresh node, I get

kevan@b8chem-87:~$ tahoe ls
Traceback (most recent call last):
  File "/home/kevan/Desktop/software/tahoe/allmydata-tahoe-1.6.0/support/bin/tahoe", line 8, in <module>
    load_entry_point('allmydata-tahoe==1.6.0', 'console_scripts', 'tahoe')()
  File "/home/kevan/Desktop/software/tahoe/allmydata-tahoe-1.6.0/src/allmydata/scripts/runner.py", line 102, in run
    rc = runner(sys.argv[1:])
  File "/home/kevan/Desktop/software/tahoe/allmydata-tahoe-1.6.0/src/allmydata/scripts/runner.py", line 89, in runner
    rc = cli.dispatch[command](so)
  File "/home/kevan/Desktop/software/tahoe/allmydata-tahoe-1.6.0/src/allmydata/scripts/cli.py", line 429, in list
    rc = tahoe_ls.list(options)
  File "/home/kevan/Desktop/software/tahoe/allmydata-tahoe-1.6.0/src/allmydata/scripts/tahoe_ls.py", line 18, in list
    rootcap, path = get_alias(aliases, where, DEFAULT_ALIAS)
  File "/home/kevan/Desktop/software/tahoe/allmydata-tahoe-1.6.0/src/allmydata/scripts/common.py", line 150, in get_alias
    return aliases[default], path
KeyError: 'tahoe'
kevan@b8chem-87:~$ 

If I create an alias, then try again, I get

kevan@b8chem-87:~$ tahoe create-alias havasu
Alias 'havasu' created
kevan@b8chem-87:~$ tahoe ls
Traceback (most recent call last):
  File "/home/kevan/Desktop/software/tahoe/allmydata-tahoe-1.6.0/support/bin/tahoe", line 8, in <module>
    load_entry_point('allmydata-tahoe==1.6.0', 'console_scripts', 'tahoe')()
  File "/home/kevan/Desktop/software/tahoe/allmydata-tahoe-1.6.0/src/allmydata/scripts/runner.py", line 102, in run
    rc = runner(sys.argv[1:])
  File "/home/kevan/Desktop/software/tahoe/allmydata-tahoe-1.6.0/src/allmydata/scripts/runner.py", line 89, in runner
    rc = cli.dispatch[command](so)
  File "/home/kevan/Desktop/software/tahoe/allmydata-tahoe-1.6.0/src/allmydata/scripts/cli.py", line 429, in list
    rc = tahoe_ls.list(options)
  File "/home/kevan/Desktop/software/tahoe/allmydata-tahoe-1.6.0/src/allmydata/scripts/tahoe_ls.py", line 18, in list
    rootcap, path = get_alias(aliases, where, DEFAULT_ALIAS)
  File "/home/kevan/Desktop/software/tahoe/allmydata-tahoe-1.6.0/src/allmydata/scripts/common.py", line 150, in get_alias
    return aliases[default], path
KeyError: 'tahoe'
kevan@b8chem-87:~$ 

I should probably see something like

kevan@b8chem-87:~$ tahoe ls
Usage:  tahoe <command> [command options] ls [options]
Options:
  -q, --quiet             Operate silently.
  -V, --version           Display version numbers and exit.
      --version-and-path  Display version numbers and paths to their locations
                          and exit.
  -l, --long              Use long format: show file sizes, and timestamps
      --uri               Show file/directory URIs
      --readonly-uri      Show readonly file/directory URIs
  -F, --classify          Append '/' to directory names, and '*' to mutable
      --json              Show the raw JSON output
  -d, --node-directory=   Look here to find out which Tahoe node should be used
                          for all operations. The directory should either
                          contain a full Tahoe node, or a file named node.url
                          which points to some other Tahoe node. It should also
                          contain a file named private/aliases which contains
                          the mapping from alias name to root dirnode URI.
                          [default: ~/.tahoe]
  -u, --node-url=         URL of the tahoe node to use, a URL like
                          "http://127.0.0.1:3456". This overrides the URL found
                          in the --node-directory .
      --dir-cap=          Which dirnode URI should be used as the 'tahoe' alias.
      --help              Display this help and exit.

List the contents of some portion of the grid.

error: no alias specified, and the default 'tahoe' alias doesn't exist.
kevan@b8chem-87:~$ 

or, perhaps better still, the CLI code could look in ~/.tahoe/private/aliases and choose one of those instead of requiring the 'tahoe' alias (failing gracefully with something like the message above if nothing is there, of course).

When I do 'tahoe ls' on a fresh node, I get ``` kevan@b8chem-87:~$ tahoe ls Traceback (most recent call last): File "/home/kevan/Desktop/software/tahoe/allmydata-tahoe-1.6.0/support/bin/tahoe", line 8, in <module> load_entry_point('allmydata-tahoe==1.6.0', 'console_scripts', 'tahoe')() File "/home/kevan/Desktop/software/tahoe/allmydata-tahoe-1.6.0/src/allmydata/scripts/runner.py", line 102, in run rc = runner(sys.argv[1:]) File "/home/kevan/Desktop/software/tahoe/allmydata-tahoe-1.6.0/src/allmydata/scripts/runner.py", line 89, in runner rc = cli.dispatch[command](so) File "/home/kevan/Desktop/software/tahoe/allmydata-tahoe-1.6.0/src/allmydata/scripts/cli.py", line 429, in list rc = tahoe_ls.list(options) File "/home/kevan/Desktop/software/tahoe/allmydata-tahoe-1.6.0/src/allmydata/scripts/tahoe_ls.py", line 18, in list rootcap, path = get_alias(aliases, where, DEFAULT_ALIAS) File "/home/kevan/Desktop/software/tahoe/allmydata-tahoe-1.6.0/src/allmydata/scripts/common.py", line 150, in get_alias return aliases[default], path KeyError: 'tahoe' kevan@b8chem-87:~$ ``` If I create an alias, then try again, I get ``` kevan@b8chem-87:~$ tahoe create-alias havasu Alias 'havasu' created kevan@b8chem-87:~$ tahoe ls Traceback (most recent call last): File "/home/kevan/Desktop/software/tahoe/allmydata-tahoe-1.6.0/support/bin/tahoe", line 8, in <module> load_entry_point('allmydata-tahoe==1.6.0', 'console_scripts', 'tahoe')() File "/home/kevan/Desktop/software/tahoe/allmydata-tahoe-1.6.0/src/allmydata/scripts/runner.py", line 102, in run rc = runner(sys.argv[1:]) File "/home/kevan/Desktop/software/tahoe/allmydata-tahoe-1.6.0/src/allmydata/scripts/runner.py", line 89, in runner rc = cli.dispatch[command](so) File "/home/kevan/Desktop/software/tahoe/allmydata-tahoe-1.6.0/src/allmydata/scripts/cli.py", line 429, in list rc = tahoe_ls.list(options) File "/home/kevan/Desktop/software/tahoe/allmydata-tahoe-1.6.0/src/allmydata/scripts/tahoe_ls.py", line 18, in list rootcap, path = get_alias(aliases, where, DEFAULT_ALIAS) File "/home/kevan/Desktop/software/tahoe/allmydata-tahoe-1.6.0/src/allmydata/scripts/common.py", line 150, in get_alias return aliases[default], path KeyError: 'tahoe' kevan@b8chem-87:~$ ``` I should probably see something like ``` kevan@b8chem-87:~$ tahoe ls Usage: tahoe <command> [command options] ls [options] Options: -q, --quiet Operate silently. -V, --version Display version numbers and exit. --version-and-path Display version numbers and paths to their locations and exit. -l, --long Use long format: show file sizes, and timestamps --uri Show file/directory URIs --readonly-uri Show readonly file/directory URIs -F, --classify Append '/' to directory names, and '*' to mutable --json Show the raw JSON output -d, --node-directory= Look here to find out which Tahoe node should be used for all operations. The directory should either contain a full Tahoe node, or a file named node.url which points to some other Tahoe node. It should also contain a file named private/aliases which contains the mapping from alias name to root dirnode URI. [default: ~/.tahoe] -u, --node-url= URL of the tahoe node to use, a URL like "http://127.0.0.1:3456". This overrides the URL found in the --node-directory . --dir-cap= Which dirnode URI should be used as the 'tahoe' alias. --help Display this help and exit. List the contents of some portion of the grid. error: no alias specified, and the default 'tahoe' alias doesn't exist. kevan@b8chem-87:~$ ``` or, perhaps better still, the CLI code could look in ~/.tahoe/private/aliases and choose one of those instead of requiring the 'tahoe' alias (failing gracefully with something like the message above if nothing is there, of course).
tahoe-lafs added the
code-frontend-cli
major
defect
1.6.0
labels 2010-02-07 20:00:01 +00:00
tahoe-lafs added this to the undecided milestone 2010-02-07 20:00:01 +00:00
kevan commented 2010-02-07 22:01:20 +00:00
Author
Owner

Here is a test that exercises the first case above and fails.

(whether or not we'd want to have a distinct test for having aliases none of which are called tahoe depends on how this is solved)

Here is a test that exercises the first case above and fails. (whether or not we'd want to have a distinct test for having aliases none of which are called tahoe depends on how this is solved)
kevan commented 2010-02-07 22:01:41 +00:00
Author
Owner

Attachment 939test.darcspatch.txt (2182 bytes) added

**Attachment** 939test.darcspatch.txt (2182 bytes) added
kevan commented 2010-02-07 22:42:41 +00:00
Author
Owner

Other CLI commands process the alias in the same way as ls, though. Let's see how they do it.

(the 'tahoe-test' node has no aliases)

'tahoe backup'

pathos:~ kacarstensen$ tahoe backup -d tahoe-test entab.c software
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/Current/bin/tahoe", line 8, in <module>
    load_entry_point('allmydata-tahoe==1.6.0-r4228', 'console_scripts', 'tahoe')()
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/allmydata_tahoe-1.6.0_r4228-py2.6.egg/allmydata/scripts/runner.py", line 102, in run
    rc = runner(sys.argv[1:])
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/allmydata_tahoe-1.6.0_r4228-py2.6.egg/allmydata/scripts/runner.py", line 89, in runner
    rc = cli.dispatch[command](so)
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/allmydata_tahoe-1.6.0_r4228-py2.6.egg/allmydata/scripts/cli.py", line 473, in backup
    rc = tahoe_backup.backup(options)
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/allmydata_tahoe-1.6.0_r4228-py2.6.egg/allmydata/scripts/tahoe_backup.py", line 311, in backup
    return bu.run()
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/allmydata_tahoe-1.6.0_r4228-py2.6.egg/allmydata/scripts/tahoe_backup.py", line 95, in run
    rootcap, path = get_alias(options.aliases, options.to_dir, DEFAULT_ALIAS)
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/allmydata_tahoe-1.6.0_r4228-py2.6.egg/allmydata/scripts/common.py", line 150, in get_alias
    return aliases[default], path
KeyError: 'tahoe'

'tahoe check'

pathos:~ kacarstensen$ tahoe check -d tahoe-test 
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/Current/bin/tahoe", line 8, in <module>
    load_entry_point('allmydata-tahoe==1.6.0-r4228', 'console_scripts', 'tahoe')()
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/allmydata_tahoe-1.6.0_r4228-py2.6.egg/allmydata/scripts/runner.py", line 102, in run
    rc = runner(sys.argv[1:])
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/allmydata_tahoe-1.6.0_r4228-py2.6.egg/allmydata/scripts/runner.py", line 89, in runner
    rc = cli.dispatch[command](so)
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/allmydata_tahoe-1.6.0_r4228-py2.6.egg/allmydata/scripts/cli.py", line 493, in check
    rc = tahoe_check.check(options)
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/allmydata_tahoe-1.6.0_r4228-py2.6.egg/allmydata/scripts/tahoe_check.py", line 18, in check
    rootcap, path = get_alias(options.aliases, where, DEFAULT_ALIAS)
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/allmydata_tahoe-1.6.0_r4228-py2.6.egg/allmydata/scripts/common.py", line 150, in get_alias
    return aliases[default], path
KeyError: 'tahoe'

'tahoe cp'

pathos:~ kacarstensen$ tahoe cp -d tahoe-test entab.c dest
Success: file copied 

'tahoe get'

pathos:~ kacarstensen$ tahoe get -d tahoe-test file
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/Current/bin/tahoe", line 8, in <module>
    load_entry_point('allmydata-tahoe==1.6.0-r4228', 'console_scripts', 'tahoe')()
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/allmydata_tahoe-1.6.0_r4228-py2.6.egg/allmydata/scripts/runner.py", line 102, in run
    rc = runner(sys.argv[1:])
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/allmydata_tahoe-1.6.0_r4228-py2.6.egg/allmydata/scripts/runner.py", line 89, in runner
    rc = cli.dispatch[command](so)
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/allmydata_tahoe-1.6.0_r4228-py2.6.egg/allmydata/scripts/cli.py", line 434, in get
    rc = tahoe_get.get(options)
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/allmydata_tahoe-1.6.0_r4228-py2.6.egg/allmydata/scripts/tahoe_get.py", line 16, in get
    rootcap, path = get_alias(aliases, from_file, DEFAULT_ALIAS)
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/allmydata_tahoe-1.6.0_r4228-py2.6.egg/allmydata/scripts/common.py", line 150, in get_alias
    return aliases[default], path
KeyError: 'tahoe'

'tahoe manifest'

pathos:~ kacarstensen$ tahoe manifest -d tahoe-test
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/Current/bin/tahoe", line 8, in <module>
    load_entry_point('allmydata-tahoe==1.6.0-r4228', 'console_scripts', 'tahoe')()
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/allmydata_tahoe-1.6.0_r4228-py2.6.egg/allmydata/scripts/runner.py", line 102, in run
    rc = runner(sys.argv[1:])
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/allmydata_tahoe-1.6.0_r4228-py2.6.egg/allmydata/scripts/runner.py", line 89, in runner
    rc = cli.dispatch[command](so)
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/allmydata_tahoe-1.6.0_r4228-py2.6.egg/allmydata/scripts/cli.py", line 483, in manifest
    rc = tahoe_manifest.manifest(options)
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/allmydata_tahoe-1.6.0_r4228-py2.6.egg/allmydata/scripts/tahoe_manifest.py", line 87, in manifest
    return ManifestStreamer().run(options)
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/allmydata_tahoe-1.6.0_r4228-py2.6.egg/allmydata/scripts/tahoe_manifest.py", line 28, in run
    rootcap, path = get_alias(options.aliases, where, DEFAULT_ALIAS)
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/allmydata_tahoe-1.6.0_r4228-py2.6.egg/allmydata/scripts/common.py", line 150, in get_alias
    return aliases[default], path
KeyError: 'tahoe'

'tahoe mkdir'

pathos:~ kacarstensen$ tahoe mkdir -d tahoe-test
URI:DIR2:<dircap>

'tahoe mv'

pathos:~ kacarstensen$ tahoe mv -d tahoe-test afile anotherfile
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/Current/bin/tahoe", line 8, in <module>
    load_entry_point('allmydata-tahoe==1.6.0-r4228', 'console_scripts', 'tahoe')()
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/allmydata_tahoe-1.6.0_r4228-py2.6.egg/allmydata/scripts/runner.py", line 102, in run
    rc = runner(sys.argv[1:])
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/allmydata_tahoe-1.6.0_r4228-py2.6.egg/allmydata/scripts/runner.py", line 89, in runner
    rc = cli.dispatch[command](so)
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/allmydata_tahoe-1.6.0_r4228-py2.6.egg/allmydata/scripts/cli.py", line 463, in mv
    rc = tahoe_mv.mv(options, mode="move")
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/allmydata_tahoe-1.6.0_r4228-py2.6.egg/allmydata/scripts/tahoe_mv.py", line 20, in mv
    rootcap, from_path = get_alias(aliases, from_file, DEFAULT_ALIAS)
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/allmydata_tahoe-1.6.0_r4228-py2.6.egg/allmydata/scripts/common.py", line 150, in get_alias
    return aliases[default], path
KeyError: 'tahoe'

'tahoe put'

pathos:~ kacarstensen$ tahoe put -d tahoe-test a.out
200 OK
URI:CHK:<cap>

'tahoe rm'

pathos:~ kacarstensen$ tahoe rm -d tahoe-test afile
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/Current/bin/tahoe", line 8, in <module>
    load_entry_point('allmydata-tahoe==1.6.0-r4228', 'console_scripts', 'tahoe')()
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/allmydata_tahoe-1.6.0_r4228-py2.6.egg/allmydata/scripts/runner.py", line 102, in run
    rc = runner(sys.argv[1:])
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/allmydata_tahoe-1.6.0_r4228-py2.6.egg/allmydata/scripts/runner.py", line 89, in runner
    rc = cli.dispatch[command](so)
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/allmydata_tahoe-1.6.0_r4228-py2.6.egg/allmydata/scripts/cli.py", line 458, in rm
    rc = tahoe_rm.rm(options)
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/allmydata_tahoe-1.6.0_r4228-py2.6.egg/allmydata/scripts/tahoe_rm.py", line 18, in rm
    rootcap, path = get_alias(aliases, where, DEFAULT_ALIAS)
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/allmydata_tahoe-1.6.0_r4228-py2.6.egg/allmydata/scripts/common.py", line 150, in get_alias
    return aliases[default], path
KeyError: 'tahoe'

'tahoe webopen'

pathos:~ kacarstensen$ tahoe webopen -d tahoe-test
pathos:~ kacarstensen$ 

So I guess this isn't specific to 'tahoe ls', but instead is something that relates to many CLI tools. I'm updating the summary accordingly.

Other CLI commands process the alias in the same way as ls, though. Let's see how they do it. (the 'tahoe-test' node has no aliases) 'tahoe backup' ``` pathos:~ kacarstensen$ tahoe backup -d tahoe-test entab.c software Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/Current/bin/tahoe", line 8, in <module> load_entry_point('allmydata-tahoe==1.6.0-r4228', 'console_scripts', 'tahoe')() File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/allmydata_tahoe-1.6.0_r4228-py2.6.egg/allmydata/scripts/runner.py", line 102, in run rc = runner(sys.argv[1:]) File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/allmydata_tahoe-1.6.0_r4228-py2.6.egg/allmydata/scripts/runner.py", line 89, in runner rc = cli.dispatch[command](so) File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/allmydata_tahoe-1.6.0_r4228-py2.6.egg/allmydata/scripts/cli.py", line 473, in backup rc = tahoe_backup.backup(options) File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/allmydata_tahoe-1.6.0_r4228-py2.6.egg/allmydata/scripts/tahoe_backup.py", line 311, in backup return bu.run() File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/allmydata_tahoe-1.6.0_r4228-py2.6.egg/allmydata/scripts/tahoe_backup.py", line 95, in run rootcap, path = get_alias(options.aliases, options.to_dir, DEFAULT_ALIAS) File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/allmydata_tahoe-1.6.0_r4228-py2.6.egg/allmydata/scripts/common.py", line 150, in get_alias return aliases[default], path KeyError: 'tahoe' ``` 'tahoe check' ``` pathos:~ kacarstensen$ tahoe check -d tahoe-test Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/Current/bin/tahoe", line 8, in <module> load_entry_point('allmydata-tahoe==1.6.0-r4228', 'console_scripts', 'tahoe')() File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/allmydata_tahoe-1.6.0_r4228-py2.6.egg/allmydata/scripts/runner.py", line 102, in run rc = runner(sys.argv[1:]) File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/allmydata_tahoe-1.6.0_r4228-py2.6.egg/allmydata/scripts/runner.py", line 89, in runner rc = cli.dispatch[command](so) File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/allmydata_tahoe-1.6.0_r4228-py2.6.egg/allmydata/scripts/cli.py", line 493, in check rc = tahoe_check.check(options) File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/allmydata_tahoe-1.6.0_r4228-py2.6.egg/allmydata/scripts/tahoe_check.py", line 18, in check rootcap, path = get_alias(options.aliases, where, DEFAULT_ALIAS) File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/allmydata_tahoe-1.6.0_r4228-py2.6.egg/allmydata/scripts/common.py", line 150, in get_alias return aliases[default], path KeyError: 'tahoe' ``` 'tahoe cp' ``` pathos:~ kacarstensen$ tahoe cp -d tahoe-test entab.c dest Success: file copied ``` 'tahoe get' ``` pathos:~ kacarstensen$ tahoe get -d tahoe-test file Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/Current/bin/tahoe", line 8, in <module> load_entry_point('allmydata-tahoe==1.6.0-r4228', 'console_scripts', 'tahoe')() File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/allmydata_tahoe-1.6.0_r4228-py2.6.egg/allmydata/scripts/runner.py", line 102, in run rc = runner(sys.argv[1:]) File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/allmydata_tahoe-1.6.0_r4228-py2.6.egg/allmydata/scripts/runner.py", line 89, in runner rc = cli.dispatch[command](so) File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/allmydata_tahoe-1.6.0_r4228-py2.6.egg/allmydata/scripts/cli.py", line 434, in get rc = tahoe_get.get(options) File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/allmydata_tahoe-1.6.0_r4228-py2.6.egg/allmydata/scripts/tahoe_get.py", line 16, in get rootcap, path = get_alias(aliases, from_file, DEFAULT_ALIAS) File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/allmydata_tahoe-1.6.0_r4228-py2.6.egg/allmydata/scripts/common.py", line 150, in get_alias return aliases[default], path KeyError: 'tahoe' ``` 'tahoe manifest' ``` pathos:~ kacarstensen$ tahoe manifest -d tahoe-test Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/Current/bin/tahoe", line 8, in <module> load_entry_point('allmydata-tahoe==1.6.0-r4228', 'console_scripts', 'tahoe')() File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/allmydata_tahoe-1.6.0_r4228-py2.6.egg/allmydata/scripts/runner.py", line 102, in run rc = runner(sys.argv[1:]) File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/allmydata_tahoe-1.6.0_r4228-py2.6.egg/allmydata/scripts/runner.py", line 89, in runner rc = cli.dispatch[command](so) File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/allmydata_tahoe-1.6.0_r4228-py2.6.egg/allmydata/scripts/cli.py", line 483, in manifest rc = tahoe_manifest.manifest(options) File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/allmydata_tahoe-1.6.0_r4228-py2.6.egg/allmydata/scripts/tahoe_manifest.py", line 87, in manifest return ManifestStreamer().run(options) File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/allmydata_tahoe-1.6.0_r4228-py2.6.egg/allmydata/scripts/tahoe_manifest.py", line 28, in run rootcap, path = get_alias(options.aliases, where, DEFAULT_ALIAS) File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/allmydata_tahoe-1.6.0_r4228-py2.6.egg/allmydata/scripts/common.py", line 150, in get_alias return aliases[default], path KeyError: 'tahoe' ``` 'tahoe mkdir' ``` pathos:~ kacarstensen$ tahoe mkdir -d tahoe-test URI:DIR2:<dircap> ``` 'tahoe mv' ``` pathos:~ kacarstensen$ tahoe mv -d tahoe-test afile anotherfile Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/Current/bin/tahoe", line 8, in <module> load_entry_point('allmydata-tahoe==1.6.0-r4228', 'console_scripts', 'tahoe')() File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/allmydata_tahoe-1.6.0_r4228-py2.6.egg/allmydata/scripts/runner.py", line 102, in run rc = runner(sys.argv[1:]) File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/allmydata_tahoe-1.6.0_r4228-py2.6.egg/allmydata/scripts/runner.py", line 89, in runner rc = cli.dispatch[command](so) File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/allmydata_tahoe-1.6.0_r4228-py2.6.egg/allmydata/scripts/cli.py", line 463, in mv rc = tahoe_mv.mv(options, mode="move") File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/allmydata_tahoe-1.6.0_r4228-py2.6.egg/allmydata/scripts/tahoe_mv.py", line 20, in mv rootcap, from_path = get_alias(aliases, from_file, DEFAULT_ALIAS) File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/allmydata_tahoe-1.6.0_r4228-py2.6.egg/allmydata/scripts/common.py", line 150, in get_alias return aliases[default], path KeyError: 'tahoe' ``` 'tahoe put' ``` pathos:~ kacarstensen$ tahoe put -d tahoe-test a.out 200 OK URI:CHK:<cap> ``` 'tahoe rm' ``` pathos:~ kacarstensen$ tahoe rm -d tahoe-test afile Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/Current/bin/tahoe", line 8, in <module> load_entry_point('allmydata-tahoe==1.6.0-r4228', 'console_scripts', 'tahoe')() File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/allmydata_tahoe-1.6.0_r4228-py2.6.egg/allmydata/scripts/runner.py", line 102, in run rc = runner(sys.argv[1:]) File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/allmydata_tahoe-1.6.0_r4228-py2.6.egg/allmydata/scripts/runner.py", line 89, in runner rc = cli.dispatch[command](so) File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/allmydata_tahoe-1.6.0_r4228-py2.6.egg/allmydata/scripts/cli.py", line 458, in rm rc = tahoe_rm.rm(options) File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/allmydata_tahoe-1.6.0_r4228-py2.6.egg/allmydata/scripts/tahoe_rm.py", line 18, in rm rootcap, path = get_alias(aliases, where, DEFAULT_ALIAS) File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/allmydata_tahoe-1.6.0_r4228-py2.6.egg/allmydata/scripts/common.py", line 150, in get_alias return aliases[default], path KeyError: 'tahoe' ``` 'tahoe webopen' ``` pathos:~ kacarstensen$ tahoe webopen -d tahoe-test pathos:~ kacarstensen$ ``` So I guess this isn't specific to 'tahoe ls', but instead is something that relates to many CLI tools. I'm updating the summary accordingly.
tahoe-lafs changed title from 'tahoe ls': fail gracefully when tahoe: doesn't exist and no alias is specified to the CLI should fail gracefully when tahoe: doesn't exist and no alias is specified 2010-02-07 22:42:41 +00:00

I like the error: no alias specified, and the default 'tahoe' alias doesn't exist. message. I'd like it even better it we added a second line with instructions: To create one, use "tahoe create-alias tahoe".

And yeah, some CLI commands make as much (or more) sense without an alias.. "tahoe mkdir", "tahoe put", "tahoe get" are frequently used with raw caps, either accepting or returning them. It's the commands that always require aliases that are in most need of this improved error message.

I like the `error: no alias specified, and the default 'tahoe' alias doesn't exist.` message. I'd like it even better it we added a second line with instructions: `To create one, use "tahoe create-alias tahoe"`. And yeah, some CLI commands make as much (or more) sense without an alias.. "tahoe mkdir", "tahoe put", "tahoe get" are frequently used with raw caps, either accepting or returning them. It's the commands that always require aliases that are in most need of this improved error message.
davidsarah commented 2010-02-08 05:06:29 +00:00
Author
Owner

#681 was a duplicate for tahoe ls. I've kept this ticket because it is more general and has more information.

#681 was a duplicate for `tahoe ls`. I've kept this ticket because it is more general and has more information.
tahoe-lafs modified the milestone from undecided to 1.7.0 2010-02-08 05:06:29 +00:00
kevan commented 2010-02-11 02:51:44 +00:00
Author
Owner

I'm attaching a patch that I think fixes this, and a few other problems related to explicitly specified aliases that don't exist.

When you invoke a command with no alias when tahoe: doesn't exist, or with an explicit alias that doesn't exist, you'll see something like:

wlan98-239:tahoe-1.6 kacarstensen$ ./bin/tahoe webopen fake:
error: Unknown alias 'fake', please create it with 'tahoe add-alias' or 'tahoe create-alias'.

or

wlan1-92:tahoe-1.6 kacarstensen$ ./bin/tahoe get -d ~/tahoe-test fake
error: No alias specified, and the default 'tahoe' alias doesn't exist. To create it, use 'tahoe create-alias tahoe'.
I'm attaching a patch that I think fixes this, and a few other problems related to explicitly specified aliases that don't exist. When you invoke a command with no alias when `tahoe:` doesn't exist, or with an explicit alias that doesn't exist, you'll see something like: ``` wlan98-239:tahoe-1.6 kacarstensen$ ./bin/tahoe webopen fake: error: Unknown alias 'fake', please create it with 'tahoe add-alias' or 'tahoe create-alias'. ``` or ``` wlan1-92:tahoe-1.6 kacarstensen$ ./bin/tahoe get -d ~/tahoe-test fake error: No alias specified, and the default 'tahoe' alias doesn't exist. To create it, use 'tahoe create-alias tahoe'. ```
kevan commented 2010-02-11 02:52:28 +00:00
Author
Owner

Attachment 939.darcspatch.txt (15757 bytes) added

fixes for #939

**Attachment** 939.darcspatch.txt (15757 bytes) added fixes for #939
davidsarah commented 2010-02-11 05:42:46 +00:00
Author
Owner

I can't see any problems in the code.

In the tests patch:

  • on line 30, "C:\Windows" should be "C:\\Windows".
  • on line 71, the basedir should be cli/Ln/ln_with_nonexistent_alias, not cli/Ln/ln_without_alias.
  • the string passed to failUnlessIn is sometimes "error", sometimes "error:", and sometimes "error: ". Make it consistent.
  • the file open calls should use "wb" for the mode.

Also, tahoe webopen with no arguments currently raises TypeError: object of type 'NoneType' has no len() (#855). Either fix this, or add a TODO comment referencing #855 where the relevant test would be.

I can't see any problems in the code. In the tests patch: * on line 30, `"C:\Windows"` should be `"C:\\Windows"`. * on line 71, the basedir should be `cli/Ln/ln_with_nonexistent_alias`, not `cli/Ln/ln_without_alias`. * the string passed to `failUnlessIn` is sometimes `"error"`, sometimes `"error:"`, and sometimes `"error: "`. Make it consistent. * the file `open` calls should use `"wb"` for the mode. Also, `tahoe webopen` with no arguments currently raises `TypeError: object of type 'NoneType' has no len()` (#855). Either fix this, or add a TODO comment referencing #855 where the relevant test would be.
davidsarah commented 2010-02-11 05:55:34 +00:00
Author
Owner

Replying to davidsarah:

Also, tahoe webopen with no arguments currently raises TypeError: object of type 'NoneType' has no len()

Oh, that was because I hadn't specified --node-directory (which is a separate bug).

What is relevant to this ticket is that the tests should include test_webopen_without_alias.

Replying to [davidsarah](/tahoe-lafs/trac-2024-07-25/issues/939#issuecomment-75219): > Also, `tahoe webopen` with no arguments currently raises `TypeError: object of type 'NoneType' has no len()` Oh, that was because I hadn't specified `--node-directory` (which is a separate bug). What is relevant to this ticket is that the tests should include `test_webopen_without_alias`.
kevan commented 2010-02-11 19:22:05 +00:00
Author
Owner

Thanks for the review.

So I'm clear: have you found a way to break tahoe webopen that is (or should be) fixed in this ticket, but isn't tested by my patches? Or is there some other reason that you'd like to see the test there?

Thanks for the review. So I'm clear: have you found a way to break `tahoe webopen` that is (or should be) fixed in this ticket, but isn't tested by my patches? Or is there some other reason that you'd like to see the test there?
davidsarah commented 2010-02-12 05:21:56 +00:00
Author
Owner

Unless I'm mistaken, there should only be two backslashes in "C:\Windows", not four.

So I'm clear: have you found a way to break tahoe webopen that is (or should be) fixed in this ticket, but isn't tested by my patches?

No (I thought I had, but I was mistaken). There is currently no test for tahoe webopen without arguments, but I'll leave it up to you whether you want to fix that in this ticket.

Unless I'm mistaken, there should only be two backslashes in "C:\\Windows", not four. > So I'm clear: have you found a way to break tahoe webopen that is (or should be) fixed in this ticket, but isn't tested by my patches? No (I thought I had, but I was mistaken). There is currently no test for `tahoe webopen` without arguments, but I'll leave it up to you whether you want to fix that in this ticket.
kevan commented 2010-02-12 06:26:24 +00:00
Author
Owner

Replying to davidsarah:

Unless I'm mistaken, there should only be two backslashes in "C:\Windows", not four.

You're right -- I interpreted your comment as meaning that C:\ in a Windows path has two slashes, and I typed 4 to deal with escaping. But you meant that I literally should replace that string in the code with C:\\Windows. I'll fix that -- thanks.

No (I thought I had, but I was mistaken). There is currently no test for tahoe webopen without arguments, but I'll leave it up to you whether you want to fix that in this ticket.

I think it would be more appropriate to add it when #855 is fixed. It's helpful to have something that is broken when writing a test -- that way, you have something well-defined to test for.

Replying to [davidsarah](/tahoe-lafs/trac-2024-07-25/issues/939#issuecomment-75222): > Unless I'm mistaken, there should only be two backslashes in "C:\\Windows", not four. You're right -- I interpreted your comment as meaning that C:\ in a Windows path has two slashes, and I typed 4 to deal with escaping. But you meant that I literally should replace that string in the code with `C:\\Windows`. I'll fix that -- thanks. > No (I thought I had, but I was mistaken). There is currently no test for `tahoe webopen` without arguments, but I'll leave it up to you whether you want to fix that in this ticket. I think it would be more appropriate to add it when #855 is fixed. It's helpful to have something that is broken when writing a test -- that way, you have something well-defined to test for.
kevan commented 2010-02-12 06:30:19 +00:00
Author
Owner

Attachment 939tests.darcspatch.txt (19415 bytes) added

tests for #939 -- review this one

**Attachment** 939tests.darcspatch.txt (19415 bytes) added tests for #939 -- review this one
davidsarah commented 2010-02-12 06:39:43 +00:00
Author
Owner

Looks good.

Looks good.

fixed by changeset:63c8c6574745374a and changeset:c00a62a2e78a9b33. Thanks!

fixed by changeset:63c8c6574745374a and changeset:c00a62a2e78a9b33. Thanks!
zooko added the
fixed
label 2010-02-15 04:23:21 +00:00
zooko closed this issue 2010-02-15 04:23:21 +00:00
zooko modified the milestone from 1.7.0 to 1.6.1 2010-02-15 04:25:14 +00:00
Sign in to join this conversation.
No Milestone
No Assignees
3 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#939
No description provided.