api_errors.py revision 1130
565N/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#
835N/A# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
565N/A# Use is subject to license terms.
926N/A#
565N/A
1051N/Aimport httplib
1050N/Aimport os
941N/Aimport socket
941N/Aimport urllib2
926N/Aimport urlparse
926N/A
926N/A# EmptyI for argument defaults; can't import from misc due to circular
926N/A# dependency.
926N/AEmptyI = tuple()
838N/A
565N/Aclass ApiException(Exception):
565N/A pass
565N/A
565N/Aclass ImageNotFoundException(ApiException):
565N/A """Used when an image was not found"""
565N/A def __init__(self, user_specified, user_dir, root_dir):
565N/A ApiException.__init__(self)
565N/A self.user_specified = user_specified
565N/A self.user_dir = user_dir
565N/A self.root_dir = root_dir
565N/A
565N/Aclass NetworkUnavailableException(ApiException):
565N/A def __init__(self, caught_exception):
565N/A ApiException.__init__(self)
565N/A self.ex = caught_exception
565N/A
565N/A def __str__(self):
565N/A return str(self.ex)
565N/A
565N/Aclass VersionException(ApiException):
565N/A def __init__(self, expected_version, received_version):
565N/A ApiException.__init__(self)
565N/A self.expected_version = expected_version
565N/A self.received_version = received_version
565N/A
565N/Aclass PlanExistsException(ApiException):
565N/A def __init__(self, plan_type):
565N/A ApiException.__init__(self)
565N/A self.plan_type = plan_type
565N/A
1019N/Aclass ActuatorException(ApiException):
1019N/A def __init__(self, e):
1019N/A ApiException.__init__(self)
1019N/A self.exception = e
1019N/A
1019N/A def __str__(self):
1019N/A return str(self.exception)
1019N/A
565N/Aclass PrematureExecutionException(ApiException):
565N/A pass
565N/A
565N/Aclass AlreadyPreparedException(ApiException):
565N/A pass
565N/A
565N/Aclass AlreadyExecutedException(ApiException):
565N/A pass
565N/A
565N/Aclass ImageplanStateException(ApiException):
565N/A def __init__(self, state):
565N/A ApiException.__init__(self)
565N/A self.state = state
565N/A
565N/Aclass IpkgOutOfDateException(ApiException):
565N/A pass
565N/A
565N/Aclass ImageUpdateOnLiveImageException(ApiException):
565N/A pass
565N/A
565N/Aclass CanceledException(ApiException):
565N/A pass
565N/A
565N/Aclass PlanMissingException(ApiException):
565N/A pass
565N/A
565N/Aclass NoPackagesInstalledException(ApiException):
565N/A pass
565N/A
685N/Aclass PermissionsException(ApiException):
685N/A def __init__(self, path):
685N/A ApiException.__init__(self)
685N/A self.path = path
685N/A
685N/A def __str__(self):
685N/A if self.path:
926N/A return _("Could not operate on %s\nbecause of "
926N/A "insufficient permissions. Please try the command "
926N/A "again using pfexec\nor otherwise increase your "
926N/A "privileges.") % self.path
685N/A else:
685N/A return _("""
685N/ACould not complete the operation because of insufficient permissions. Please
926N/Atry the command again using pfexec or otherwise increase your privileges.
685N/A""")
685N/A
879N/Aclass FileInUseException(PermissionsException):
879N/A def __init__(self, path):
879N/A PermissionsException.__init__(self, path)
879N/A assert path
879N/A
879N/A def __str__(self):
879N/A return _("Could not operate on %s\nbecause the file is "
879N/A "in use. Please stop using the file and try the\n"
879N/A "operation again.") % self.path
879N/A
565N/Aclass PlanCreationException(ApiException):
838N/A def __init__(self, unfound_fmris=EmptyI, multiple_matches=EmptyI,
926N/A missing_matches=EmptyI, illegal=EmptyI,
926N/A constraint_violations=EmptyI, badarch=EmptyI):
565N/A ApiException.__init__(self)
838N/A self.unfound_fmris = unfound_fmris
838N/A self.multiple_matches = multiple_matches
838N/A self.missing_matches = missing_matches
838N/A self.illegal = illegal
838N/A self.constraint_violations = constraint_violations
838N/A self.badarch = badarch
838N/A
565N/A def __str__(self):
616N/A res = []
616N/A if self.unfound_fmris:
616N/A s = _("""\
988N/AThe following pattern(s) did not match any packages in the current catalog.
988N/ATry relaxing the pattern, refreshing and/or examining the catalogs:""")
926N/A res += [s]
926N/A res += ["\t%s" % p for p in self.unfound_fmris]
565N/A
565N/A if self.multiple_matches:
988N/A s = _("'%s' matches multiple packages")
565N/A for p, lst in self.multiple_matches:
922N/A res.append(s % p)
922N/A for pfmri in lst:
633N/A res.append("\t%s" % pfmri)
616N/A
988N/A s = _("'%s' matches no installed packages")
616N/A res += [ s % p for p in self.missing_matches ]
616N/A
988N/A s = _("'%s' is an illegal fmri")
616N/A res += [ s % p for p in self.illegal ]
616N/A
655N/A if self.constraint_violations:
988N/A s = _("The following package(s) violated constraints:")
1027N/A res += [s]
926N/A res += ["\t%s" % p for p in self.constraint_violations]
655N/A
838N/A if self.badarch:
838N/A s = _("'%s' supports the following architectures: %s")
838N/A a = _("Image architecture is defined as: %s")
1027N/A res += [ s % (self.badarch[0],
838N/A ", ".join(self.badarch[1]))]
838N/A res += [ a % (self.badarch[2])]
838N/A
565N/A return '\n'.join(res)
565N/A
1068N/A
1050N/Aclass ActionExecutionError(ApiException):
1050N/A """An error was encountered executing an action.
1050N/A
1050N/A In particular, this exception indicates that something went wrong in the
1050N/A application (or unapplication) of the action to the system, not an error
1050N/A in the pkg(5) code.
1050N/A
1050N/A The 'msg' argument can provide a more specific message than what would
1050N/A be returned from, and 'ignoreerrno' can be set to True to indicate that
1050N/A the sterror() text is misleading, and shouldn't be displayed.
1050N/A """
1050N/A
1050N/A def __init__(self, action, exception, msg=None, ignoreerrno=False):
1050N/A self.action = action
1050N/A self.exception = exception
1050N/A self.msg = msg
1050N/A self.ignoreerrno = ignoreerrno
1050N/A
1050N/A def __str__(self):
1050N/A errno = ""
1050N/A if not self.ignoreerrno and hasattr(self.exception, "errno"):
1050N/A errno = "[errno %d: %s]" % (self.exception.errno,
1050N/A os.strerror(self.exception.errno))
1050N/A
1050N/A msg = self.msg or ""
1050N/A
1050N/A # Fall back on the wrapped exception if we don't have anything
1050N/A # useful.
1050N/A if not errno and not msg:
1050N/A return str(self.exception)
1050N/A
1050N/A if errno and msg:
1050N/A return "%s: %s" % (errno, msg)
1050N/A
1050N/A # If we only have one of the two, no need for the colon.
1050N/A return "%s%s" % (errno, msg)
1050N/A
1068N/A
1068N/Aclass CatalogCacheError(ApiException):
1068N/A """Base class used for all catalog cache errors."""
1068N/A
1068N/A def __init__(self, *args, **kwargs):
1068N/A ApiException.__init__(self, *args)
1068N/A if args:
1068N/A self.data = args[0]
1068N/A else:
1068N/A self.data = None
1068N/A self.args = kwargs
1068N/A
1068N/A
1068N/Aclass CatalogCacheBadVersion(CatalogCacheError):
1068N/A """Used to indicate that the catalog cache is invalid or is not of a
1068N/A supported version."""
1068N/A
1068N/A def __str__(self):
1068N/A return _("Unsupported catalog cache Version: '%(found)s'; "
1068N/A "expected: '%(expected)s'") % { "found": self.data,
1068N/A "expected": self.args["expected"] }
1068N/A
1068N/A
1068N/Aclass CatalogCacheInvalid(CatalogCacheError):
1068N/A """Used to indicate that the catalog cache is corrupt or otherwise
1068N/A unparseable."""
1068N/A
1068N/A def __str__(self):
1068N/A return _("Catalog cache is corrupt or invalid; error "
1068N/A "encountered while reading:\nline %(lnum)d: '%(data)s'") % {
1068N/A "lnum": self.args["line_number"], "data": self.data }
1068N/A
1068N/A
1068N/Aclass CatalogCacheMissing(CatalogCacheError):
1068N/A """Used to indicate that the catalog cache is missing."""
1068N/A
1068N/A def __str__(self):
1068N/A return _("Catalog cache is missing.")
1068N/A
1068N/A
565N/Aclass CatalogRefreshException(ApiException):
565N/A def __init__(self, failed, total, succeeded, message=None):
565N/A ApiException.__init__(self)
565N/A self.failed = failed
565N/A self.total = total
565N/A self.succeeded = succeeded
565N/A self.message = message
565N/A
1068N/A
565N/Aclass InventoryException(ApiException):
838N/A def __init__(self, notfound=EmptyI, illegal=EmptyI):
565N/A ApiException.__init__(self)
838N/A self.notfound = notfound
838N/A self.illegal = illegal
565N/A assert(self.notfound or self.illegal)
565N/A
596N/A def __str__(self):
596N/A outstr = ""
596N/A for x in self.illegal:
596N/A # Illegal FMRIs have their own __str__ method
596N/A outstr += "%s\n" % x
614N/A
614N/A if self.notfound:
614N/A outstr += _("No matching package could be found for "
614N/A "the following FMRIs in any of the catalogs for "
926N/A "the current publishers:\n")
614N/A
614N/A for x in self.notfound:
614N/A outstr += "%s\n" % x
614N/A
596N/A return outstr
565N/A
1027N/A
1027N/Aclass SearchException(ApiException):
1027N/A """Based class used for all search-related api exceptions."""
1027N/A pass
1027N/A
1027N/A
1027N/Aclass IndexingException(SearchException):
565N/A """ The base class for all exceptions that can occur while indexing. """
1027N/A
565N/A def __init__(self, private_exception):
1027N/A SearchException.__init__(self)
565N/A self.cause = private_exception.cause
565N/A
1027N/A
565N/Aclass CorruptedIndexException(IndexingException):
565N/A """This is used when the index is not in a correct state."""
565N/A pass
565N/A
1027N/A
565N/Aclass ProblematicPermissionsIndexException(IndexingException):
565N/A """ This is used when the indexer is unable to create, move, or remove
565N/A files or directories it should be able to. """
565N/A def __str__(self):
565N/A return "Could not remove or create " \
565N/A "%s because of incorrect " \
565N/A "permissions. Please correct this issue then " \
565N/A "rebuild the index." % self.cause
941N/A
941N/A
1027N/Aclass MainDictParsingException(SearchException):
941N/A """This is used when the main dictionary could not parse a line."""
941N/A def __init__(self, e):
1027N/A SearchException.__init__(self)
941N/A self.e = e
941N/A
941N/A def __str__(self):
1027N/A return str(self.e)
1027N/A
565N/A
565N/Aclass NonLeafPackageException(ApiException):
565N/A """Removal of a package which satisfies dependencies has been attempted.
1027N/A
565N/A The first argument to the constructor is the FMRI which we tried to
565N/A remove, and is available as the "fmri" member of the exception. The
565N/A second argument is the list of dependent packages that prevent the
565N/A removal of the package, and is available as the "dependents" member.
565N/A """
565N/A
565N/A def __init__(self, *args):
565N/A ApiException.__init__(self, *args)
565N/A
565N/A self.fmri = args[0]
565N/A self.dependents = args[1]
835N/A
835N/Aclass InvalidDepotResponseException(ApiException):
835N/A """Raised when the depot doesn't have versions of operations
835N/A that the client needs to operate successfully."""
835N/A def __init__(self, url, data):
926N/A ApiException.__init__(self)
835N/A self.url = url
835N/A self.data = data
835N/A
835N/A def __str__(self):
835N/A s = "Unable to contact valid package server"
835N/A if self.url:
835N/A s += ": %s" % self.url
835N/A if self.data:
835N/A s += "\nEncountered the following error(s):\n%s" % \
835N/A self.data
835N/A return s
884N/A
926N/Aclass DataError(ApiException):
926N/A """Base exception class used for all data related errors."""
926N/A
926N/A def __init__(self, *args, **kwargs):
926N/A ApiException.__init__(self, *args)
926N/A if args:
926N/A self.data = args[0]
926N/A else:
926N/A self.data = None
926N/A self.args = kwargs
926N/A
926N/A
926N/Aclass InvalidP5IFile(DataError):
926N/A """Used to indicate that the specified location does not contain a
926N/A valid p5i-formatted file."""
926N/A
926N/A def __str__(self):
926N/A if self.data:
926N/A return _("The specified file is in an unrecognized "
926N/A "format or does not contain valid publisher "
926N/A "information: %s") % self.data
926N/A return _("The specified file is in an unrecognized format or "
926N/A "does not contain valid publisher information.")
926N/A
926N/A
926N/Aclass UnsupportedP5IFile(DataError):
926N/A """Used to indicate that an attempt to read an unsupported version
926N/A of pkg(5) info file was attempted."""
926N/A
926N/A def __str__(self):
926N/A return _("Unsupported pkg(5) publisher information data "
926N/A "format.")
926N/A
926N/A
926N/Aclass TransportError(ApiException):
926N/A """Base exception class for all transfer exceptions."""
926N/A
926N/A def __init__(self, *args, **kwargs):
926N/A ApiException.__init__(self, *args)
926N/A if args:
926N/A self.data = args[0]
926N/A else:
926N/A self.data = None
926N/A self.args = kwargs
926N/A
926N/A def __str__(self):
926N/A return str(self.data)
926N/A
926N/A
926N/Aclass RetrievalError(TransportError):
926N/A """Used to indicate that a a requested resource could not be
926N/A retrieved."""
926N/A
926N/A def __str__(self):
926N/A location = self.args.get("location", None)
926N/A if location:
926N/A return _("Error encountered while retrieving data from "
926N/A "'%s':\n%s") % (location, self.data)
926N/A return _("Error encountered while retrieving data from: %s") % \
926N/A self.data
926N/A
926N/A
926N/Aclass InvalidResourceLocation(TransportError):
926N/A """Used to indicate that an invalid transport location was provided."""
926N/A
926N/A def __str__(self):
926N/A return _("'%s' is not a valid location.") % self.data
926N/A
941N/Aclass BEException(ApiException):
941N/A def __init__(self):
941N/A ApiException.__init__(self)
926N/A
884N/Aclass InvalidBENameException(BEException):
884N/A def __init__(self, be_name):
884N/A BEException.__init__(self)
884N/A self.be_name = be_name
884N/A
884N/A def __str__(self):
1076N/A return _("'%s' is not a valid boot environment name.") % \
1076N/A self.be_name
1076N/A
1076N/Aclass DuplicateBEName(BEException):
1076N/A """Used to indicate that there is an existing boot environment
1076N/A with this name"""
1076N/A
1076N/A def __init__(self, be_name):
1076N/A BEException.__init__(self)
1076N/A self.be_name = be_name
1076N/A
1076N/A def __str__(self):
1076N/A return _("The boot environment '%s' already exists.") % \
1076N/A self.be_name
884N/A
884N/Aclass BENamingNotSupported(BEException):
884N/A def __init__(self, be_name):
884N/A BEException.__init__(self)
884N/A self.be_name = be_name
884N/A
884N/A def __str__(self):
884N/A return _("""\
884N/ABoot environment naming during package install is not supported on this
884N/Aversion of OpenSolaris. Please image-update without the --be-name option.""")
884N/A
884N/Aclass UnableToCopyBE(BEException):
884N/A def __str__(self):
884N/A return _("Unable to clone the current boot environment.")
884N/A
884N/Aclass UnableToRenameBE(BEException):
884N/A def __init__(self, orig, dest):
884N/A BEException.__init__(self)
884N/A self.original_name = orig
884N/A self.destination_name = dest
884N/A
884N/A def __str__(self):
884N/A d = {
884N/A "orig": self.original_name,
884N/A "dest": self.destination_name
884N/A }
884N/A return _("""\
884N/AA problem occurred while attempting to rename the boot environment
884N/Acurrently named %(orig)s to %(dest)s.""") % d
884N/A
884N/Aclass UnableToMountBE(BEException):
884N/A def __init__(self, be_name, be_dir):
884N/A BEException.__init__(self)
884N/A self.name = be_name
884N/A self.mountpoint = be_dir
884N/A
884N/A def __str__(self):
884N/A return _("Unable to mount %(name)s at %(mt)s") % \
884N/A {"name": self.name, "mt": self.mountpoint}
884N/A
884N/Aclass BENameGivenOnDeadBE(BEException):
884N/A def __init__(self, be_name):
884N/A BEException.__init__(self)
884N/A self.name = be_name
884N/A
884N/A def __str__(self):
884N/A return _("""\
884N/ANaming a boot environment when operating on a non-live image is
884N/Anot allowed.""")
926N/A
926N/A
917N/Aclass UnrecognizedOptionsToInfo(ApiException):
917N/A def __init__(self, opts):
917N/A ApiException.__init__(self)
917N/A self._opts = opts
917N/A
917N/A def __str__(self):
917N/A s = _("Info does not recognize the following options:")
917N/A for o in self._opts:
917N/A s += _(" '") + str(o) + _("'")
917N/A return s
926N/A
926N/A
1027N/Aclass ProblematicSearchServers(SearchException):
1100N/A """This class wraps exceptions which could appear while trying to
1100N/A do a search request."""
1100N/A
941N/A def __init__(self, failed, invalid):
941N/A self.failed_servers = failed
941N/A self.invalid_servers = invalid
941N/A
941N/A def __str__(self):
941N/A s = _("Some servers failed to respond appropriately:\n")
941N/A for pub, err in self.failed_servers:
1051N/A # The messages and structure for these error
1051N/A # messages was often lifted from retrieve.py.
941N/A if isinstance(err, urllib2.HTTPError):
1051N/A s += _(" %(o)s: %(msg)s (%(code)d)\n") % \
1051N/A { "o": pub["origin"], "msg": err.msg,
1051N/A "code": err.code }
941N/A elif isinstance(err, urllib2.URLError):
941N/A if isinstance(err.args[0], socket.timeout):
1051N/A s += _(" %s: timeout\n") % \
1051N/A (pub["origin"],)
941N/A else:
1051N/A s += _(" %(o)s: %(other)s\n") % \
1051N/A { "o": pub["origin"],
1051N/A "other": err.args[0][1] }
1051N/A elif isinstance(err, httplib.BadStatusLine):
1051N/A s += _(" %(o)s: Unable to read status of "
1051N/A "HTTP response:%(l)s\n This is "
1051N/A "most likely not a pkg(5) depot. Please "
1051N/A "check the URL and the \n port "
1051N/A "number.") % \
1051N/A { "o": pub["origin"], "l": err.line}
1051N/A elif isinstance(err,
1051N/A (httplib.IncompleteRead, ValueError)):
1051N/A s += _(" %s: Incomplete read from "
1051N/A "host") % pub["origin"]
1100N/A # RunetimeErrors arise when no supported version
1100N/A # of the operation request is found.
941N/A elif isinstance(err, RuntimeError):
1051N/A s += _(" %(o)s: %(msg)s\n") % \
1051N/A { "o": pub["origin"], "msg": err}
1051N/A elif isinstance(err, socket.timeout):
1051N/A s += _(" %s: Socket timeout") % pub["origin"]
1051N/A elif isinstance(err, socket.error):
1051N/A s += _(" %(o)s: Socket error, reason: "
1051N/A "%(msg)s") % { "o": pub["origin"],
1051N/A "msg": err }
941N/A else:
1051N/A s += _(" %(o)s: %(msg)s") % \
1051N/A { "o": pub["origin"], "msg": err}
941N/A for pub in self.invalid_servers:
941N/A s += _("%s appears not to be a valid package depot.\n" \
941N/A % pub['origin'])
941N/A return s
941N/A
941N/A
941N/Aclass IncorrectIndexFileHash(ApiException):
941N/A """This is used when the index hash value doesn't match the hash of the
941N/A packages installed in the image."""
941N/A pass
941N/A
941N/A
1027N/Aclass InconsistentIndexException(IndexingException):
941N/A """This is used when the existing index is found to have inconsistent
941N/A versions."""
941N/A def __init__(self, e):
941N/A self.exception = e
941N/A
941N/A def __str__(self):
941N/A return str(self.exception)
941N/A
941N/A
1027N/Aclass SlowSearchUsed(SearchException):
1100N/A """This exception is thrown when a local search is performed without
1100N/A an index. It's raised after all results have been yielded."""
1100N/A
941N/A def __str__(self):
941N/A return _("Search capabilities and performance are degraded.\n"
941N/A "To improve, run 'pkg rebuild-index'.")
941N/A
941N/A
941N/Aclass BooleanQueryException(ApiException):
1100N/A """This exception is used when the children of a boolean operation
1100N/A have different return types. The command 'pkg search foo AND <bar>'
1100N/A is the simplest example of this."""
1100N/A
1053N/A def __init__(self, e):
941N/A ApiException.__init__(self)
1053N/A self.e = e
941N/A
941N/A def __str__(self):
1053N/A return str(self.e)
1053N/A
1100N/A
1053N/Aclass ParseError(ApiException):
1053N/A def __init__(self, e):
1053N/A ApiException.__init__(self)
1053N/A self.e = e
1053N/A
1053N/A def __str__(self):
1053N/A return str(self.e)
941N/A
941N/A
926N/Aclass PublisherError(ApiException):
926N/A """Base exception class for all publisher exceptions."""
926N/A
926N/A def __init__(self, *args, **kwargs):
926N/A ApiException.__init__(self, *args)
926N/A if args:
926N/A self.data = args[0]
926N/A else:
926N/A self.data = None
926N/A self.args = kwargs
926N/A
926N/A def __str__(self):
926N/A return str(self.data)
926N/A
926N/A
1087N/Aclass BadPublisherMetaRoot(PublisherError):
1087N/A """Used to indicate an operation on the publisher's meta_root failed
1087N/A because the meta_root is invalid."""
1087N/A
1087N/A def __str__(self):
1087N/A return _("Publisher meta_root '%(root)s' is invalid; unable "
1087N/A "to complete operation: '%(op)s'.") % { "root": self.data,
1087N/A "op": self.args.get("operation", None) }
1087N/A
1087N/A
926N/Aclass BadPublisherPrefix(PublisherError):
926N/A """Used to indicate that a publisher name is not valid."""
926N/A
926N/A def __str__(self):
926N/A return _("'%s' is not a valid publisher name.") % self.data
926N/A
926N/A
926N/Aclass BadRepositoryAttributeValue(PublisherError):
926N/A """Used to indicate that the specified repository attribute value is
926N/A invalid."""
926N/A
926N/A def __str__(self):
926N/A return _("'%(value)s' is not a valid value for repository "
926N/A "attribute '%(attribute)s'.") % {
926N/A "value": self.args["value"], "attribute": self.data }
926N/A
926N/A
926N/Aclass BadRepositoryCollectionType(PublisherError):
926N/A """Used to indicate that the specified repository collection type is
926N/A invalid."""
926N/A
926N/A def __init__(self, *args, **kwargs):
926N/A PublisherError.__init__(self, *args, **kwargs)
926N/A
926N/A def __str__(self):
926N/A return _("'%s' is not a valid repository collection type.") % \
926N/A self.data
926N/A
926N/A
926N/Aclass BadRepositoryURI(PublisherError):
926N/A """Used to indicate that a repository URI is not syntactically valid."""
926N/A
926N/A def __str__(self):
926N/A return _("'%s' is not a valid URI.") % self.data
926N/A
926N/A
926N/Aclass BadRepositoryURIPriority(PublisherError):
926N/A """Used to indicate that the priority specified for a repository URI is
926N/A not valid."""
926N/A
926N/A def __str__(self):
926N/A return _("'%s' is not a valid URI priority; integer value "
926N/A "expected.") % self.data
926N/A
926N/A
926N/Aclass BadRepositoryURISortPolicy(PublisherError):
926N/A """Used to indicate that the specified repository URI sort policy is
926N/A invalid."""
926N/A
926N/A def __init__(self, *args, **kwargs):
926N/A PublisherError.__init__(self, *args, **kwargs)
926N/A
926N/A def __str__(self):
926N/A return _("'%s' is not a valid repository URI sort policy.") % \
926N/A self.data
926N/A
926N/A
926N/Aclass DisabledPublisher(PublisherError):
926N/A """Used to indicate that an attempt to use a disabled publisher occurred
926N/A during an operation."""
926N/A
926N/A def __str__(self):
926N/A return _("Publisher '%s' is disabled and cannot be used for "
926N/A "packaging operations.") % self.data
926N/A
926N/A
926N/Aclass DuplicatePublisher(PublisherError):
926N/A """Used to indicate that a publisher with the same name or alias already
926N/A exists for an image."""
926N/A
926N/A def __str__(self):
926N/A return _("A publisher with the same name or alias as '%s' "
926N/A "already exists.") % self.data
926N/A
926N/A
926N/Aclass DuplicateRepository(PublisherError):
926N/A """Used to indicate that a repository with the same origin uris
926N/A already exists for a publisher."""
926N/A
926N/A def __str__(self):
926N/A return _("A repository with the same name or origin URIs "
926N/A "already exists for publisher '%s'.") % self.data
926N/A
926N/A
926N/Aclass DuplicateRepositoryMirror(PublisherError):
926N/A """Used to indicate that a repository URI is already in use by another
926N/A repository mirror."""
926N/A
926N/A def __str__(self):
926N/A return _("Mirror '%s' already exists for the specified "
926N/A "repository.") % self.data
926N/A
926N/A
926N/Aclass DuplicateRepositoryOrigin(PublisherError):
926N/A """Used to indicate that a repository URI is already in use by another
926N/A repository origin."""
926N/A
926N/A def __str__(self):
926N/A return _("Origin '%s' already exists for the specified "
926N/A "repository.") % self.data
926N/A
926N/A
926N/Aclass RemovePreferredPublisher(PublisherError):
926N/A """Used to indicate an attempt to remove the preferred publisher was
926N/A made."""
926N/A
926N/A def __str__(self):
926N/A return _("The preferred publisher cannot be removed.")
926N/A
926N/A
926N/Aclass SelectedRepositoryRemoval(PublisherError):
926N/A """Used to indicate that an attempt to remove the selected repository
926N/A for a publisher was made."""
926N/A
926N/A def __str__(self):
926N/A return _("Cannot remove the selected repository for a "
926N/A "publisher.")
926N/A
926N/A
926N/Aclass SetPreferredPublisherDisabled(PublisherError):
926N/A """Used to indicate an attempt to set a disabled publisher as the
926N/A preferred publisher was made."""
926N/A
926N/A def __str__(self):
996N/A return _("Publisher '%s' is disabled and cannot be set as the "
996N/A "preferred publisher.") % self.data
926N/A
926N/A
926N/Aclass UnknownLegalURI(PublisherError):
926N/A """Used to indicate that no matching legal URI could be found using the
926N/A provided criteria."""
926N/A
926N/A def __str__(self):
926N/A return _("Unknown legal URI '%s'.") % self.data
926N/A
926N/A
926N/Aclass UnknownPublisher(PublisherError):
926N/A """Used to indicate that no matching publisher could be found using the
926N/A provided criteria."""
926N/A
926N/A def __str__(self):
926N/A return _("Unknown publisher '%s'.") % self.data
926N/A
926N/A
926N/Aclass UnknownRelatedURI(PublisherError):
926N/A """Used to indicate that no matching related URI could be found using
926N/A the provided criteria."""
926N/A
926N/A def __str__(self):
926N/A return _("Unknown related URI '%s'.") % self.data
926N/A
926N/A
926N/Aclass UnknownRepository(PublisherError):
926N/A """Used to indicate that no matching repository could be found using the
926N/A provided criteria."""
926N/A
926N/A def __str__(self):
926N/A return _("Unknown repository '%s'.") % self.data
926N/A
926N/A
926N/Aclass UnknownRepositoryMirror(PublisherError):
926N/A """Used to indicate that a repository URI could not be found in the
926N/A list of repository mirrors."""
926N/A
926N/A def __str__(self):
926N/A return _("Unknown repository mirror '%s'.") % self.data
926N/A
926N/A
926N/Aclass UnknownRepositoryOrigin(PublisherError):
926N/A """Used to indicate that a repository URI could not be found in the
926N/A list of repository origins."""
926N/A
926N/A def __str__(self):
926N/A return _("Unknown repository origin '%s'") % self.data
926N/A
926N/A
926N/Aclass UnsupportedRepositoryURI(PublisherError):
926N/A """Used to indicate that the specified repository URI uses an
926N/A unsupported scheme."""
926N/A
926N/A def __str__(self):
926N/A if self.data:
926N/A scheme = urlparse.urlsplit(self.data,
926N/A allow_fragments=0)[0]
926N/A return _("The URI '%(uri)s' contains an unsupported "
926N/A "scheme '%(scheme)s'.") % { "uri": self.data,
926N/A "scheme": scheme }
926N/A return _("The specified URI contains an unsupported scheme.")
926N/A
926N/A
926N/Aclass UnsupportedRepositoryURIAttribute(PublisherError):
926N/A """Used to indicate that the specified repository URI attribute is not
926N/A supported for the URI's scheme."""
926N/A
926N/A def __str__(self):
926N/A return _("'%(attr)s' is not supported for '%(scheme)s'.") % {
926N/A "attr": self.data, "scheme": self.args["scheme"] }
926N/A
926N/A
926N/Aclass CertificateError(ApiException):
926N/A """Base exception class for all certificate exceptions."""
926N/A
926N/A def __init__(self, *args, **kwargs):
926N/A ApiException.__init__(self, *args)
926N/A if args:
926N/A self.data = args[0]
926N/A else:
926N/A self.data = None
926N/A self.args = kwargs
926N/A
926N/A def __str__(self):
926N/A return str(self.data)
926N/A
926N/A
926N/Aclass ExpiredCertificate(CertificateError):
926N/A """Used to indicate that a certificate has expired."""
926N/A
926N/A def __str__(self):
926N/A publisher = self.args.get("publisher", None)
926N/A uri = self.args.get("uri", None)
926N/A if publisher:
926N/A if uri:
926N/A return _("Certificate '%(cert)s' for publisher "
926N/A "'%(pub)s' needed to access '%(uri)s', "
926N/A "has expired. Please install a valid "
926N/A "certificate.") % { "cert": self.data,
1130N/A "pub": publisher, "uri": uri }
926N/A return _("Certificate '%(cert)s' for publisher "
926N/A "'%(pub)s', has expired. Please install a valid "
926N/A "certificate.") % { "cert": self.data,
926N/A "pub": publisher }
926N/A if uri:
926N/A return _("Certificate '%(cert)s', needed to access "
926N/A "'%(uri)s', has expired. Please install a valid "
926N/A "certificate.") % { "cert": self.data, "uri": uri }
926N/A return _("Certificate '%s' has expired. Please install a "
926N/A "valid certificate.") % self.data
926N/A
926N/A
926N/Aclass ExpiringCertificate(CertificateError):
926N/A """Used to indicate that a certificate has expired."""
926N/A
926N/A def __str__(self):
926N/A publisher = self.args.get("publisher", None)
926N/A uri = self.args.get("uri", None)
926N/A days = self.args.get("days", 0)
926N/A if publisher:
926N/A if uri:
926N/A return _("Certificate '%(cert)s' for publisher "
926N/A "'%(pub)s', needed to access '%(uri)s', "
926N/A "will expire in '%(days)s' days.") % {
926N/A "cert": self.data, "pub": publisher,
926N/A "uri": uri, "days": days }
926N/A return _("Certificate '%(cert)s' for publisher "
926N/A "'%(pub)s' will expire in '%(days)s' days.") % {
926N/A "cert": self.data, "pub": publisher, "days": days }
926N/A if uri:
926N/A return _("Certificate '%(cert)s', needed to access "
926N/A "'%(uri)s', will expire in '%(days)s' days.") % {
926N/A "cert": self.data, "uri": uri, "days": days }
926N/A return _("Certificate '%(cert)s' will expire in "
926N/A "'%(days)s' days.") % { "cert": self.data, "days": days }
926N/A
926N/A
926N/Aclass InvalidCertificate(CertificateError):
926N/A """Used to indicate that a certificate is invalid."""
926N/A
926N/A def __str__(self):
926N/A publisher = self.args.get("publisher", None)
926N/A uri = self.args.get("uri", None)
926N/A if publisher:
926N/A if uri:
926N/A return _("Certificate '%(cert)s' for publisher "
926N/A "'%(pub)s', needed to access '%(uri)s', is "
926N/A "invalid.") % { "cert": self.data,
926N/A "pub": publisher, "uri": uri }
926N/A return _("Certificate '%(cert)s' for publisher "
926N/A "'%(pub)s' is invalid.") % { "cert": self.data,
926N/A "pub": publisher }
926N/A if uri:
926N/A return _("Certificate '%(cert)s' needed to access "
926N/A "'%(uri)s' is invalid.") % { "cert": self.data,
926N/A "uri": uri }
926N/A return _("Invalid certificate '%s'.") % self.data
926N/A
926N/A
926N/Aclass NoSuchCertificate(CertificateError):
926N/A """Used to indicate that a certificate could not be found."""
926N/A
926N/A def __str__(self):
926N/A publisher = self.args.get("publisher", None)
926N/A uri = self.args.get("uri", None)
926N/A if publisher:
926N/A if uri:
926N/A return _("Unable to locate certificate "
926N/A "'%(cert)s' for publisher '%(pub)s' needed "
926N/A "to access '%(uri)s'.") % {
926N/A "cert": self.data, "pub": publisher,
926N/A "uri": uri }
926N/A return _("Unable to locate certificate '%(cert)s' for "
926N/A "publisher '%(pub)s'.") % { "cert": self.data,
926N/A "pub": publisher }
926N/A if uri:
926N/A return _("Unable to locate certificate '%(cert)s' "
926N/A "needed to access '%(uri)s'.") % {
926N/A "cert": self.data, "uri": uri }
926N/A return _("Unable to locate certificate '%s'.") % self.data
926N/A
926N/A
926N/Aclass NotYetValidCertificate(CertificateError):
926N/A """Used to indicate that a certificate is not yet valid (future
926N/A effective date)."""
926N/A
926N/A def __str__(self):
926N/A publisher = self.args.get("publisher", None)
926N/A uri = self.args.get("uri", None)
926N/A if publisher:
926N/A if uri:
926N/A return _("Certificate '%(cert)s' for publisher "
926N/A "'%(pub)s', needed to access '%(uri)s', "
926N/A "has a future effective date.") % {
926N/A "cert": self.data, "pub": publisher,
926N/A "uri": uri }
926N/A return _("Certificate '%(cert)s' for publisher "
926N/A "'%(pub)s' has a future effective date.") % {
926N/A "cert": self.data, "pub": publisher }
926N/A if uri:
926N/A return _("Certificate '%(cert)s' needed to access "
926N/A "'%(uri)s' has a future effective date.") % {
926N/A "cert": self.data, "uri": uri }
926N/A return _("Certificate '%s' has a future effective date.") % \
926N/A self.data
941N/A
941N/A
941N/Aclass ServerReturnError(ApiException):
1100N/A """This exception is used when the server reutrns a line which the
1100N/A client cannot parse correctly."""
1100N/A
941N/A def __init__(self, line):
941N/A ApiException.__init__(self)
941N/A self.line = line
941N/A
941N/A def __str__(self):
1027N/A return _("Gave a bad response:%s") % self.line