Wed Feb 10 18:43:18 PST 2010 Kevan Carstensen * Alter CLI utilities to handle nonexistent aliases better New patches: [Alter CLI utilities to handle nonexistent aliases better Kevan Carstensen **20100211024318 Ignore-this: e698ea4a57f5fe27c24336581ca0cf65 ] { hunk ./src/allmydata/scripts/common.py 137 # DefaultAliasMarker. We special-case strings with a recognized cap URI # prefix, to make it easy to access specific files/directories by their # caps. + # If the transformed alias is either not found in aliases, or is blank + # and default is not found in aliases, an UnknownAliasError is + # raised. path = path.strip() if uri.has_uri_prefix(path): # The only way to get a sub-path is to use URI:blah:./foo, and we hunk ./src/allmydata/scripts/common.py 153 # no alias if default == None: return DefaultAliasMarker, path + if default not in aliases: + raise UnknownAliasError("No alias specified, and the default " + "'tahoe' alias doesn't exist. To create " + "it, use 'tahoe create-alias tahoe'.") return aliases[default], path if colon == 1 and default == None and platform_uses_lettercolon_drivename(): # treat C:\why\must\windows\be\so\weird as a local path, not a tahoe hunk ./src/allmydata/scripts/common.py 168 # "foo/bar:7" if default == None: return DefaultAliasMarker, path + if default not in aliases: + raise UnknownAliasError("No alias specified, and the default " + "'tahoe' alias doesn't exist. To create " + "it, use 'tahoe create-alias tahoe'.") return aliases[default], path if alias not in aliases: raise UnknownAliasError("Unknown alias '%s', please create it with 'tahoe add-alias' or 'tahoe create-alias'." % alias) hunk ./src/allmydata/scripts/slow_operation.py 3 import os, time -from allmydata.scripts.common import get_alias, DEFAULT_ALIAS, escape_path +from allmydata.scripts.common import get_alias, DEFAULT_ALIAS, escape_path, \ + UnknownAliasError from allmydata.scripts.common_http import do_http from allmydata.util import base32 import urllib hunk ./src/allmydata/scripts/slow_operation.py 21 nodeurl += "/" self.nodeurl = nodeurl where = options.where - rootcap, path = get_alias(options.aliases, where, DEFAULT_ALIAS) + try: + rootcap, path = get_alias(options.aliases, where, DEFAULT_ALIAS) + except UnknownAliasError, e: + print >>stderr, "error: %s" % e.args[0] + return 1 if path == '/': path = '' url = nodeurl + "uri/%s" % urllib.quote(rootcap) hunk ./src/allmydata/scripts/tahoe_backup.py 7 import urllib import simplejson import datetime -from allmydata.scripts.common import get_alias, escape_path, DEFAULT_ALIAS +from allmydata.scripts.common import get_alias, escape_path, DEFAULT_ALIAS, \ + UnknownAliasError from allmydata.scripts.common_http import do_http from allmydata.util import time_format from allmydata.scripts import backupdb hunk ./src/allmydata/scripts/tahoe_backup.py 96 print >>stderr, "ERROR: Unable to load backup db." return 1 - rootcap, path = get_alias(options.aliases, options.to_dir, DEFAULT_ALIAS) + try: + rootcap, path = get_alias(options.aliases, options.to_dir, DEFAULT_ALIAS) + except UnknownAliasError, e: + print >>stderr, "error: %s" % e.args[0] + return 1 to_url = nodeurl + "uri/%s/" % urllib.quote(rootcap) if path: to_url += escape_path(path) hunk ./src/allmydata/scripts/tahoe_check.py 5 import urllib import simplejson from twisted.protocols.basic import LineOnlyReceiver -from allmydata.scripts.common import get_alias, DEFAULT_ALIAS, escape_path +from allmydata.scripts.common import get_alias, DEFAULT_ALIAS, escape_path, \ + UnknownAliasError from allmydata.scripts.common_http import do_http class Checker: hunk ./src/allmydata/scripts/tahoe_check.py 19 if not nodeurl.endswith("/"): nodeurl += "/" where = options.where - rootcap, path = get_alias(options.aliases, where, DEFAULT_ALIAS) + try: + rootcap, path = get_alias(options.aliases, where, DEFAULT_ALIAS) + except UnknownAliasError, e: + print >>stderr, "error: %s" % e.args[0] + return 1 if path == '/': path = '' url = nodeurl + "uri/%s" % urllib.quote(rootcap) hunk ./src/allmydata/scripts/tahoe_check.py 272 nodeurl += "/" self.nodeurl = nodeurl where = options.where - rootcap, path = get_alias(options.aliases, where, DEFAULT_ALIAS) + try: + rootcap, path = get_alias(options.aliases, where, DEFAULT_ALIAS) + except UnknownAliasError, e: + print >>stderr, "error: %s" % e.args[0] + return 1 if path == '/': path = '' url = nodeurl + "uri/%s" % urllib.quote(rootcap) hunk ./src/allmydata/scripts/tahoe_cp.py 7 import simplejson from cStringIO import StringIO from twisted.python.failure import Failure -from allmydata.scripts.common import get_alias, escape_path, DefaultAliasMarker +from allmydata.scripts.common import get_alias, escape_path, \ + DefaultAliasMarker, UnknownAliasError from allmydata.scripts.common_http import do_http from allmydata import uri hunk ./src/allmydata/scripts/tahoe_cp.py 468 destination_spec = self.options.destination recursive = self.options["recursive"] - target = self.get_target_info(destination_spec) + try: + target = self.get_target_info(destination_spec) + except UnknownAliasError, e: + self.to_stderr("error: %s" % e.args[0]) + return 1 try: sources = [] # list of (name, source object) hunk ./src/allmydata/scripts/tahoe_cp.py 482 except MissingSourceError, e: self.to_stderr("No such file or directory %s" % e.args[0]) return 1 + except UnknownAliasError, e: + self.to_stderr("error: %s" % e.args[0]) + return 1 have_source_dirs = bool([s for (name,s) in sources if isinstance(s, (LocalDirectorySource, hunk ./src/allmydata/scripts/tahoe_get.py 3 import urllib -from allmydata.scripts.common import get_alias, DEFAULT_ALIAS, escape_path +from allmydata.scripts.common import get_alias, DEFAULT_ALIAS, escape_path, \ + UnknownAliasError from allmydata.scripts.common_http import do_http def get(options): hunk ./src/allmydata/scripts/tahoe_get.py 17 if nodeurl[-1] != "/": nodeurl += "/" - rootcap, path = get_alias(aliases, from_file, DEFAULT_ALIAS) + try: + rootcap, path = get_alias(aliases, from_file, DEFAULT_ALIAS) + except UnknownAliasError, e: + print >>stderr, "error: %s" % e.args[0] + return 1 url = nodeurl + "uri/%s" % urllib.quote(rootcap) if path: url += "/" + escape_path(path) hunk ./src/allmydata/scripts/tahoe_ls.py 4 import urllib, time import simplejson -from allmydata.scripts.common import get_alias, DEFAULT_ALIAS, escape_path +from allmydata.scripts.common import get_alias, DEFAULT_ALIAS, escape_path, \ + UnknownAliasError from allmydata.scripts.common_http import do_http def list(options): hunk ./src/allmydata/scripts/tahoe_ls.py 19 nodeurl += "/" if where.endswith("/"): where = where[:-1] - rootcap, path = get_alias(aliases, where, DEFAULT_ALIAS) + try: + rootcap, path = get_alias(aliases, where, DEFAULT_ALIAS) + except UnknownAliasError, e: + print >>stderr, "error: %s" % e.args[0] + return 1 url = nodeurl + "uri/%s" % urllib.quote(rootcap) if path: # move where.endswith check here? hunk ./src/allmydata/scripts/tahoe_manifest.py 6 from twisted.protocols.basic import LineOnlyReceiver from allmydata.util.abbreviate import abbreviate_space_both from allmydata.scripts.slow_operation import SlowOperationRunner -from allmydata.scripts.common import get_alias, DEFAULT_ALIAS, escape_path +from allmydata.scripts.common import get_alias, DEFAULT_ALIAS, escape_path, \ + UnknownAliasError from allmydata.scripts.common_http import do_http class FakeTransport: hunk ./src/allmydata/scripts/tahoe_manifest.py 29 nodeurl += "/" self.nodeurl = nodeurl where = options.where - rootcap, path = get_alias(options.aliases, where, DEFAULT_ALIAS) + try: + rootcap, path = get_alias(options.aliases, where, DEFAULT_ALIAS) + except UnknownAliasError, e: + print >>stderr, "error: %s" % e.args[0] + return 1 if path == '/': path = '' url = nodeurl + "uri/%s" % urllib.quote(rootcap) hunk ./src/allmydata/scripts/tahoe_mkdir.py 4 import urllib from allmydata.scripts.common_http import do_http, check_http_error -from allmydata.scripts.common import get_alias, DEFAULT_ALIAS +from allmydata.scripts.common import get_alias, DEFAULT_ALIAS, UnknownAliasError def mkdir(options): nodeurl = options['node-url'] hunk ./src/allmydata/scripts/tahoe_mkdir.py 15 if not nodeurl.endswith("/"): nodeurl += "/" if where: - rootcap, path = get_alias(aliases, where, DEFAULT_ALIAS) + try: + rootcap, path = get_alias(aliases, where, DEFAULT_ALIAS) + except UnknownAliasError, e: + print >>stderr, "error: %s" % e.args[0] + return 1 if not where or not path: # create a new unlinked directory hunk ./src/allmydata/scripts/tahoe_mv.py 5 import re import urllib import simplejson -from allmydata.scripts.common import get_alias, DEFAULT_ALIAS, escape_path +from allmydata.scripts.common import get_alias, DEFAULT_ALIAS, escape_path, \ + UnknownAliasError from allmydata.scripts.common_http import do_http # this script is used for both 'mv' and 'ln' hunk ./src/allmydata/scripts/tahoe_mv.py 21 if nodeurl[-1] != "/": nodeurl += "/" - rootcap, from_path = get_alias(aliases, from_file, DEFAULT_ALIAS) + try: + rootcap, from_path = get_alias(aliases, from_file, DEFAULT_ALIAS) + except UnknownAliasError, e: + print >>stderr, "error: %s" % e.args[0] + return 1 from_url = nodeurl + "uri/%s" % urllib.quote(rootcap) if from_path: from_url += "/" + escape_path(from_path) hunk ./src/allmydata/scripts/tahoe_mv.py 38 cap = str(cap) # now get the target - rootcap, path = get_alias(aliases, to_file, DEFAULT_ALIAS) + try: + rootcap, path = get_alias(aliases, to_file, DEFAULT_ALIAS) + except UnknownAliasError, e: + print >>stderr, "error: %s" % e.args[0] + return 1 to_url = nodeurl + "uri/%s" % urllib.quote(rootcap) if path: to_url += "/" + escape_path(path) hunk ./src/allmydata/scripts/tahoe_put.py 6 import os.path import urllib from allmydata.scripts.common_http import do_http -from allmydata.scripts.common import get_alias, DEFAULT_ALIAS, escape_path +from allmydata.scripts.common import get_alias, DEFAULT_ALIAS, escape_path, \ + UnknownAliasError def put(options): """ hunk ./src/allmydata/scripts/tahoe_put.py 38 # /oops/subdir/foo : DISALLOWED # ALIAS:foo : aliases[ALIAS]/foo # ALIAS:subdir/foo : aliases[ALIAS]/subdir/foo - + # ALIAS:/oops/subdir/foo : DISALLOWED # DIRCAP:./foo : DIRCAP/foo # DIRCAP:./subdir/foo : DIRCAP/subdir/foo hunk ./src/allmydata/scripts/tahoe_put.py 48 if to_file.startswith("URI:SSK:"): url = nodeurl + "uri/%s" % urllib.quote(to_file) else: - rootcap, path = get_alias(aliases, to_file, DEFAULT_ALIAS) + try: + rootcap, path = get_alias(aliases, to_file, DEFAULT_ALIAS) + except UnknownAliasError, e: + print >>stderr, "error: %s" % e.args[0] + return 1 if path.startswith("/"): suggestion = to_file.replace("/", "", 1) print >>stderr, "ERROR: The remote filename must not start with a slash" hunk ./src/allmydata/scripts/tahoe_rm.py 4 import urllib from allmydata.scripts.common_http import do_http -from allmydata.scripts.common import get_alias, DEFAULT_ALIAS, escape_path +from allmydata.scripts.common import get_alias, DEFAULT_ALIAS, escape_path, \ + UnknownAliasError def rm(options): """ hunk ./src/allmydata/scripts/tahoe_rm.py 19 if nodeurl[-1] != "/": nodeurl += "/" - rootcap, path = get_alias(aliases, where, DEFAULT_ALIAS) + try: + rootcap, path = get_alias(aliases, where, DEFAULT_ALIAS) + except UnknownAliasError, e: + print >>stderr, "error: %s" % e.args[0] + return 1 assert path url = nodeurl + "uri/%s" % urllib.quote(rootcap) url += "/" + escape_path(path) hunk ./src/allmydata/scripts/tahoe_webopen.py 2 -from allmydata.scripts.common import get_alias, DEFAULT_ALIAS, escape_path +from allmydata.scripts.common import get_alias, DEFAULT_ALIAS, escape_path, \ + UnknownAliasError import urllib def webopen(options, opener=None): hunk ./src/allmydata/scripts/tahoe_webopen.py 8 nodeurl = options['node-url'] + stderr = options.stderr if not nodeurl.endswith("/"): nodeurl += "/" where = options.where hunk ./src/allmydata/scripts/tahoe_webopen.py 13 if where: - rootcap, path = get_alias(options.aliases, where, DEFAULT_ALIAS) + try: + rootcap, path = get_alias(options.aliases, where, DEFAULT_ALIAS) + except UnknownAliasError, e: + print >>stderr, "error: %s" % e.args[0] + return 1 if path == '/': path = '' url = nodeurl + "uri/%s" % urllib.quote(rootcap) } Context: [adding pycrypto to the auto dependencies secorp@allmydata.com**20100206054314 Ignore-this: b873fc00a6a5b001d30d479e6053cf2f ] [docs running.html - "tahoe run ." does not work with the current installation, replaced with "tahoe start ." secorp@allmydata.com**20100206165320 Ignore-this: fdb2dcb0e417d303cd43b1951a4f8c03 ] [code coverage: replace figleaf with coverage.py, should work on py2.6 now. Brian Warner **20100203165421 Ignore-this: 46ab590360be6a385cb4fc4e68b6b42c It still lacks the right HTML report (the builtin report is very pretty, but lacks the "lines uncovered" numbers that I want), and the half-finished delta-from-last-run measurements. ] [More comprehensive changes and ticket references for NEWS david-sarah@jacaranda.org**20100202061256 Ignore-this: 696cf0106e8a7fd388afc5b55fba8a1b ] [docs: install.html: link into Python 2.5.5 download page zooko@zooko.com**20100202065852 Ignore-this: 1a9471b8175b7de5741d8445a7ede29d ] [TAG allmydata-tahoe-1.6.0 zooko@zooko.com**20100202061125 Ignore-this: dee6ade7ac1452cf5d1d9c69a8146d84 ] Patch bundle hash: 08b3b81c318baadf54c58f8b2b61eafbd4db3b0e