api_errors.py revision 1254
1516N/A#!/usr/bin/python2.4
565N/A#
565N/A# CDDL HEADER START
565N/A#
565N/A# The contents of this file are subject to the terms of the
565N/A# Common Development and Distribution License (the "License").
565N/A# You may not use this file except in compliance with the License.
565N/A#
565N/A# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
565N/A# or http://www.opensolaris.org/os/licensing.
565N/A# See the License for the specific language governing permissions
565N/A# and limitations under the License.
565N/A#
565N/A# When distributing Covered Code, include this CDDL HEADER in each
565N/A# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
565N/A# If applicable, add the following below this CDDL HEADER, with the
565N/A# fields enclosed by brackets "[]" replaced with your own identifying
565N/A# information: Portions Copyright [yyyy] [name of copyright owner]
565N/A#
565N/A# CDDL HEADER END
565N/A#
926N/A
926N/A#
3321N/A# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
926N/A# Use is subject to license terms.
565N/A#
2026N/A
3094N/Aimport os
1050N/Aimport urlparse
3234N/A
2524N/A# EmptyI for argument defaults; can't import from misc due to circular
3245N/A# dependency.
3234N/AEmptyI = tuple()
926N/A
2339N/Aclass ApiException(Exception):
2339N/A pass
2339N/A
926N/Aclass ImageNotFoundException(ApiException):
926N/A """Used when an image was not found"""
926N/A def __init__(self, user_specified, user_dir, root_dir):
838N/A ApiException.__init__(self)
565N/A self.user_specified = user_specified
2034N/A self.user_dir = user_dir
2034N/A self.root_dir = root_dir
2034N/A
1540N/Aclass VersionException(ApiException):
2034N/A def __init__(self, expected_version, received_version):
2034N/A ApiException.__init__(self)
2200N/A self.expected_version = expected_version
2034N/A self.received_version = received_version
2034N/A
2034N/Aclass PlanExistsException(ApiException):
565N/A def __init__(self, plan_type):
2339N/A ApiException.__init__(self)
2339N/A self.plan_type = plan_type
2339N/A
2339N/Aclass ActuatorException(ApiException):
2339N/A def __init__(self, e):
2339N/A ApiException.__init__(self)
2524N/A self.exception = e
2524N/A
2524N/A def __str__(self):
2524N/A return str(self.exception)
2524N/A
2524N/Aclass PrematureExecutionException(ApiException):
2524N/A pass
2524N/A
2524N/Aclass AlreadyPreparedException(ApiException):
2524N/A pass
2524N/A
2524N/Aclass AlreadyExecutedException(ApiException):
2524N/A pass
2524N/A
2524N/Aclass ImageplanStateException(ApiException):
2524N/A def __init__(self, state):
2524N/A ApiException.__init__(self)
2524N/A self.state = state
2524N/A
2524N/Aclass IpkgOutOfDateException(ApiException):
2524N/A pass
2524N/A
2524N/Aclass ImageUpdateOnLiveImageException(ApiException):
2524N/A pass
2524N/A
2524N/Aclass CanceledException(ApiException):
2524N/A pass
2524N/A
2524N/Aclass PlanMissingException(ApiException):
2524N/A pass
2524N/A
2524N/Aclass NoPackagesInstalledException(ApiException):
2524N/A pass
2524N/A
2524N/Aclass PermissionsException(ApiException):
2524N/A def __init__(self, path):
2524N/A ApiException.__init__(self)
2524N/A self.path = path
2524N/A
2524N/A def __str__(self):
2524N/A if self.path:
2524N/A return _("Could not operate on %s\nbecause of "
2524N/A "insufficient permissions. Please try the command "
2524N/A "again using pfexec\nor otherwise increase your "
2524N/A "privileges.") % self.path
2524N/A else:
2524N/A return _("""
2524N/ACould not complete the operation because of insufficient permissions. Please
2524N/Atry the command again using pfexec or otherwise increase your privileges.
1710N/A""")
1710N/A
1710N/Aclass FileInUseException(PermissionsException):
1710N/A def __init__(self, path):
1710N/A PermissionsException.__init__(self, path)
1710N/A assert path
1710N/A
1710N/A def __str__(self):
1710N/A return _("Could not operate on %s\nbecause the file is "
1710N/A "in use. Please stop using the file and try the\n"
1710N/A "operation again.") % self.path
1710N/A
1710N/Aclass PlanCreationException(ApiException):
1710N/A def __init__(self, unmatched_fmris=EmptyI, multiple_matches=EmptyI,
1710N/A missing_matches=EmptyI, illegal=EmptyI,
3158N/A constraint_violations=EmptyI, badarch=EmptyI):
3158N/A ApiException.__init__(self)
3158N/A self.unmatched_fmris = unmatched_fmris
1710N/A self.multiple_matches = multiple_matches
1710N/A self.missing_matches = missing_matches
1710N/A self.illegal = illegal
3158N/A self.constraint_violations = constraint_violations
3158N/A self.badarch = badarch
1710N/A
1710N/A def __str__(self):
1710N/A res = []
3158N/A if self.unmatched_fmris:
3158N/A s = _("""\
1710N/AThe following pattern(s) did not match any packages in the current catalog.
1710N/ATry relaxing the pattern, refreshing and/or examining the catalogs:""")
1710N/A res += [s]
565N/A res += ["\t%s" % p for p in self.unmatched_fmris]
565N/A
565N/A if self.multiple_matches:
565N/A s = _("'%s' matches multiple packages")
565N/A for p, lst in self.multiple_matches:
565N/A res.append(s % p)
565N/A for pfmri in lst:
565N/A res.append("\t%s" % pfmri)
2976N/A
3158N/A s = _("'%s' matches no installed packages")
2976N/A res += [ s % p for p in self.missing_matches ]
2144N/A
2144N/A s = _("'%s' is an illegal fmri")
2144N/A res += [ s % p for p in self.illegal ]
2144N/A
2144N/A if self.constraint_violations:
2144N/A s = _("The following package(s) violated constraints:")
2144N/A res += [s]
2144N/A res += ["\t%s" % p for p in self.constraint_violations]
2144N/A
2144N/A if self.badarch:
3158N/A s = _("'%s' supports the following architectures: %s")
2144N/A a = _("Image architecture is defined as: %s")
3158N/A res += [ s % (self.badarch[0],
2144N/A ", ".join(self.badarch[1]))]
2407N/A res += [ a % (self.badarch[2])]
2407N/A
2407N/A return '\n'.join(res)
2407N/A
2407N/A
2407N/Aclass ActionExecutionError(ApiException):
2407N/A """An error was encountered executing an action.
2407N/A
2407N/A In particular, this exception indicates that something went wrong in the
3158N/A application (or unapplication) of the action to the system, not an error
3158N/A in the pkg(5) code.
3158N/A
3158N/A The 'msg' argument can provide a more specific message than what would
3158N/A be returned from, and 'ignoreerrno' can be set to True to indicate that
3158N/A the sterror() text is misleading, and shouldn't be displayed.
2875N/A """
2144N/A
565N/A def __init__(self, action, exception, msg=None, ignoreerrno=False):
565N/A self.action = action
565N/A self.exception = exception
565N/A self.msg = msg
565N/A self.ignoreerrno = ignoreerrno
565N/A
2144N/A def __str__(self):
565N/A errno = ""
565N/A if not self.ignoreerrno and hasattr(self.exception, "errno"):
565N/A errno = "[errno %d: %s]" % (self.exception.errno,
565N/A os.strerror(self.exception.errno))
565N/A
1618N/A msg = self.msg or ""
1618N/A
1618N/A # Fall back on the wrapped exception if we don't have anything
1618N/A # useful.
1618N/A if not errno and not msg:
1618N/A return str(self.exception)
1755N/A
1755N/A if errno and msg:
1755N/A return "%s: %s" % (errno, msg)
1755N/A
1755N/A # If we only have one of the two, no need for the colon.
1755N/A return "%s%s" % (errno, msg)
1755N/A
1755N/A
1755N/Aclass CatalogCacheError(ApiException):
1755N/A """Base class used for all catalog cache errors."""
1755N/A
1755N/A def __init__(self, *args, **kwargs):
1755N/A ApiException.__init__(self, *args)
1755N/A if args:
3158N/A self.data = args[0]
1755N/A else:
1755N/A self.data = None
1618N/A self.args = kwargs
1618N/A
1618N/A
1618N/Aclass CatalogCacheBadVersion(CatalogCacheError):
1618N/A """Used to indicate that the catalog cache is invalid or is not of a
1618N/A supported version."""
1618N/A
1618N/A def __str__(self):
1618N/A return _("Unsupported catalog cache Version: '%(found)s'; "
1618N/A "expected: '%(expected)s'") % { "found": self.data,
1618N/A "expected": self.args["expected"] }
1618N/A
1618N/A
1618N/Aclass CatalogCacheInvalid(CatalogCacheError):
1618N/A """Used to indicate that the catalog cache is corrupt or otherwise
1618N/A unparseable."""
1618N/A
1618N/A def __str__(self):
1618N/A return _("Catalog cache is corrupt or invalid; error "
1618N/A "encountered while reading:\nline %(lnum)d: '%(data)s'") % {
1618N/A "lnum": self.args["line_number"], "data": self.data }
1618N/A
1618N/A
1618N/Aclass CatalogCacheMissing(CatalogCacheError):
1618N/A """Used to indicate that the catalog cache is missing."""
1618N/A
1618N/A def __str__(self):
1618N/A return _("Catalog cache is missing.")
1618N/A
1618N/A
1618N/Aclass CatalogRefreshException(ApiException):
1618N/A def __init__(self, failed, total, succeeded, message=None):
1618N/A ApiException.__init__(self)
1618N/A self.failed = failed
1618N/A self.total = total
1618N/A self.succeeded = succeeded
1618N/A self.message = message
1618N/A
1618N/A
1618N/Aclass InventoryException(ApiException):
1618N/A def __init__(self, notfound=EmptyI, illegal=EmptyI):
1618N/A ApiException.__init__(self)
1618N/A self.notfound = notfound
1618N/A self.illegal = illegal
1618N/A assert(self.notfound or self.illegal)
1618N/A
1618N/A def __str__(self):
1618N/A outstr = ""
1618N/A for x in self.illegal:
1618N/A # Illegal FMRIs have their own __str__ method
1618N/A outstr += "%s\n" % x
1618N/A
1618N/A if self.notfound:
1618N/A outstr += _("No matching package could be found for "
1618N/A "the following FMRIs in any of the catalogs for "
1618N/A "the current publishers:\n")
1618N/A
3158N/A for x in self.notfound:
1618N/A outstr += "%s\n" % x
1618N/A
3158N/A return outstr
1618N/A
1618N/A
1618N/A# SearchExceptions
1618N/A
1618N/Aclass SearchException(ApiException):
1618N/A """Based class used for all search-related api exceptions."""
1618N/A pass
1618N/A
1618N/A
1019N/Aclass MainDictParsingException(SearchException):
1019N/A """This is used when the main dictionary could not parse a line."""
1019N/A def __init__(self, e):
1019N/A SearchException.__init__(self)
1019N/A self.e = e
1019N/A
1019N/A def __str__(self):
1019N/A return str(self.e)
1618N/A
565N/A
565N/Aclass MalformedSearchRequest(SearchException):
565N/A """Raised when the server cannot understand the format of the
1618N/A search request."""
1618N/A
565N/A def __init__(self, url):
565N/A SearchException.__init__(self)
1618N/A self.url = url
565N/A
565N/A def __str__(self):
565N/A return str(self.url)
1618N/A
565N/A
565N/Aclass NegativeSearchResult(SearchException):
565N/A """Returned when the search cannot find any matches."""
565N/A
565N/A def __init__(self, url):
1369N/A SearchException.__init__(self)
1710N/A self.url = url
1710N/A
1710N/A def __str__(self):
1710N/A return _("The search at url %s returned no results.") % self.url
1710N/A
1710N/A
1710N/Aclass ProblematicSearchServers(SearchException):
1710N/A """This class wraps exceptions which could appear while trying to
1710N/A do a search request."""
1710N/A
1372N/A def __init__(self, failed=EmptyI, invalid=EmptyI, unsupported=EmptyI):
1369N/A SearchException.__init__(self)
1369N/A self.failed_servers = failed
1369N/A self.invalid_servers = invalid
1369N/A self.unsupported_servers = unsupported
1369N/A
1369N/A def __str__(self):
1369N/A s = _("Some servers failed to respond appropriately:\n")
3158N/A for pub, err in self.failed_servers:
3158N/A s += _("%(o)s:\n%(msg)s\n") % \
3158N/A { "o": pub, "msg": err}
1369N/A for pub in self.invalid_servers:
1369N/A s += _("%s did not return a valid response.\n" \
565N/A % pub)
2976N/A if len(self.unsupported_servers) > 0:
3356N/A s += _("Some servers don't support requested search"
2976N/A " operation:\n")
565N/A for pub, err in self.unsupported_servers:
565N/A s += _("%(o)s:\n%(msg)s\n") % \
2976N/A { "o": pub, "msg": err}
2976N/A
2976N/A return s
2976N/A
565N/A
1328N/Aclass SlowSearchUsed(SearchException):
2976N/A """This exception is thrown when a local search is performed without
2976N/A an index. It's raised after all results have been yielded."""
2976N/A
2976N/A def __str__(self):
1328N/A return _("Search performance is degraded.\n"
565N/A "Run 'pkg rebuild-index' to improve search speed.")
565N/A
565N/A
565N/Aclass UnsupportedSearchError(SearchException):
565N/A """Returned when a search protocol is not supported by the
565N/A remote server."""
565N/A
565N/A def __init__(self, url=None, proto=None):
565N/A SearchException.__init__(self)
685N/A self.url = url
685N/A self.proto = proto
685N/A
685N/A def __str__(self):
685N/A s = _("Search server does not support the requested protocol:")
685N/A if self.url:
685N/A s += "\nServer URL: %s" % self.url
3158N/A if self.proto:
2126N/A s += "\nRequested operation: %s" % self.proto
3158N/A return s
3158N/A
685N/A def __cmp__(self, other):
685N/A if not isinstance(other, UnsupportedSearchError):
2126N/A return -1
2126N/A r = cmp(self.url, other.url)
685N/A if r != 0:
685N/A return r
879N/A return cmp(self.proto, other.proto)
879N/A
879N/A
879N/A# IndexingExceptions.
879N/A
879N/Aclass IndexingException(SearchException):
3158N/A """ The base class for all exceptions that can occur while indexing. """
879N/A
3158N/A def __init__(self, private_exception):
879N/A SearchException.__init__(self)
1335N/A self.cause = private_exception.cause
2612N/A
2612N/A
2612N/Aclass CorruptedIndexException(IndexingException):
2612N/A """This is used when the index is not in a correct state."""
2612N/A pass
2612N/A
2612N/A
2612N/Aclass InconsistentIndexException(IndexingException):
2612N/A """This is used when the existing index is found to have inconsistent
2612N/A versions."""
1335N/A def __init__(self, e):
1945N/A IndexingException.__init__(self, e)
1335N/A self.exception = e
1335N/A
1335N/A def __str__(self):
1335N/A return str(self.exception)
1335N/A
1335N/A
1335N/Aclass ProblematicPermissionsIndexException(IndexingException):
1335N/A """ This is used when the indexer is unable to create, move, or remove
3158N/A files or directories it should be able to. """
3158N/A def __str__(self):
1335N/A return "Could not remove or create " \
1335N/A "%s because of incorrect " \
1335N/A "permissions. Please correct this issue then " \
1335N/A "rebuild the index." % self.cause
2974N/A
2974N/A# Query Parsing Exceptions
2974N/Aclass BooleanQueryException(ApiException):
2974N/A """This exception is used when the children of a boolean operation
2974N/A have different return types. The command 'pkg search foo AND <bar>'
2974N/A is the simplest example of this."""
3158N/A
3158N/A def __init__(self, e):
3158N/A ApiException.__init__(self)
2974N/A self.e = e
2974N/A
2301N/A def __str__(self):
2510N/A return str(self.e)
2510N/A
2510N/A
2301N/Aclass ParseError(ApiException):
2301N/A def __init__(self, e):
2301N/A ApiException.__init__(self)
2301N/A self.e = e
2301N/A
2301N/A def __str__(self):
2301N/A return str(self.e)
2301N/A
2301N/A
2301N/Aclass NonLeafPackageException(ApiException):
2301N/A """Removal of a package which satisfies dependencies has been attempted.
2301N/A
2301N/A The first argument to the constructor is the FMRI which we tried to
2301N/A remove, and is available as the "fmri" member of the exception. The
2301N/A second argument is the list of dependent packages that prevent the
3158N/A removal of the package, and is available as the "dependents" member.
2301N/A """
2301N/A
3158N/A def __init__(self, *args):
2301N/A ApiException.__init__(self, *args)
3158N/A
2301N/A self.fmri = args[0]
3158N/A self.dependents = args[1]
2301N/A
2301N/Aclass InvalidDepotResponseException(ApiException):
3158N/A """Raised when the depot doesn't have versions of operations
3158N/A that the client needs to operate successfully."""
2301N/A def __init__(self, url, data):
2301N/A ApiException.__init__(self)
2301N/A self.url = url
2301N/A self.data = data
2301N/A
2301N/A def __str__(self):
2301N/A s = "Unable to contact valid package server"
2301N/A if self.url:
3158N/A s += ": %s" % self.url
2301N/A if self.data:
2301N/A s += "\nEncountered the following error(s):\n%s" % \
2301N/A self.data
2301N/A return s
2301N/A
3384N/Aclass DataError(ApiException):
3384N/A """Base exception class used for all data related errors."""
3384N/A
3384N/A def __init__(self, *args, **kwargs):
3384N/A ApiException.__init__(self, *args)
3384N/A if args:
3384N/A self.data = args[0]
3384N/A else:
3384N/A self.data = None
3384N/A self.args = kwargs
3384N/A
3384N/A
3384N/Aclass InvalidP5IFile(DataError):
3384N/A """Used to indicate that the specified location does not contain a
3384N/A valid p5i-formatted file."""
3384N/A
565N/A def __str__(self):
2339N/A if self.data:
2339N/A return _("The specified file is in an unrecognized "
2339N/A "format or does not contain valid publisher "
2339N/A "information: %s") % self.data
2339N/A return _("The specified file is in an unrecognized format or "
2453N/A "does not contain valid publisher information.")
2339N/A
2339N/A
2339N/Aclass UnsupportedP5IFile(DataError):
2339N/A """Used to indicate that an attempt to read an unsupported version
2339N/A of pkg(5) info file was attempted."""
2339N/A
2339N/A def __str__(self):
2339N/A return _("Unsupported pkg(5) publisher information data "
2505N/A "format.")
2339N/A
2339N/A
2339N/Aclass TransportError(ApiException):
2445N/A """Abstract exception class for all transport exceptions.
2339N/A Specific transport exceptions should be implemented in the
3110N/A transport code. Callers wishing to catch transport exceptions
2339N/A should use this class. Subclasses must implement all methods
2339N/A defined here that raise NotImplementedError."""
2339N/A
2339N/A def __str__(self):
2339N/A raise NotImplementedError
565N/A
2339N/A
2339N/Aclass RetrievalError(ApiException):
2339N/A """Used to indicate that a a requested resource could not be
2339N/A retrieved."""
2453N/A
2339N/A def __init__(self, data, location=None):
2339N/A ApiException.__init__(self)
2339N/A self.data = data
1505N/A self.location = location
1505N/A
2339N/A def __str__(self):
2339N/A if self.location:
2339N/A return _("Error encountered while retrieving data from "
2505N/A "'%s':\n%s") % (self.location, self.data)
2339N/A return _("Error encountered while retrieving data from: %s") % \
2207N/A self.data
2339N/A
2445N/A
2339N/Aclass InvalidResourceLocation(ApiException):
2339N/A """Used to indicate that an invalid transport location was provided."""
3110N/A
2339N/A def __init__(self, data):
1505N/A ApiException.__init__(self)
2212N/A self.data = data
2339N/A
565N/A def __str__(self):
616N/A return _("'%s' is not a valid location.") % self.data
1141N/A
616N/Aclass BEException(ApiException):
2339N/A def __init__(self):
2445N/A ApiException.__init__(self)
2339N/A
926N/Aclass InvalidBENameException(BEException):
3158N/A def __init__(self, be_name):
565N/A BEException.__init__(self)
2445N/A self.be_name = be_name
2445N/A
2445N/A def __str__(self):
2445N/A return _("'%s' is not a valid boot environment name.") % \
2445N/A self.be_name
2445N/A
3158N/Aclass DuplicateBEName(BEException):
2445N/A """Used to indicate that there is an existing boot environment
2212N/A with this name"""
2212N/A
2212N/A def __init__(self, be_name):
2212N/A BEException.__init__(self)
2212N/A self.be_name = be_name
3158N/A
2212N/A def __str__(self):
1505N/A return _("The boot environment '%s' already exists.") % \
1505N/A self.be_name
1505N/A
1505N/Aclass BENamingNotSupported(BEException):
1505N/A def __init__(self, be_name):
3158N/A BEException.__init__(self)
1505N/A self.be_name = be_name
565N/A
3158N/A def __str__(self):
565N/A return _("""\
3158N/ABoot environment naming during package install is not supported on this
922N/Aversion of OpenSolaris. Please image-update without the --be-name option.""")
3158N/A
616N/Aclass UnableToCopyBE(BEException):
1505N/A def __str__(self):
3158N/A return _("Unable to clone the current boot environment.")
3158N/A
616N/Aclass UnableToRenameBE(BEException):
1505N/A def __init__(self, orig, dest):
3158N/A BEException.__init__(self)
3158N/A self.original_name = orig
655N/A self.destination_name = dest
838N/A
3158N/A def __str__(self):
3158N/A d = {
3158N/A "orig": self.original_name,
3158N/A "dest": self.destination_name
3158N/A }
3158N/A return _("""\
3158N/AA problem occurred while attempting to rename the boot environment
3158N/Acurrently named %(orig)s to %(dest)s.""") % d
3158N/A
1461N/Aclass UnableToMountBE(BEException):
1352N/A def __init__(self, be_name, be_dir):
1352N/A BEException.__init__(self)
1352N/A self.name = be_name
1352N/A self.mountpoint = be_dir
1352N/A
3158N/A def __str__(self):
1352N/A return _("Unable to mount %(name)s at %(mt)s") % \
2453N/A {"name": self.name, "mt": self.mountpoint}
2453N/A
2453N/Aclass BENameGivenOnDeadBE(BEException):
3234N/A def __init__(self, be_name):
2453N/A BEException.__init__(self)
2453N/A self.name = be_name
2453N/A
1505N/A def __str__(self):
2681N/A return _("""\
2681N/ANaming a boot environment when operating on a non-live image is
1505N/Anot allowed.""")
1505N/A
1505N/A
1505N/Aclass UnrecognizedOptionsToInfo(ApiException):
1505N/A def __init__(self, opts):
3158N/A ApiException.__init__(self)
1945N/A self._opts = opts
1505N/A
1505N/A def __str__(self):
2197N/A s = _("Info does not recognize the following options:")
2197N/A for o in self._opts:
2207N/A s += _(" '") + str(o) + _("'")
2339N/A return s
2339N/A
2339N/Aclass IncorrectIndexFileHash(ApiException):
2339N/A """This is used when the index hash value doesn't match the hash of the
2339N/A packages installed in the image."""
2339N/A pass
3158N/A
3158N/A
2339N/Aclass PublisherError(ApiException):
1505N/A """Base exception class for all publisher exceptions."""
1505N/A
1505N/A def __init__(self, *args, **kwargs):
2339N/A ApiException.__init__(self, *args)
2339N/A if args:
2339N/A self.data = args[0]
2339N/A else:
2339N/A self.data = None
2339N/A self.args = kwargs
2339N/A
2339N/A def __str__(self):
2339N/A return str(self.data)
1505N/A
3158N/A
3158N/Aclass BadPublisherMetaRoot(PublisherError):
3158N/A """Used to indicate an operation on the publisher's meta_root failed
3158N/A because the meta_root is invalid."""
2200N/A
2200N/A def __str__(self):
3158N/A return _("Publisher meta_root '%(root)s' is invalid; unable "
1945N/A "to complete operation: '%(op)s'.") % { "root": self.data,
2207N/A "op": self.args.get("operation", None) }
2207N/A
2207N/A
2207N/Aclass BadPublisherPrefix(PublisherError):
2207N/A """Used to indicate that a publisher name is not valid."""
2228N/A
2339N/A def __str__(self):
2339N/A return _("'%s' is not a valid publisher name.") % self.data
2339N/A
3158N/A
2228N/Aclass BadRepositoryAttributeValue(PublisherError):
2228N/A """Used to indicate that the specified repository attribute value is
2339N/A invalid."""
2339N/A
2339N/A def __str__(self):
3158N/A return _("'%(value)s' is not a valid value for repository "
2228N/A "attribute '%(attribute)s'.") % {
2505N/A "value": self.args["value"], "attribute": self.data }
2505N/A
2505N/A
3158N/Aclass BadRepositoryCollectionType(PublisherError):
2505N/A """Used to indicate that the specified repository collection type is
2339N/A invalid."""
2339N/A
2339N/A def __init__(self, *args, **kwargs):
3158N/A PublisherError.__init__(self, *args, **kwargs)
3158N/A
2339N/A def __str__(self):
2339N/A return _("'%s' is not a valid repository collection type.") % \
2339N/A self.data
2339N/A
3158N/A
2339N/Aclass BadRepositoryURI(PublisherError):
2339N/A """Used to indicate that a repository URI is not syntactically valid."""
2339N/A
2339N/A def __str__(self):
2339N/A return _("'%s' is not a valid URI.") % self.data
2339N/A
2339N/A
2339N/Aclass BadRepositoryURIPriority(PublisherError):
2339N/A """Used to indicate that the priority specified for a repository URI is
2364N/A not valid."""
2339N/A
2339N/A def __str__(self):
2339N/A return _("'%s' is not a valid URI priority; integer value "
2339N/A "expected.") % self.data
2339N/A
2339N/A
2339N/Aclass BadRepositoryURISortPolicy(PublisherError):
2339N/A """Used to indicate that the specified repository URI sort policy is
2339N/A invalid."""
2339N/A
3110N/A def __init__(self, *args, **kwargs):
3110N/A PublisherError.__init__(self, *args, **kwargs)
3110N/A
3110N/A def __str__(self):
3110N/A return _("'%s' is not a valid repository URI sort policy.") % \
3158N/A self.data
3110N/A
3110N/A
1352N/Aclass DisabledPublisher(PublisherError):
565N/A """Used to indicate that an attempt to use a disabled publisher occurred
2228N/A during an operation."""
2205N/A
2205N/A def __str__(self):
2205N/A return _("Publisher '%s' is disabled and cannot be used for "
2205N/A "packaging operations.") % self.data
2205N/A
2205N/A
2205N/Aclass DuplicatePublisher(PublisherError):
2205N/A """Used to indicate that a publisher with the same name or alias already
2205N/A exists for an image."""
2205N/A
2205N/A def __str__(self):
2205N/A return _("A publisher with the same name or alias as '%s' "
2205N/A "already exists.") % self.data
2205N/A
2205N/A
2205N/Aclass DuplicateRepository(PublisherError):
2205N/A """Used to indicate that a repository with the same origin uris
2205N/A already exists for a publisher."""
2205N/A
2205N/A def __str__(self):
2205N/A return _("A repository with the same name or origin URIs "
2205N/A "already exists for publisher '%s'.") % self.data
2205N/A
2205N/A
2205N/Aclass DuplicateRepositoryMirror(PublisherError):
2205N/A """Used to indicate that a repository URI is already in use by another
2205N/A repository mirror."""
2205N/A
2205N/A def __str__(self):
2205N/A return _("Mirror '%s' already exists for the specified "
2205N/A "repository.") % self.data
2205N/A
2205N/A
2205N/Aclass DuplicateRepositoryOrigin(PublisherError):
2205N/A """Used to indicate that a repository URI is already in use by another
2205N/A repository origin."""
2205N/A
2205N/A def __str__(self):
3158N/A return _("Origin '%s' already exists for the specified "
3158N/A "repository.") % self.data
2205N/A
3158N/A
3347N/Aclass RemovePreferredPublisher(PublisherError):
3347N/A """Used to indicate an attempt to remove the preferred publisher was
3347N/A made."""
2205N/A
2205N/A def __str__(self):
3158N/A return _("The preferred publisher cannot be removed.")
3158N/A
2205N/A
2205N/Aclass SelectedRepositoryRemoval(PublisherError):
2205N/A """Used to indicate that an attempt to remove the selected repository
2205N/A for a publisher was made."""
2205N/A
2205N/A def __str__(self):
2205N/A return _("Cannot remove the selected repository for a "
2205N/A "publisher.")
2205N/A
2205N/A
2205N/Aclass SetPreferredPublisherDisabled(PublisherError):
2205N/A """Used to indicate an attempt to set a disabled publisher as the
2205N/A preferred publisher was made."""
2205N/A
2205N/A def __str__(self):
2205N/A return _("Publisher '%s' is disabled and cannot be set as the "
2205N/A "preferred publisher.") % self.data
2205N/A
2205N/A
2205N/Aclass UnknownLegalURI(PublisherError):
3158N/A """Used to indicate that no matching legal URI could be found using the
3234N/A provided criteria."""
3158N/A
3158N/A def __str__(self):
3347N/A return _("Unknown legal URI '%s'.") % self.data
3347N/A
3347N/A
2205N/Aclass UnknownPublisher(PublisherError):
2205N/A """Used to indicate that no matching publisher could be found using the
3234N/A provided criteria."""
3158N/A
3158N/A def __str__(self):
2205N/A return _("Unknown publisher '%s'.") % self.data
2205N/A
2205N/A
2205N/Aclass UnknownRelatedURI(PublisherError):
2205N/A """Used to indicate that no matching related URI could be found using
2205N/A the provided criteria."""
2205N/A
2205N/A def __str__(self):
2205N/A return _("Unknown related URI '%s'.") % self.data
2205N/A
2205N/A
2205N/Aclass UnknownRepository(PublisherError):
2205N/A """Used to indicate that no matching repository could be found using the
2205N/A provided criteria."""
2205N/A
2205N/A def __str__(self):
2205N/A return _("Unknown repository '%s'.") % self.data
2205N/A
2205N/A
2205N/Aclass UnknownRepositoryMirror(PublisherError):
3234N/A """Used to indicate that a repository URI could not be found in the
2453N/A list of repository mirrors."""
2453N/A
2453N/A def __str__(self):
2453N/A return _("Unknown repository mirror '%s'.") % self.data
2205N/A
2205N/A
2205N/Aclass UnknownRepositoryOrigin(PublisherError):
2205N/A """Used to indicate that a repository URI could not be found in the
2205N/A list of repository origins."""
2205N/A
2232N/A def __str__(self):
2232N/A return _("Unknown repository origin '%s'") % self.data
2205N/A
2205N/A
3234N/Aclass UnsupportedRepositoryURI(PublisherError):
2205N/A """Used to indicate that the specified repository URI uses an
2205N/A unsupported scheme."""
2205N/A
3158N/A def __str__(self):
3158N/A if self.data:
2205N/A scheme = urlparse.urlsplit(self.data,
2205N/A allow_fragments=0)[0]
2205N/A return _("The URI '%(uri)s' contains an unsupported "
2205N/A "scheme '%(scheme)s'.") % { "uri": self.data,
2205N/A "scheme": scheme }
3158N/A return _("The specified URI contains an unsupported scheme.")
2205N/A
3158N/A
3158N/Aclass UnsupportedRepositoryURIAttribute(PublisherError):
2205N/A """Used to indicate that the specified repository URI attribute is not
3158N/A supported for the URI's scheme."""
2205N/A
3158N/A def __str__(self):
3158N/A return _("'%(attr)s' is not supported for '%(scheme)s'.") % {
2205N/A "attr": self.data, "scheme": self.args["scheme"] }
3158N/A
2205N/A
2205N/Aclass CertificateError(ApiException):
2239N/A """Base exception class for all certificate exceptions."""
2205N/A
2205N/A def __init__(self, *args, **kwargs):
3347N/A ApiException.__init__(self, *args)
3347N/A if args:
3347N/A self.data = args[0]
2205N/A else:
2205N/A self.data = None
2205N/A self.args = kwargs
3206N/A
3206N/A def __str__(self):
3206N/A return str(self.data)
3206N/A
3206N/A
3206N/Aclass ExpiredCertificate(CertificateError):
3206N/A """Used to indicate that a certificate has expired."""
3206N/A
3206N/A def __str__(self):
3206N/A publisher = self.args.get("publisher", None)
3206N/A uri = self.args.get("uri", None)
3206N/A if publisher:
3206N/A if uri:
3206N/A return _("Certificate '%(cert)s' for publisher "
3206N/A "'%(pub)s' needed to access '%(uri)s', "
3206N/A "has expired. Please install a valid "
3206N/A "certificate.") % { "cert": self.data,
3206N/A "pub": publisher, "uri": uri }
3206N/A return _("Certificate '%(cert)s' for publisher "
3206N/A "'%(pub)s', has expired. Please install a valid "
3206N/A "certificate.") % { "cert": self.data,
3206N/A "pub": publisher }
3206N/A if uri:
3206N/A return _("Certificate '%(cert)s', needed to access "
3206N/A "'%(uri)s', has expired. Please install a valid "
3206N/A "certificate.") % { "cert": self.data, "uri": uri }
3206N/A return _("Certificate '%s' has expired. Please install a "
3206N/A "valid certificate.") % self.data
3206N/A
3206N/A
3206N/Aclass ExpiringCertificate(CertificateError):
3206N/A """Used to indicate that a certificate has expired."""
3206N/A
3206N/A def __str__(self):
3206N/A publisher = self.args.get("publisher", None)
3206N/A uri = self.args.get("uri", None)
3206N/A days = self.args.get("days", 0)
3206N/A if publisher:
3206N/A if uri:
3206N/A return _("Certificate '%(cert)s' for publisher "
3206N/A "'%(pub)s', needed to access '%(uri)s', "
3206N/A "will expire in '%(days)s' days.") % {
3206N/A "cert": self.data, "pub": publisher,
3206N/A "uri": uri, "days": days }
3206N/A return _("Certificate '%(cert)s' for publisher "
3206N/A "'%(pub)s' will expire in '%(days)s' days.") % {
3206N/A "cert": self.data, "pub": publisher, "days": days }
3206N/A if uri:
3206N/A return _("Certificate '%(cert)s', needed to access "
3206N/A "'%(uri)s', will expire in '%(days)s' days.") % {
3206N/A "cert": self.data, "uri": uri, "days": days }
3206N/A return _("Certificate '%(cert)s' will expire in "
3206N/A "'%(days)s' days.") % { "cert": self.data, "days": days }
3206N/A
3206N/A
3206N/Aclass InvalidCertificate(CertificateError):
3206N/A """Used to indicate that a certificate is invalid."""
3206N/A
3206N/A def __str__(self):
3206N/A publisher = self.args.get("publisher", None)
3206N/A uri = self.args.get("uri", None)
3206N/A if publisher:
3206N/A if uri:
3206N/A return _("Certificate '%(cert)s' for publisher "
3206N/A "'%(pub)s', needed to access '%(uri)s', is "
3206N/A "invalid.") % { "cert": self.data,
3206N/A "pub": publisher, "uri": uri }
3206N/A return _("Certificate '%(cert)s' for publisher "
3206N/A "'%(pub)s' is invalid.") % { "cert": self.data,
3206N/A "pub": publisher }
3206N/A if uri:
3206N/A return _("Certificate '%(cert)s' needed to access "
3206N/A "'%(uri)s' is invalid.") % { "cert": self.data,
3206N/A "uri": uri }
3206N/A return _("Invalid certificate '%s'.") % self.data
3206N/A
3206N/A
3206N/Aclass NoSuchKey(CertificateError):
3206N/A """Used to indicate that a key could not be found."""
3206N/A
3206N/A def __str__(self):
3206N/A publisher = self.args.get("publisher", None)
3206N/A uri = self.args.get("uri", None)
3206N/A if publisher:
3206N/A if uri:
3206N/A return _("Unable to locate key '%(key)s' for "
3206N/A "publisher '%(pub)s' needed to access "
3206N/A "'%(uri)s'.") % { "key": self.data,
3206N/A "pub": publisher, "uri": uri }
3206N/A return _("Unable to locate key '%(key)s' for publisher "
3206N/A "'%(pub)s'.") % { "key": self.data, "pub": publisher
3206N/A }
3206N/A if uri:
3206N/A return _("Unable to locate key '%(key)s' needed to "
3206N/A "access '%(uri)s'.") % { "key": self.data,
3206N/A "uri": uri }
3206N/A return _("Unable to locate key '%s'.") % self.data
3206N/A
3206N/A
3206N/Aclass NoSuchCertificate(CertificateError):
3206N/A """Used to indicate that a certificate could not be found."""
3206N/A
3206N/A def __str__(self):
3206N/A publisher = self.args.get("publisher", None)
3206N/A uri = self.args.get("uri", None)
3206N/A if publisher:
3206N/A if uri:
3206N/A return _("Unable to locate certificate "
3206N/A "'%(cert)s' for publisher '%(pub)s' needed "
3206N/A "to access '%(uri)s'.") % {
3206N/A "cert": self.data, "pub": publisher,
3206N/A "uri": uri }
3206N/A return _("Unable to locate certificate '%(cert)s' for "
3206N/A "publisher '%(pub)s'.") % { "cert": self.data,
3206N/A "pub": publisher }
3206N/A if uri:
3206N/A return _("Unable to locate certificate '%(cert)s' "
3206N/A "needed to access '%(uri)s'.") % {
3206N/A "cert": self.data, "uri": uri }
3206N/A return _("Unable to locate certificate '%s'.") % self.data
3206N/A
3206N/A
3206N/Aclass NotYetValidCertificate(CertificateError):
3206N/A """Used to indicate that a certificate is not yet valid (future
2205N/A effective date)."""
2205N/A
2205N/A def __str__(self):
2205N/A publisher = self.args.get("publisher", None)
2205N/A uri = self.args.get("uri", None)
2205N/A if publisher:
2205N/A if uri:
2205N/A return _("Certificate '%(cert)s' for publisher "
2205N/A "'%(pub)s', needed to access '%(uri)s', "
2205N/A "has a future effective date.") % {
2205N/A "cert": self.data, "pub": publisher,
3158N/A "uri": uri }
3158N/A return _("Certificate '%(cert)s' for publisher "
3158N/A "'%(pub)s' has a future effective date.") % {
3158N/A "cert": self.data, "pub": publisher }
2205N/A if uri:
2205N/A return _("Certificate '%(cert)s' needed to access "
2205N/A "'%(uri)s' has a future effective date.") % {
2205N/A "cert": self.data, "uri": uri }
3158N/A return _("Certificate '%s' has a future effective date.") % \
2205N/A self.data
2205N/A
3158N/A
3158N/Aclass ServerReturnError(ApiException):
3158N/A """This exception is used when the server reutrns a line which the
3158N/A client cannot parse correctly."""
3158N/A
1068N/A def __init__(self, line):
1050N/A ApiException.__init__(self)
1859N/A self.line = line
1859N/A
1050N/A def __str__(self):
1050N/A return _("Gave a bad response:%s") % self.line
1859N/A