# 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
# 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
# "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)
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
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)
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
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)
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:
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)
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)
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
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)
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,
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):
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)
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):
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?
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:
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)
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']
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
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'
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)
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)
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):
"""
# /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
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"
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):
"""
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)
-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):
nodeurl = options['node-url']
+ stderr = options.stderr
if not nodeurl.endswith("/"):
nodeurl += "/"
where = options.where
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)