src/modules/client/api_errors.py
author Shawn Walker <shawn.walker@oracle.com>
Tue, 08 Feb 2011 13:04:17 -0800
changeset 2212 9936333985a6
parent 2207 029ca014fced
child 2215 b4355e8c5097
permissions -rw-r--r--
738 "install world" for pkg 17809 get_pkg_list() should filter on all variants set in the image 17822 get_pkg_list() variant filtering for newest versions omits previous acceptable versions
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1516
8c950a3b4171 10485 move pkg(5) to Python 2.6
Rich Burridge <rich.burridge@sun.com>
parents: 1505
diff changeset
     1
#!/usr/bin/python
565
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
     2
#
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
     3
# CDDL HEADER START
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
     4
#
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
     5
# The contents of this file are subject to the terms of the
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
     6
# Common Development and Distribution License (the "License").
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
     7
# You may not use this file except in compliance with the License.
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
     8
#
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
     9
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    10
# or http://www.opensolaris.org/os/licensing.
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    11
# See the License for the specific language governing permissions
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    12
# and limitations under the License.
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    13
#
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    14
# When distributing Covered Code, include this CDDL HEADER in each
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    15
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    16
# If applicable, add the following below this CDDL HEADER, with the
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    17
# fields enclosed by brackets "[]" replaced with your own identifying
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    18
# information: Portions Copyright [yyyy] [name of copyright owner]
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    19
#
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    20
# CDDL HEADER END
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    21
#
926
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
    22
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
    23
#
2197
f0a833446218 13054 solver could emit a directed error message for over-revved incorporated pkgs
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents: 2158
diff changeset
    24
# Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
926
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
    25
#
565
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    26
2026
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
    27
import errno
1050
54c841d1fad9 1770 Invalid "Not owner" error when path is delivered as both directory and symlink
Danek Duvall <danek.duvall@sun.com>
parents: 1027
diff changeset
    28
import os
926
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
    29
import urlparse
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
    30
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
    31
# EmptyI for argument defaults; can't import from misc due to circular
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
    32
# dependency.
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
    33
EmptyI = tuple()
838
aafbe4737188 3245 need to support creation of multi-architecture (fat) packages
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents: 835
diff changeset
    34
565
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    35
class ApiException(Exception):
2034
d5ee7746faeb 16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents: 2028
diff changeset
    36
        def __init__(self, *args):
d5ee7746faeb 16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents: 2028
diff changeset
    37
                Exception.__init__(self)
d5ee7746faeb 16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents: 2028
diff changeset
    38
                self.__verbose_info = []
1540
de040c9fd0c0 13003 exception messages not always displayed correctly with python 2.6
Shawn Walker <srw@sun.com>
parents: 1516
diff changeset
    39
de040c9fd0c0 13003 exception messages not always displayed correctly with python 2.6
Shawn Walker <srw@sun.com>
parents: 1516
diff changeset
    40
        def __unicode__(self):
de040c9fd0c0 13003 exception messages not always displayed correctly with python 2.6
Shawn Walker <srw@sun.com>
parents: 1516
diff changeset
    41
                # To workaround python issues 6108 and 2517, this provides a
de040c9fd0c0 13003 exception messages not always displayed correctly with python 2.6
Shawn Walker <srw@sun.com>
parents: 1516
diff changeset
    42
                # a standard wrapper for this class' exceptions so that they
de040c9fd0c0 13003 exception messages not always displayed correctly with python 2.6
Shawn Walker <srw@sun.com>
parents: 1516
diff changeset
    43
                # have a chance of being stringified correctly.
1968
c0540b1e4f7e 8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents: 1945
diff changeset
    44
                return unicode(str(self))
1540
de040c9fd0c0 13003 exception messages not always displayed correctly with python 2.6
Shawn Walker <srw@sun.com>
parents: 1516
diff changeset
    45
2034
d5ee7746faeb 16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents: 2028
diff changeset
    46
        def add_verbose_info(self, info):
d5ee7746faeb 16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents: 2028
diff changeset
    47
                self.__verbose_info.extend(info)
2200
155eda704b2f 16279 Need a way to revert certain editable files to a as-installed state
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents: 2197
diff changeset
    48
2034
d5ee7746faeb 16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents: 2028
diff changeset
    49
        @property
d5ee7746faeb 16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents: 2028
diff changeset
    50
        def verbose_info(self):
d5ee7746faeb 16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents: 2028
diff changeset
    51
                return self.__verbose_info
565
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    52
1710
139720e2e756 1668 image locking needed to prevent race conditions
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
    53
class ImageLockedError(ApiException):
139720e2e756 1668 image locking needed to prevent race conditions
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
    54
        """Used to indicate that the image is currently locked by another thread
139720e2e756 1668 image locking needed to prevent race conditions
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
    55
        or process and cannot be modified."""
139720e2e756 1668 image locking needed to prevent race conditions
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
    56
139720e2e756 1668 image locking needed to prevent race conditions
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
    57
        def __init__(self, hostname=None, pid=None, pid_name=None):
139720e2e756 1668 image locking needed to prevent race conditions
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
    58
                ApiException.__init__(self)
139720e2e756 1668 image locking needed to prevent race conditions
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
    59
                self.hostname = hostname
139720e2e756 1668 image locking needed to prevent race conditions
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
    60
                self.pid = pid
139720e2e756 1668 image locking needed to prevent race conditions
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
    61
                self.pid_name = pid_name
139720e2e756 1668 image locking needed to prevent race conditions
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
    62
139720e2e756 1668 image locking needed to prevent race conditions
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
    63
        def __str__(self):
139720e2e756 1668 image locking needed to prevent race conditions
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
    64
                if self.pid is not None and self.pid_name is not None and \
139720e2e756 1668 image locking needed to prevent race conditions
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
    65
                    self.hostname is not None:
139720e2e756 1668 image locking needed to prevent race conditions
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
    66
                        return _("The image cannot be modified as it is "
139720e2e756 1668 image locking needed to prevent race conditions
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
    67
                            "currently in use by another package client: "
139720e2e756 1668 image locking needed to prevent race conditions
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
    68
                            "%(pid_name)s on %(host)s, pid %(pid)s.") % {
139720e2e756 1668 image locking needed to prevent race conditions
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
    69
                            "pid_name": self.pid_name, "pid": self.pid,
139720e2e756 1668 image locking needed to prevent race conditions
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
    70
                            "host": self.hostname }
139720e2e756 1668 image locking needed to prevent race conditions
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
    71
                if self.pid is not None and self.pid_name is not None:
139720e2e756 1668 image locking needed to prevent race conditions
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
    72
                        return _("The image cannot be modified as it is "
139720e2e756 1668 image locking needed to prevent race conditions
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
    73
                            "currently in use by another package client: "
139720e2e756 1668 image locking needed to prevent race conditions
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
    74
                            "%(pid_name)s on an unknown host, pid %(pid)s.") % {
139720e2e756 1668 image locking needed to prevent race conditions
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
    75
                            "pid_name": self.pid_name, "pid": self.pid }
139720e2e756 1668 image locking needed to prevent race conditions
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
    76
                elif self.pid is not None:
139720e2e756 1668 image locking needed to prevent race conditions
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
    77
                        return _("The image cannot be modified as it is "
139720e2e756 1668 image locking needed to prevent race conditions
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
    78
                            "currently in use by another package client: "
139720e2e756 1668 image locking needed to prevent race conditions
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
    79
                            "pid %(pid)s on %(host)s.") % {
139720e2e756 1668 image locking needed to prevent race conditions
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
    80
                            "pid": self.pid, "host": self.hostname }
139720e2e756 1668 image locking needed to prevent race conditions
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
    81
                return _("The image cannot be modified as it is currently "
139720e2e756 1668 image locking needed to prevent race conditions
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
    82
                    "in use by another package client.")
139720e2e756 1668 image locking needed to prevent race conditions
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
    83
565
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    84
class ImageNotFoundException(ApiException):
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    85
        """Used when an image was not found"""
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    86
        def __init__(self, user_specified, user_dir, root_dir):
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    87
                ApiException.__init__(self)
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    88
                self.user_specified = user_specified
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    89
                self.user_dir = user_dir
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    90
                self.root_dir = root_dir
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
    91
2144
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2126
diff changeset
    92
2158
5a688b5b92a3 15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents: 2144
diff changeset
    93
class ImageLocationAmbiguous(ApiException):
5a688b5b92a3 15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents: 2144
diff changeset
    94
        """Used to indicate that an image was found at a location other than
5a688b5b92a3 15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents: 2144
diff changeset
    95
        '/' on the Solaris platform when requesting automatic image location
5a688b5b92a3 15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents: 2144
diff changeset
    96
        discovery.  Clients should trap this exception and add their own
5a688b5b92a3 15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents: 2144
diff changeset
    97
        messaging telling the user how to specify an image root explicitly
5a688b5b92a3 15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents: 2144
diff changeset
    98
        for the location."""
5a688b5b92a3 15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents: 2144
diff changeset
    99
5a688b5b92a3 15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents: 2144
diff changeset
   100
        def __init__(self, root, live_root="/"):
5a688b5b92a3 15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents: 2144
diff changeset
   101
                ApiException.__init__(self)
5a688b5b92a3 15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents: 2144
diff changeset
   102
                self.root = root
5a688b5b92a3 15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents: 2144
diff changeset
   103
                self.live_root = live_root
5a688b5b92a3 15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents: 2144
diff changeset
   104
5a688b5b92a3 15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents: 2144
diff changeset
   105
        def __str__(self):
5a688b5b92a3 15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents: 2144
diff changeset
   106
                return _("pkg(5) image found at '%(found)s' instead of "
5a688b5b92a3 15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents: 2144
diff changeset
   107
                    "'%(expected)s'.") % { "found": self.root,
5a688b5b92a3 15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents: 2144
diff changeset
   108
                    "expected": self.live_root }
5a688b5b92a3 15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents: 2144
diff changeset
   109
5a688b5b92a3 15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents: 2144
diff changeset
   110
2144
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2126
diff changeset
   111
class ImageFormatUpdateNeeded(ApiException):
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2126
diff changeset
   112
        """Used to indicate that an image cannot be used until its format is
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2126
diff changeset
   113
        updated."""
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2126
diff changeset
   114
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2126
diff changeset
   115
        def __init__(self, path):
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2126
diff changeset
   116
                ApiException.__init__(self)
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2126
diff changeset
   117
                self.path = path
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2126
diff changeset
   118
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2126
diff changeset
   119
        def __str__(self):
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2126
diff changeset
   120
                return _("The image rooted at %s is written in an older format "
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2126
diff changeset
   121
                    "and must be updated before the requested operation can be "
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2126
diff changeset
   122
                    "performed.") % self.path
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2126
diff changeset
   123
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2126
diff changeset
   124
565
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   125
class VersionException(ApiException):
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   126
        def __init__(self, expected_version, received_version):
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   127
                ApiException.__init__(self)
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   128
                self.expected_version = expected_version
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   129
                self.received_version = received_version
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   130
2144
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2126
diff changeset
   131
565
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   132
class PlanExistsException(ApiException):
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   133
        def __init__(self, plan_type):
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   134
                ApiException.__init__(self)
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   135
                self.plan_type = plan_type
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   136
1618
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   137
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   138
class PlanPrepareException(ApiException):
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   139
        """Base exception class for plan preparation errors."""
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   140
        pass
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   141
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   142
1755
8e1ed1373f93 9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents: 1736
diff changeset
   143
class InvalidPackageErrors(ApiException):
8e1ed1373f93 9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents: 1736
diff changeset
   144
        """Used to indicate that the requested operation could not be completed
8e1ed1373f93 9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents: 1736
diff changeset
   145
        as one or more packages contained invalid metadata."""
8e1ed1373f93 9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents: 1736
diff changeset
   146
8e1ed1373f93 9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents: 1736
diff changeset
   147
        def __init__(self, errors):
8e1ed1373f93 9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents: 1736
diff changeset
   148
                """'errors' should be a list of exceptions or strings
8e1ed1373f93 9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents: 1736
diff changeset
   149
                indicating what packages had errors and why."""
8e1ed1373f93 9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents: 1736
diff changeset
   150
8e1ed1373f93 9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents: 1736
diff changeset
   151
                ApiException.__init__(self)
8e1ed1373f93 9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents: 1736
diff changeset
   152
                self.errors = errors
8e1ed1373f93 9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents: 1736
diff changeset
   153
8e1ed1373f93 9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents: 1736
diff changeset
   154
        def __str__(self):
8e1ed1373f93 9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents: 1736
diff changeset
   155
                return _("The requested operation cannot be completed due "
8e1ed1373f93 9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents: 1736
diff changeset
   156
                    "to invalid package metadata.  Details follow:\n\n"
8e1ed1373f93 9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents: 1736
diff changeset
   157
                    "%s") % "\n".join(str(e) for e in self.errors)
8e1ed1373f93 9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents: 1736
diff changeset
   158
8e1ed1373f93 9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents: 1736
diff changeset
   159
1618
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   160
class LicenseAcceptanceError(ApiException):
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   161
        """Used to indicate that license-related errors occurred during
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   162
        plan evaluation or execution."""
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   163
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   164
        def __init__(self, pfmri, src=None, dest=None, accepted=None,
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   165
            displayed=None):
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   166
                ApiException.__init__(self)
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   167
                self.fmri = pfmri
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   168
                self.src = src
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   169
                self.dest = dest
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   170
                self.accepted = accepted
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   171
                self.displayed = displayed
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   172
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   173
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   174
class PkgLicenseErrors(PlanPrepareException):
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   175
        """Used to indicate that plan evaluation or execution failed due
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   176
        to license-related errors for a package."""
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   177
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   178
        def __init__(self, errors):
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   179
                """'errors' should be a list of LicenseAcceptanceError
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   180
                exceptions."""
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   181
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   182
                PlanPrepareException.__init__(self)
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   183
                self.__errors = errors
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   184
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   185
        @property
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   186
        def errors(self):
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   187
                """A list of LicenseAcceptanceError exceptions."""
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   188
                return self.__errors
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   189
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   190
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   191
class PlanLicenseErrors(PlanPrepareException):
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   192
        """Used to indicate that image plan evaluation or execution failed due
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   193
        to license-related errors."""
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   194
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   195
        def __init__(self, pp_errors):
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   196
                """'errors' should be a list of PkgLicenseErrors exceptions."""
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   197
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   198
                PlanPrepareException.__init__(self)
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   199
                self.__errors = pkgs = {}
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   200
                for pp_err in pp_errors:
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   201
                        for e in pp_err.errors:
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   202
                                pkgs.setdefault(str(e.fmri), []).append(e)
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   203
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   204
        @property
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   205
        def errors(self):
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   206
                """Returns a dictionary indexed by package FMRI string of
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   207
                lists of LicenseAcceptanceError exceptions."""
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   208
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   209
                return self.__errors
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   210
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   211
        def __str__(self):
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   212
                """Returns a string representation of the license errors."""
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   213
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   214
                output = ""
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   215
                for sfmri in self.__errors:
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   216
                        output += ("-" * 40) + "\n"
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   217
                        output += _("Package: %s\n\n") % sfmri
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   218
                        for e in self.__errors[sfmri]:
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   219
                                lic_name = e.dest.attrs["license"]
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   220
                                output += _("License: %s\n") % lic_name
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   221
                                if e.dest.must_accept and not e.accepted:
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   222
                                        output += _("  License requires "
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   223
                                            "acceptance.")
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   224
                                if e.dest.must_display and not e.displayed:
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   225
                                        output += _("  License must be viewed.")
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   226
                                output += "\n"
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   227
                return output
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   228
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   229
1019
e61c57c724c9 7663 disable_fmri should be synchronous
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents: 996
diff changeset
   230
class ActuatorException(ApiException):
e61c57c724c9 7663 disable_fmri should be synchronous
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents: 996
diff changeset
   231
        def __init__(self, e):
e61c57c724c9 7663 disable_fmri should be synchronous
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents: 996
diff changeset
   232
                ApiException.__init__(self)
e61c57c724c9 7663 disable_fmri should be synchronous
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents: 996
diff changeset
   233
                self.exception = e
e61c57c724c9 7663 disable_fmri should be synchronous
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents: 996
diff changeset
   234
e61c57c724c9 7663 disable_fmri should be synchronous
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents: 996
diff changeset
   235
        def __str__(self):
e61c57c724c9 7663 disable_fmri should be synchronous
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents: 996
diff changeset
   236
                return str(self.exception)
e61c57c724c9 7663 disable_fmri should be synchronous
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents: 996
diff changeset
   237
1618
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   238
565
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   239
class PrematureExecutionException(ApiException):
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   240
        pass
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   241
1618
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   242
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   243
class AlreadyPreparedException(PlanPrepareException):
565
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   244
        pass
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   245
1618
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   246
565
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   247
class AlreadyExecutedException(ApiException):
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   248
        pass
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   249
1618
04f7471c9e72 5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents: 1603
diff changeset
   250
565
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   251
class ImageplanStateException(ApiException):
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   252
        def __init__(self, state):
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   253
                ApiException.__init__(self)
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   254
                self.state = state
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   255
1369
e86145680c34 11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents: 1352
diff changeset
   256
1710
139720e2e756 1668 image locking needed to prevent race conditions
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   257
class InvalidPlanError(ApiException):
139720e2e756 1668 image locking needed to prevent race conditions
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   258
        """Used to indicate that the image plan is no longer valid, likely as a
139720e2e756 1668 image locking needed to prevent race conditions
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   259
        result of an image state change since the plan was created."""
139720e2e756 1668 image locking needed to prevent race conditions
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   260
139720e2e756 1668 image locking needed to prevent race conditions
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   261
        def __str__(self):
139720e2e756 1668 image locking needed to prevent race conditions
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   262
                return _("The plan for the current operation is no longer "
139720e2e756 1668 image locking needed to prevent race conditions
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   263
                    "valid.  The image has likely been modified by another "
139720e2e756 1668 image locking needed to prevent race conditions
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   264
                    "process or client.  Please try the operation again.")
139720e2e756 1668 image locking needed to prevent race conditions
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   265
139720e2e756 1668 image locking needed to prevent race conditions
Shawn Walker <srw@sun.com>
parents: 1618
diff changeset
   266
1372
484408dfa0a1 11483 ImagePkgStateError needs correction
Shawn Walker <srw@sun.com>
parents: 1370
diff changeset
   267
class ImagePkgStateError(ApiException):
1369
e86145680c34 11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents: 1352
diff changeset
   268
e86145680c34 11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents: 1352
diff changeset
   269
        def __init__(self, fmri, states):
e86145680c34 11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents: 1352
diff changeset
   270
                ApiException.__init__(self)
e86145680c34 11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents: 1352
diff changeset
   271
                self.fmri = fmri
e86145680c34 11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents: 1352
diff changeset
   272
                self.states = states
e86145680c34 11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents: 1352
diff changeset
   273
e86145680c34 11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents: 1352
diff changeset
   274
        def __str__(self):
e86145680c34 11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents: 1352
diff changeset
   275
                return _("Invalid package state change attempted '%(states)s' "
1372
484408dfa0a1 11483 ImagePkgStateError needs correction
Shawn Walker <srw@sun.com>
parents: 1370
diff changeset
   276
                    "for package '%(fmri)s'.") % { "states": self.states,
484408dfa0a1 11483 ImagePkgStateError needs correction
Shawn Walker <srw@sun.com>
parents: 1370
diff changeset
   277
                    "fmri": self.fmri }
1369
e86145680c34 11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents: 1352
diff changeset
   278
e86145680c34 11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents: 1352
diff changeset
   279
565
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   280
class IpkgOutOfDateException(ApiException):
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   281
        pass
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   282
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   283
class ImageUpdateOnLiveImageException(ApiException):
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   284
        pass
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   285
1328
5c3747a4fe0a 9387 pkg fix should honor reboot-needed flag
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents: 1286
diff changeset
   286
class RebootNeededOnLiveImageException(ApiException):
5c3747a4fe0a 9387 pkg fix should honor reboot-needed flag
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents: 1286
diff changeset
   287
        pass
5c3747a4fe0a 9387 pkg fix should honor reboot-needed flag
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents: 1286
diff changeset
   288
565
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   289
class CanceledException(ApiException):
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   290
        pass
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   291
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   292
class PlanMissingException(ApiException):
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   293
        pass
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   294
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   295
class NoPackagesInstalledException(ApiException):
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   296
        pass
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   297
685
6f53483db920 1469 image-update by unprivileged user should give better error message
Brock Pytlik <bpytlik@sun.com>
parents: 655
diff changeset
   298
class PermissionsException(ApiException):
6f53483db920 1469 image-update by unprivileged user should give better error message
Brock Pytlik <bpytlik@sun.com>
parents: 655
diff changeset
   299
        def __init__(self, path):
6f53483db920 1469 image-update by unprivileged user should give better error message
Brock Pytlik <bpytlik@sun.com>
parents: 655
diff changeset
   300
                ApiException.__init__(self)
6f53483db920 1469 image-update by unprivileged user should give better error message
Brock Pytlik <bpytlik@sun.com>
parents: 655
diff changeset
   301
                self.path = path
6f53483db920 1469 image-update by unprivileged user should give better error message
Brock Pytlik <bpytlik@sun.com>
parents: 655
diff changeset
   302
6f53483db920 1469 image-update by unprivileged user should give better error message
Brock Pytlik <bpytlik@sun.com>
parents: 655
diff changeset
   303
        def __str__(self):
6f53483db920 1469 image-update by unprivileged user should give better error message
Brock Pytlik <bpytlik@sun.com>
parents: 655
diff changeset
   304
                if self.path:
926
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
   305
                        return _("Could not operate on %s\nbecause of "
2126
7f6719cd083b 14316 please suggest the proper classification and product in the pkg error message
Shawn Walker <shawn.walker@oracle.com>
parents: 2100
diff changeset
   306
                            "insufficient permissions. Please try the "
7f6719cd083b 14316 please suggest the proper classification and product in the pkg error message
Shawn Walker <shawn.walker@oracle.com>
parents: 2100
diff changeset
   307
                            "command again as a privileged user.") % \
7f6719cd083b 14316 please suggest the proper classification and product in the pkg error message
Shawn Walker <shawn.walker@oracle.com>
parents: 2100
diff changeset
   308
                            self.path
685
6f53483db920 1469 image-update by unprivileged user should give better error message
Brock Pytlik <bpytlik@sun.com>
parents: 655
diff changeset
   309
                else:
6f53483db920 1469 image-update by unprivileged user should give better error message
Brock Pytlik <bpytlik@sun.com>
parents: 655
diff changeset
   310
                        return _("""
2126
7f6719cd083b 14316 please suggest the proper classification and product in the pkg error message
Shawn Walker <shawn.walker@oracle.com>
parents: 2100
diff changeset
   311
Could not complete the operation because of insufficient permissions.
7f6719cd083b 14316 please suggest the proper classification and product in the pkg error message
Shawn Walker <shawn.walker@oracle.com>
parents: 2100
diff changeset
   312
Please try the command again as a privileged user.
685
6f53483db920 1469 image-update by unprivileged user should give better error message
Brock Pytlik <bpytlik@sun.com>
parents: 655
diff changeset
   313
""")
6f53483db920 1469 image-update by unprivileged user should give better error message
Brock Pytlik <bpytlik@sun.com>
parents: 655
diff changeset
   314
879
3e4622a4c074 2747 make per-package progress output work on Windows
Tom Mueller <Tom.Mueller@sun.com>
parents: 838
diff changeset
   315
class FileInUseException(PermissionsException):
3e4622a4c074 2747 make per-package progress output work on Windows
Tom Mueller <Tom.Mueller@sun.com>
parents: 838
diff changeset
   316
        def __init__(self, path):
3e4622a4c074 2747 make per-package progress output work on Windows
Tom Mueller <Tom.Mueller@sun.com>
parents: 838
diff changeset
   317
                PermissionsException.__init__(self, path)
3e4622a4c074 2747 make per-package progress output work on Windows
Tom Mueller <Tom.Mueller@sun.com>
parents: 838
diff changeset
   318
                assert path
3e4622a4c074 2747 make per-package progress output work on Windows
Tom Mueller <Tom.Mueller@sun.com>
parents: 838
diff changeset
   319
3e4622a4c074 2747 make per-package progress output work on Windows
Tom Mueller <Tom.Mueller@sun.com>
parents: 838
diff changeset
   320
        def __str__(self):
3e4622a4c074 2747 make per-package progress output work on Windows
Tom Mueller <Tom.Mueller@sun.com>
parents: 838
diff changeset
   321
                return _("Could not operate on %s\nbecause the file is "
3e4622a4c074 2747 make per-package progress output work on Windows
Tom Mueller <Tom.Mueller@sun.com>
parents: 838
diff changeset
   322
                    "in use. Please stop using the file and try the\n"
3e4622a4c074 2747 make per-package progress output work on Windows
Tom Mueller <Tom.Mueller@sun.com>
parents: 838
diff changeset
   323
                    "operation again.") % self.path
3e4622a4c074 2747 make per-package progress output work on Windows
Tom Mueller <Tom.Mueller@sun.com>
parents: 838
diff changeset
   324
1335
3dde2385d05c 516 Clean up traceback for installs to read-only filesystems
John Sonnenschein <John.Sonnenschein@Sun.COM>
parents: 1328
diff changeset
   325
3dde2385d05c 516 Clean up traceback for installs to read-only filesystems
John Sonnenschein <John.Sonnenschein@Sun.COM>
parents: 1328
diff changeset
   326
class ReadOnlyFileSystemException(PermissionsException):
1945
a4fc142accb2 16111 pkgdepend expands format strings before passing through gettext
Richard Lowe <richlowe@richlowe.net>
parents: 1937
diff changeset
   327
        """Used to indicate that the operation was attempted on a
1335
3dde2385d05c 516 Clean up traceback for installs to read-only filesystems
John Sonnenschein <John.Sonnenschein@Sun.COM>
parents: 1328
diff changeset
   328
        read-only filesystem"""
3dde2385d05c 516 Clean up traceback for installs to read-only filesystems
John Sonnenschein <John.Sonnenschein@Sun.COM>
parents: 1328
diff changeset
   329
3dde2385d05c 516 Clean up traceback for installs to read-only filesystems
John Sonnenschein <John.Sonnenschein@Sun.COM>
parents: 1328
diff changeset
   330
        def __init__(self, path):
3dde2385d05c 516 Clean up traceback for installs to read-only filesystems
John Sonnenschein <John.Sonnenschein@Sun.COM>
parents: 1328
diff changeset
   331
                ApiException.__init__(self)
3dde2385d05c 516 Clean up traceback for installs to read-only filesystems
John Sonnenschein <John.Sonnenschein@Sun.COM>
parents: 1328
diff changeset
   332
                self.path = path
3dde2385d05c 516 Clean up traceback for installs to read-only filesystems
John Sonnenschein <John.Sonnenschein@Sun.COM>
parents: 1328
diff changeset
   333
3dde2385d05c 516 Clean up traceback for installs to read-only filesystems
John Sonnenschein <John.Sonnenschein@Sun.COM>
parents: 1328
diff changeset
   334
        def __str__(self):
3dde2385d05c 516 Clean up traceback for installs to read-only filesystems
John Sonnenschein <John.Sonnenschein@Sun.COM>
parents: 1328
diff changeset
   335
                if self.path:
3dde2385d05c 516 Clean up traceback for installs to read-only filesystems
John Sonnenschein <John.Sonnenschein@Sun.COM>
parents: 1328
diff changeset
   336
                        return _("Could not complete the operation on %s: "
1968
c0540b1e4f7e 8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents: 1945
diff changeset
   337
                            "read-only filesystem.") % self.path
1335
3dde2385d05c 516 Clean up traceback for installs to read-only filesystems
John Sonnenschein <John.Sonnenschein@Sun.COM>
parents: 1328
diff changeset
   338
                return _("Could not complete the operation: read-only "
3dde2385d05c 516 Clean up traceback for installs to read-only filesystems
John Sonnenschein <John.Sonnenschein@Sun.COM>
parents: 1328
diff changeset
   339
                        "filesystem.")
3dde2385d05c 516 Clean up traceback for installs to read-only filesystems
John Sonnenschein <John.Sonnenschein@Sun.COM>
parents: 1328
diff changeset
   340
3dde2385d05c 516 Clean up traceback for installs to read-only filesystems
John Sonnenschein <John.Sonnenschein@Sun.COM>
parents: 1328
diff changeset
   341
565
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   342
class PlanCreationException(ApiException):
1141
a74d6815a7fc 4178 unfound_fmris is a poor name
Rich Burridge <rich.burridge@sun.com>
parents: 1130
diff changeset
   343
        def __init__(self, unmatched_fmris=EmptyI, multiple_matches=EmptyI,
926
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
   344
            missing_matches=EmptyI, illegal=EmptyI,
1945
a4fc142accb2 16111 pkgdepend expands format strings before passing through gettext
Richard Lowe <richlowe@richlowe.net>
parents: 1937
diff changeset
   345
            badarch=EmptyI, installed=EmptyI, multispec=EmptyI,
a4fc142accb2 16111 pkgdepend expands format strings before passing through gettext
Richard Lowe <richlowe@richlowe.net>
parents: 1937
diff changeset
   346
            no_solution=False, no_version=EmptyI, missing_dependency=EmptyI,
2207
029ca014fced 17797 plan debugging should also display solver trim database
Shawn Walker <shawn.walker@oracle.com>
parents: 2205
diff changeset
   347
            wrong_publishers=EmptyI, obsolete=EmptyI, nofiles=EmptyI,
2212
9936333985a6 738 "install world" for pkg
Shawn Walker <shawn.walker@oracle.com>
parents: 2207
diff changeset
   348
            solver_errors=EmptyI, wrong_variants=EmptyI):
565
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   349
                ApiException.__init__(self)
1505
cc598d70bbbe 4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents: 1504
diff changeset
   350
                self.unmatched_fmris       = unmatched_fmris
cc598d70bbbe 4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents: 1504
diff changeset
   351
                self.multiple_matches      = multiple_matches
cc598d70bbbe 4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents: 1504
diff changeset
   352
                self.missing_matches       = missing_matches
cc598d70bbbe 4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents: 1504
diff changeset
   353
                self.illegal               = illegal
cc598d70bbbe 4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents: 1504
diff changeset
   354
                self.badarch               = badarch
cc598d70bbbe 4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents: 1504
diff changeset
   355
                self.installed             = installed
cc598d70bbbe 4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents: 1504
diff changeset
   356
                self.multispec             = multispec
2207
029ca014fced 17797 plan debugging should also display solver trim database
Shawn Walker <shawn.walker@oracle.com>
parents: 2205
diff changeset
   357
                self.obsolete              = obsolete
1505
cc598d70bbbe 4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents: 1504
diff changeset
   358
                self.no_solution           = no_solution
cc598d70bbbe 4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents: 1504
diff changeset
   359
                self.no_version            = no_version
cc598d70bbbe 4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents: 1504
diff changeset
   360
                self.missing_dependency    = missing_dependency
cc598d70bbbe 4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents: 1504
diff changeset
   361
                self.wrong_publishers      = wrong_publishers
2212
9936333985a6 738 "install world" for pkg
Shawn Walker <shawn.walker@oracle.com>
parents: 2207
diff changeset
   362
                self.wrong_variants        = wrong_variants
2200
155eda704b2f 16279 Need a way to revert certain editable files to a as-installed state
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents: 2197
diff changeset
   363
                self.nofiles               = nofiles
2207
029ca014fced 17797 plan debugging should also display solver trim database
Shawn Walker <shawn.walker@oracle.com>
parents: 2205
diff changeset
   364
                self.solver_errors         = solver_errors
838
aafbe4737188 3245 need to support creation of multi-architecture (fat) packages
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents: 835
diff changeset
   365
565
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   366
        def __str__(self):
616
6d307b088d92 4056 make_uninstall_plan misreports trying to uninstall a known, but uninstalled package
Brock Pytlik <bpytlik@sun.com>
parents: 614
diff changeset
   367
                res = []
1141
a74d6815a7fc 4178 unfound_fmris is a poor name
Rich Burridge <rich.burridge@sun.com>
parents: 1130
diff changeset
   368
                if self.unmatched_fmris:
616
6d307b088d92 4056 make_uninstall_plan misreports trying to uninstall a known, but uninstalled package
Brock Pytlik <bpytlik@sun.com>
parents: 614
diff changeset
   369
                        s = _("""\
988
a851ba83a5aa 6654 pkg list state incorrect after publisher removal when another publisher has it
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 941
diff changeset
   370
The following pattern(s) did not match any packages in the current catalog.
a851ba83a5aa 6654 pkg list state incorrect after publisher removal when another publisher has it
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 941
diff changeset
   371
Try relaxing the pattern, refreshing and/or examining the catalogs:""")
926
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
   372
                        res += [s]
1141
a74d6815a7fc 4178 unfound_fmris is a poor name
Rich Burridge <rich.burridge@sun.com>
parents: 1130
diff changeset
   373
                        res += ["\t%s" % p for p in self.unmatched_fmris]
565
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   374
2212
9936333985a6 738 "install world" for pkg
Shawn Walker <shawn.walker@oracle.com>
parents: 2207
diff changeset
   375
                if self.wrong_variants:
9936333985a6 738 "install world" for pkg
Shawn Walker <shawn.walker@oracle.com>
parents: 2207
diff changeset
   376
                        s = _("""\
9936333985a6 738 "install world" for pkg
Shawn Walker <shawn.walker@oracle.com>
parents: 2207
diff changeset
   377
The following pattern(s) only matched packages that are not available
9936333985a6 738 "install world" for pkg
Shawn Walker <shawn.walker@oracle.com>
parents: 2207
diff changeset
   378
for the current image's architecture, zone type, and/or other variant:""")
9936333985a6 738 "install world" for pkg
Shawn Walker <shawn.walker@oracle.com>
parents: 2207
diff changeset
   379
                        res += [s]
9936333985a6 738 "install world" for pkg
Shawn Walker <shawn.walker@oracle.com>
parents: 2207
diff changeset
   380
                        res += ["\t%s" % p for p in self.wrong_variants]
9936333985a6 738 "install world" for pkg
Shawn Walker <shawn.walker@oracle.com>
parents: 2207
diff changeset
   381
1505
cc598d70bbbe 4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents: 1504
diff changeset
   382
                if self.wrong_publishers:
cc598d70bbbe 4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents: 1504
diff changeset
   383
                        s = _("The following patterns only matched packages "
cc598d70bbbe 4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents: 1504
diff changeset
   384
                            "that are from publishers other than that which "
cc598d70bbbe 4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents: 1504
diff changeset
   385
                            "supplied the already installed version of this package")
cc598d70bbbe 4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents: 1504
diff changeset
   386
                        res += [s]
cc598d70bbbe 4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents: 1504
diff changeset
   387
                        res += ["\t%s: %s" % (p[0], ", ".join(p[1])) for p in self.wrong_publishers]
cc598d70bbbe 4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents: 1504
diff changeset
   388
565
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   389
                if self.multiple_matches:
988
a851ba83a5aa 6654 pkg list state incorrect after publisher removal when another publisher has it
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 941
diff changeset
   390
                        s = _("'%s' matches multiple packages")
565
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   391
                        for p, lst in self.multiple_matches:
922
0074b10d84e0 6874 stack trace on install with ambiguous package names
Danek Duvall <danek.duvall@sun.com>
parents: 917
diff changeset
   392
                                res.append(s % p)
0074b10d84e0 6874 stack trace on install with ambiguous package names
Danek Duvall <danek.duvall@sun.com>
parents: 917
diff changeset
   393
                                for pfmri in lst:
633
12f974919ab3 4204 Traceback when attempting to uninstall a package that I have multiples of
Brock Pytlik <bpytlik@sun.com>
parents: 616
diff changeset
   394
                                        res.append("\t%s" % pfmri)
616
6d307b088d92 4056 make_uninstall_plan misreports trying to uninstall a known, but uninstalled package
Brock Pytlik <bpytlik@sun.com>
parents: 614
diff changeset
   395
1505
cc598d70bbbe 4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents: 1504
diff changeset
   396
                if self.missing_matches:
cc598d70bbbe 4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents: 1504
diff changeset
   397
                        s = _("'%s' matches no installed packages")
cc598d70bbbe 4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents: 1504
diff changeset
   398
                        res += [ s % p for p in self.missing_matches ]
616
6d307b088d92 4056 make_uninstall_plan misreports trying to uninstall a known, but uninstalled package
Brock Pytlik <bpytlik@sun.com>
parents: 614
diff changeset
   399
1505
cc598d70bbbe 4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents: 1504
diff changeset
   400
                if self.illegal:
cc598d70bbbe 4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents: 1504
diff changeset
   401
                        s = _("'%s' is an illegal fmri")
cc598d70bbbe 4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents: 1504
diff changeset
   402
                        res += [ s % p for p in self.illegal ]
655
6eef82185057 2325 optional dependency enforcement can't handle fmris disappearing from the catalog
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents: 633
diff changeset
   403
838
aafbe4737188 3245 need to support creation of multi-architecture (fat) packages
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents: 835
diff changeset
   404
                if self.badarch:
aafbe4737188 3245 need to support creation of multi-architecture (fat) packages
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents: 835
diff changeset
   405
                        s = _("'%s' supports the following architectures: %s")
aafbe4737188 3245 need to support creation of multi-architecture (fat) packages
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents: 835
diff changeset
   406
                        a = _("Image architecture is defined as: %s")
1027
e827313523d8 7774 image history discarded when bootenv operations fail or succeed
Shawn Walker <srw@sun.com>
parents: 1019
diff changeset
   407
                        res += [ s % (self.badarch[0],
838
aafbe4737188 3245 need to support creation of multi-architecture (fat) packages
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents: 835
diff changeset
   408
                            ", ".join(self.badarch[1]))]
aafbe4737188 3245 need to support creation of multi-architecture (fat) packages
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents: 835
diff changeset
   409
                        res += [ a % (self.badarch[2])]
aafbe4737188 3245 need to support creation of multi-architecture (fat) packages
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents: 835
diff changeset
   410
1461
fdf40c8c6765 820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents: 1431
diff changeset
   411
                s = _("'%(p)s' depends on obsolete package '%(op)s'")
fdf40c8c6765 820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents: 1431
diff changeset
   412
                res += [ s % {"p": p, "op": op} for p, op in self.obsolete ]
fdf40c8c6765 820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents: 1431
diff changeset
   413
1352
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   414
                if self.installed:
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   415
                        s = _("The proposed operation can not be performed for "
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   416
                            "the following package(s) as they are already "
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   417
                            "installed: ")
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   418
                        res += [s]
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   419
                        res += ["\t%s" % p for p in self.installed]
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   420
1505
cc598d70bbbe 4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents: 1504
diff changeset
   421
                if self.multispec:
cc598d70bbbe 4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents: 1504
diff changeset
   422
                        s = _("The following different patterns specify the"
cc598d70bbbe 4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents: 1504
diff changeset
   423
                              "same package(s):")
cc598d70bbbe 4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents: 1504
diff changeset
   424
                        res += [s]
cc598d70bbbe 4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents: 1504
diff changeset
   425
                        for t in self.multispec:
cc598d70bbbe 4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents: 1504
diff changeset
   426
                                res += [
cc598d70bbbe 4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents: 1504
diff changeset
   427
                                        ", ".join(
cc598d70bbbe 4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents: 1504
diff changeset
   428
                                        [t[i] for i in range(1, len(t))])
cc598d70bbbe 4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents: 1504
diff changeset
   429
                                        + ": %s" % t[0]
1945
a4fc142accb2 16111 pkgdepend expands format strings before passing through gettext
Richard Lowe <richlowe@richlowe.net>
parents: 1937
diff changeset
   430
                                        ]
1505
cc598d70bbbe 4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents: 1504
diff changeset
   431
                if self.no_solution:
cc598d70bbbe 4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents: 1504
diff changeset
   432
                        res += [_("No solution was found to satisfy constraints")]
2197
f0a833446218 13054 solver could emit a directed error message for over-revved incorporated pkgs
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents: 2158
diff changeset
   433
                        if isinstance(self.no_solution, list):
f0a833446218 13054 solver could emit a directed error message for over-revved incorporated pkgs
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents: 2158
diff changeset
   434
                                res.extend(self.no_solution)
2207
029ca014fced 17797 plan debugging should also display solver trim database
Shawn Walker <shawn.walker@oracle.com>
parents: 2205
diff changeset
   435
1505
cc598d70bbbe 4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents: 1504
diff changeset
   436
                if self.no_version:
cc598d70bbbe 4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents: 1504
diff changeset
   437
                        res += self.no_version
cc598d70bbbe 4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents: 1504
diff changeset
   438
cc598d70bbbe 4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents: 1504
diff changeset
   439
                if self.missing_dependency:
1945
a4fc142accb2 16111 pkgdepend expands format strings before passing through gettext
Richard Lowe <richlowe@richlowe.net>
parents: 1937
diff changeset
   440
                        res += [_("Package %(pkg)s is missing a dependency: "
a4fc142accb2 16111 pkgdepend expands format strings before passing through gettext
Richard Lowe <richlowe@richlowe.net>
parents: 1937
diff changeset
   441
                            "%(dep)s") %
a4fc142accb2 16111 pkgdepend expands format strings before passing through gettext
Richard Lowe <richlowe@richlowe.net>
parents: 1937
diff changeset
   442
                            {"pkg": self.missing_dependency[0],
a4fc142accb2 16111 pkgdepend expands format strings before passing through gettext
Richard Lowe <richlowe@richlowe.net>
parents: 1937
diff changeset
   443
                             "dep": self.missing_dependency[1]}]
2200
155eda704b2f 16279 Need a way to revert certain editable files to a as-installed state
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents: 2197
diff changeset
   444
                if self.nofiles:
155eda704b2f 16279 Need a way to revert certain editable files to a as-installed state
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents: 2197
diff changeset
   445
                        res += [_("The following files are not packaged in this image:")]
155eda704b2f 16279 Need a way to revert certain editable files to a as-installed state
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents: 2197
diff changeset
   446
                        res += ["\t%s" % f for f in self.nofiles]
1945
a4fc142accb2 16111 pkgdepend expands format strings before passing through gettext
Richard Lowe <richlowe@richlowe.net>
parents: 1937
diff changeset
   447
2207
029ca014fced 17797 plan debugging should also display solver trim database
Shawn Walker <shawn.walker@oracle.com>
parents: 2205
diff changeset
   448
                if self.solver_errors:
029ca014fced 17797 plan debugging should also display solver trim database
Shawn Walker <shawn.walker@oracle.com>
parents: 2205
diff changeset
   449
                        res += ["\n"]
029ca014fced 17797 plan debugging should also display solver trim database
Shawn Walker <shawn.walker@oracle.com>
parents: 2205
diff changeset
   450
                        res += [_("Solver dependency errors:")]
029ca014fced 17797 plan debugging should also display solver trim database
Shawn Walker <shawn.walker@oracle.com>
parents: 2205
diff changeset
   451
                        res.extend(self.solver_errors)
029ca014fced 17797 plan debugging should also display solver trim database
Shawn Walker <shawn.walker@oracle.com>
parents: 2205
diff changeset
   452
1352
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   453
                return "\n".join(res)
565
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   454
2205
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   455
class ConflictingActionError(ApiException):
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   456
        """Used to indicate that the imageplan would result in one or more sets
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   457
        of conflicting actions, meaning that more than one action would exist on
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   458
        the system with the same key attribute value in the same namespace.
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   459
        There are three categories, each with its own subclass:
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   460
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   461
          - multiple files delivered to the same path or drivers, users, groups,
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   462
            etc, delivered with the same key attribute;
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   463
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   464
          - multiple objects delivered to the same path which aren't the same
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   465
            type;
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   466
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   467
          - multiple directories, links, or hardlinks delivered to the same path
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   468
            but with conflicting attributes.
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   469
        """
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   470
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   471
        def __init__(self, data):
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   472
                self._data = data
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   473
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   474
class ConflictingActionErrors(ApiException):
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   475
        """A container for multiple ConflictingActionError exception objects
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   476
        that can be raised as a single exception."""
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   477
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   478
        def __init__(self, errors):
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   479
                self.__errors = errors
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   480
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   481
        def __str__(self):
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   482
                return "\n\n".join((str(err) for err in self.__errors))
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   483
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   484
class DuplicateActionError(ConflictingActionError):
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   485
        """Multiple actions of the same type have been delivered with the same
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   486
        key attribute (when not allowed)."""
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   487
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   488
        def __str__(self):
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   489
                pfmris = set((a[1] for a in self._data))
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   490
                kv = self._data[0][0].attrs[self._data[0][0].key_attr]
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   491
                action = self._data[0][0].name
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   492
                if len(pfmris) > 1:
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   493
                        s = _("The following packages all deliver %(action)s "
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   494
                            "actions to %(kv)s:\n") % locals()
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   495
                        for a, p in self._data:
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   496
                                s += "\n  %s" % p
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   497
                        s += _("\n\nThese packages may not be installed together. "
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   498
                            "Any non-conflicting set may\nbe, or the packages "
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   499
                            "must be corrected before they can be installed.")
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   500
                else:
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   501
                        pfmri = pfmris.pop()
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   502
                        s = _("The package %(pfmri)s delivers multiple copies "
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   503
                            "of %(action)s %(kv)s") % locals()
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   504
                        s += _("\nThis package must be corrected before it "
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   505
                            "can be installed.")
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   506
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   507
                return s
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   508
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   509
class InconsistentActionTypeError(ConflictingActionError):
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   510
        """Multiple actions of different types have been delivered with the same
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   511
        'path' attribute.  While this exception could represent other action
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   512
        groups which share a single namespace, none such exist."""
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   513
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   514
        def __str__(self):
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   515
                ad = {}
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   516
                pfmris = set()
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   517
                kv = self._data[0][0].attrs[self._data[0][0].key_attr]
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   518
                for a, p in self._data:
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   519
                        ad.setdefault(a.name, []).append(p)
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   520
                        pfmris.add(p)
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   521
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   522
                if len(pfmris) > 1:
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   523
                        s = _("The following packages deliver conflicting "
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   524
                            "action types to %s:\n") % kv
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   525
                        for name, pl in ad.iteritems():
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   526
                                s += "\n  %s:" % name
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   527
                                s += "".join("\n    %s" % p for p in pl)
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   528
                        s += _("\n\nThese packages may not be installed together. "
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   529
                            "Any non-conflicting set may\nbe, or the packages "
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   530
                            "must be corrected before they can be installed.")
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   531
                else:
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   532
                        pfmri = pfmris.pop()
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   533
                        types = list_to_lang(ad.keys())
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   534
                        s = _("The package %(pfmri)s delivers conflicting "
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   535
                            "action types (%(types)s) to %(kv)s") % locals()
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   536
                        s += _("\nThis package must be corrected before it "
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   537
                            "can be installed.")
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   538
                return s
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   539
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   540
class InconsistentActionAttributeError(ConflictingActionError):
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   541
        """Multiple actions of the same type representing the same object have
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   542
        have been delivered, but with conflicting attributes, such as two
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   543
        directories at /usr with groups 'root' and 'sys', or two 'root' users
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   544
        with uids '0' and '7'."""
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   545
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   546
        def __str__(self):
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   547
                actions = self._data
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   548
                keyattr = actions[0][0].attrs[actions[0][0].key_attr]
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   549
                actname = actions[0][0].name
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   550
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   551
                # Trim the action's attributes to only those required to be
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   552
                # unique.
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   553
                def ou(action):
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   554
                        ua = dict(
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   555
                            (k, v)
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   556
                            for k, v in action.attrs.iteritems()
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   557
                            if k in action.unique_attrs
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   558
                        )
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   559
                        action.attrs = ua
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   560
                        return action
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   561
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   562
                d = {}
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   563
                for a in actions:
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   564
                        d.setdefault(str(ou(a[0])), set()).add(a[1])
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   565
                l = sorted([
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   566
                    (len(pkglist), action, pkglist)
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   567
                    for action, pkglist in d.iteritems()
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   568
                ])
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   569
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   570
                s = _("The requested change to the system attempts to install "
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   571
                    "multiple actions\nfor %(a)s '%(k)s' with conflicting "
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   572
                    "attributes:\n\n") % {"a": actname, "k": keyattr}
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   573
                allpkgs = set()
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   574
                for num, action, pkglist in l:
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   575
                        allpkgs.update(pkglist)
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   576
                        if num <= 5:
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   577
                                if num == 1:
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   578
                                        t = _("    %(n)d package delivers '%(a)s':\n")
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   579
                                else:
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   580
                                        t = _("    %(n)d packages deliver '%(a)s':\n")
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   581
                                s += t % {"n": num, "a": action}
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   582
                                for pkg in sorted(pkglist):
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   583
                                        s += _("        %s\n") % pkg
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   584
                        else:
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   585
                                t = _("    %d packages deliver '%s', including:\n")
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   586
                                s += t % (num, action)
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   587
                                for pkg in sorted(pkglist)[:5]:
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   588
                                        s += _("        %s\n") % pkg
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   589
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   590
                if len(allpkgs) == 1:
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   591
                        s += _("\n\nThis package must be corrected before it "
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   592
                            "can be installed.")
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   593
                else:
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   594
                        s += _("\n\nThese packages may not be installed together."
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   595
                            "  Any non-conflicting set may\nbe, or the packages "
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   596
                            "must be corrected before they can be installed.")
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   597
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   598
                return s
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   599
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   600
def list_to_lang(l):
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   601
        """Takes a list of items and puts them into a string, with commas in
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   602
        between items, and an "and" between the last two items.  Special cases
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   603
        for lists of two or fewer items, and uses the Oxford comma."""
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   604
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   605
        if not l:
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   606
                return ""
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   607
        if len(l) == 1:
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   608
                return l[0]
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   609
        if len(l) == 2:
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   610
                # Used for a two-element list
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   611
                return _("%(penultimate)s and %(ultimate)s") % {
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   612
                    "penultimate": l[0],
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   613
                    "ultimate": l[1]
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   614
                }
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   615
        # In order to properly i18n this construct, we create two templates:
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   616
        # one for each element save the last, and one that tacks on the last
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   617
        # element.
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   618
        # 'elementtemplate' is for each element through the penultimate
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   619
        elementtemplate = _("%s, ")
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   620
        # 'listtemplate' concatenates the concatenation of non-ultimate elements
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   621
        # and the ultimate element.
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   622
        listtemplate = _("%(list)sand %(tail)s")
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   623
        return listtemplate % {
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   624
            "list": "".join(elementtemplate % i for i in l[:-1]),
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   625
            "tail": l[-1]
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
   626
        }
1068
9400aa8afd32 2557 catalog cache pickle file dependent on fmri and version object definitions
Shawn Walker <srw@sun.com>
parents: 1053
diff changeset
   627
1050
54c841d1fad9 1770 Invalid "Not owner" error when path is delivered as both directory and symlink
Danek Duvall <danek.duvall@sun.com>
parents: 1027
diff changeset
   628
class ActionExecutionError(ApiException):
1859
6e6e866921e7 529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents: 1755
diff changeset
   629
        """Used to indicate that action execution (such as install, remove,
6e6e866921e7 529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents: 1755
diff changeset
   630
        etc.) failed even though the action is valid.
1050
54c841d1fad9 1770 Invalid "Not owner" error when path is delivered as both directory and symlink
Danek Duvall <danek.duvall@sun.com>
parents: 1027
diff changeset
   631
54c841d1fad9 1770 Invalid "Not owner" error when path is delivered as both directory and symlink
Danek Duvall <danek.duvall@sun.com>
parents: 1027
diff changeset
   632
        In particular, this exception indicates that something went wrong in the
1859
6e6e866921e7 529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents: 1755
diff changeset
   633
        application (or unapplication) of the action to the system, and is most
6e6e866921e7 529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents: 1755
diff changeset
   634
        likely not an error in the pkg(5) code."""
6e6e866921e7 529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents: 1755
diff changeset
   635
6e6e866921e7 529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents: 1755
diff changeset
   636
        def __init__(self, action, details=None, error=None, fmri=None,
6e6e866921e7 529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents: 1755
diff changeset
   637
            use_errno=None):
6e6e866921e7 529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents: 1755
diff changeset
   638
                """'action' is the object for the action that failed during the
6e6e866921e7 529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents: 1755
diff changeset
   639
                requested operation.
6e6e866921e7 529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents: 1755
diff changeset
   640
6e6e866921e7 529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents: 1755
diff changeset
   641
                'details' is an optional message explaining what operation
6e6e866921e7 529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents: 1755
diff changeset
   642
                failed, why it failed, and why it cannot continue.  It should
6e6e866921e7 529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents: 1755
diff changeset
   643
                also include a suggestion as to how to resolve the situation
6e6e866921e7 529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents: 1755
diff changeset
   644
                if possible.
6e6e866921e7 529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents: 1755
diff changeset
   645
6e6e866921e7 529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents: 1755
diff changeset
   646
                'error' is an optional exception object that may have been
6e6e866921e7 529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents: 1755
diff changeset
   647
                raised when the operation failed.
1050
54c841d1fad9 1770 Invalid "Not owner" error when path is delivered as both directory and symlink
Danek Duvall <danek.duvall@sun.com>
parents: 1027
diff changeset
   648
1859
6e6e866921e7 529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents: 1755
diff changeset
   649
                'fmri' is an optional package FMRI indicating what package
6e6e866921e7 529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents: 1755
diff changeset
   650
                was being operated on at the time the error occurred.
6e6e866921e7 529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents: 1755
diff changeset
   651
6e6e866921e7 529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents: 1755
diff changeset
   652
                'use_errno' is an optional boolean value indicating whether
6e6e866921e7 529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents: 1755
diff changeset
   653
                the strerror() text of the exception should be used.  If
6e6e866921e7 529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents: 1755
diff changeset
   654
                'details' is provided, the default value is False, otherwise
6e6e866921e7 529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents: 1755
diff changeset
   655
                True."""
1050
54c841d1fad9 1770 Invalid "Not owner" error when path is delivered as both directory and symlink
Danek Duvall <danek.duvall@sun.com>
parents: 1027
diff changeset
   656
1859
6e6e866921e7 529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents: 1755
diff changeset
   657
                assert (details or error)
1050
54c841d1fad9 1770 Invalid "Not owner" error when path is delivered as both directory and symlink
Danek Duvall <danek.duvall@sun.com>
parents: 1027
diff changeset
   658
                self.action = action
1859
6e6e866921e7 529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents: 1755
diff changeset
   659
                self.details = details
6e6e866921e7 529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents: 1755
diff changeset
   660
                self.error = error
6e6e866921e7 529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents: 1755
diff changeset
   661
                self.fmri = fmri
6e6e866921e7 529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents: 1755
diff changeset
   662
                if use_errno == None:
6e6e866921e7 529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents: 1755
diff changeset
   663
                        # If details were provided, don't use errno unless
6e6e866921e7 529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents: 1755
diff changeset
   664
                        # explicitly requested.
6e6e866921e7 529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents: 1755
diff changeset
   665
                        use_errno = not details
6e6e866921e7 529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents: 1755
diff changeset
   666
                self.use_errno = use_errno
1050
54c841d1fad9 1770 Invalid "Not owner" error when path is delivered as both directory and symlink
Danek Duvall <danek.duvall@sun.com>
parents: 1027
diff changeset
   667
54c841d1fad9 1770 Invalid "Not owner" error when path is delivered as both directory and symlink
Danek Duvall <danek.duvall@sun.com>
parents: 1027
diff changeset
   668
        def __str__(self):
54c841d1fad9 1770 Invalid "Not owner" error when path is delivered as both directory and symlink
Danek Duvall <danek.duvall@sun.com>
parents: 1027
diff changeset
   669
                errno = ""
1859
6e6e866921e7 529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents: 1755
diff changeset
   670
                if self.use_errno and self.error and \
6e6e866921e7 529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents: 1755
diff changeset
   671
                    hasattr(self.error, "errno"):
6e6e866921e7 529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents: 1755
diff changeset
   672
                        errno = "[errno %d: %s]" % (self.error.errno,
6e6e866921e7 529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents: 1755
diff changeset
   673
                            os.strerror(self.error.errno))
1050
54c841d1fad9 1770 Invalid "Not owner" error when path is delivered as both directory and symlink
Danek Duvall <danek.duvall@sun.com>
parents: 1027
diff changeset
   674
1859
6e6e866921e7 529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents: 1755
diff changeset
   675
                details = self.details or ""
1050
54c841d1fad9 1770 Invalid "Not owner" error when path is delivered as both directory and symlink
Danek Duvall <danek.duvall@sun.com>
parents: 1027
diff changeset
   676
54c841d1fad9 1770 Invalid "Not owner" error when path is delivered as both directory and symlink
Danek Duvall <danek.duvall@sun.com>
parents: 1027
diff changeset
   677
                # Fall back on the wrapped exception if we don't have anything
54c841d1fad9 1770 Invalid "Not owner" error when path is delivered as both directory and symlink
Danek Duvall <danek.duvall@sun.com>
parents: 1027
diff changeset
   678
                # useful.
1859
6e6e866921e7 529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents: 1755
diff changeset
   679
                if not errno and not details:
6e6e866921e7 529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents: 1755
diff changeset
   680
                        return str(self.error)
6e6e866921e7 529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents: 1755
diff changeset
   681
6e6e866921e7 529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents: 1755
diff changeset
   682
                if errno and details:
6e6e866921e7 529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents: 1755
diff changeset
   683
                        details = "%s: %s" % (errno, details)
1050
54c841d1fad9 1770 Invalid "Not owner" error when path is delivered as both directory and symlink
Danek Duvall <danek.duvall@sun.com>
parents: 1027
diff changeset
   684
1859
6e6e866921e7 529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents: 1755
diff changeset
   685
                if details and not self.fmri:
6e6e866921e7 529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents: 1755
diff changeset
   686
                        details = _("Requested operation failed for action "
6e6e866921e7 529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents: 1755
diff changeset
   687
                            "%(action)s:\n%(details)s") % {
6e6e866921e7 529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents: 1755
diff changeset
   688
                            "action": self.action,
2073
9fcacc9e5eaa 16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents: 2034
diff changeset
   689
                            "details": details }
1859
6e6e866921e7 529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents: 1755
diff changeset
   690
                elif details:
6e6e866921e7 529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents: 1755
diff changeset
   691
                        details = _("Requested operation failed for package "
6e6e866921e7 529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents: 1755
diff changeset
   692
                            "%(fmri)s:\n%(details)s") % { "fmri": self.fmri,
6e6e866921e7 529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents: 1755
diff changeset
   693
                            "details": details }
1050
54c841d1fad9 1770 Invalid "Not owner" error when path is delivered as both directory and symlink
Danek Duvall <danek.duvall@sun.com>
parents: 1027
diff changeset
   694
54c841d1fad9 1770 Invalid "Not owner" error when path is delivered as both directory and symlink
Danek Duvall <danek.duvall@sun.com>
parents: 1027
diff changeset
   695
                # If we only have one of the two, no need for the colon.
1859
6e6e866921e7 529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents: 1755
diff changeset
   696
                return "%s%s" % (errno, details)
1050
54c841d1fad9 1770 Invalid "Not owner" error when path is delivered as both directory and symlink
Danek Duvall <danek.duvall@sun.com>
parents: 1027
diff changeset
   697
1068
9400aa8afd32 2557 catalog cache pickle file dependent on fmri and version object definitions
Shawn Walker <srw@sun.com>
parents: 1053
diff changeset
   698
565
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   699
class CatalogRefreshException(ApiException):
1603
84bd53597209 13019 DeprecationWarnings seen after python 2.6 migration
Dan Price <dp@eng.sun.com>
parents: 1540
diff changeset
   700
        def __init__(self, failed, total, succeeded, errmessage=None):
565
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   701
                ApiException.__init__(self)
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   702
                self.failed = failed
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   703
                self.total = total
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   704
                self.succeeded = succeeded
1603
84bd53597209 13019 DeprecationWarnings seen after python 2.6 migration
Dan Price <dp@eng.sun.com>
parents: 1540
diff changeset
   705
                self.errmessage = errmessage
565
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   706
1068
9400aa8afd32 2557 catalog cache pickle file dependent on fmri and version object definitions
Shawn Walker <srw@sun.com>
parents: 1053
diff changeset
   707
1352
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   708
class CatalogError(ApiException):
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   709
        """Base exception class for all catalog exceptions."""
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   710
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   711
        def __init__(self, *args, **kwargs):
565
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   712
                ApiException.__init__(self)
1352
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   713
                if args:
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   714
                        self.data = args[0]
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   715
                else:
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   716
                        self.data = None
1516
8c950a3b4171 10485 move pkg(5) to Python 2.6
Rich Burridge <rich.burridge@sun.com>
parents: 1505
diff changeset
   717
                self._args = kwargs
1352
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   718
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   719
        def __str__(self):
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   720
                return str(self.data)
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   721
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   722
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   723
class AnarchicalCatalogFMRI(CatalogError):
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   724
        """Used to indicate that the specified FMRI is not valid for catalog
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   725
        operations because it is missing publisher information."""
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   726
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   727
        def __str__(self):
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   728
                return _("The FMRI '%s' does not contain publisher information "
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   729
                    "and cannot be used for catalog operations.") % self.data
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   730
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   731
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   732
class BadCatalogMetaRoot(CatalogError):
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   733
        """Used to indicate an operation on the catalog's meta_root failed
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   734
        because the meta_root is invalid."""
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   735
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   736
        def __str__(self):
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   737
                return _("Catalog meta_root '%(root)s' is invalid; unable "
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   738
                    "to complete operation: '%(op)s'.") % { "root": self.data,
1516
8c950a3b4171 10485 move pkg(5) to Python 2.6
Rich Burridge <rich.burridge@sun.com>
parents: 1505
diff changeset
   739
                    "op": self._args.get("operation", None) }
1352
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   740
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   741
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   742
class BadCatalogPermissions(CatalogError):
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   743
        """Used to indicate the server catalog files do not have the expected
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   744
        permissions."""
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   745
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   746
        def __init__(self, files):
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   747
                """files should contain a list object with each entry consisting
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   748
                of a tuple of filename, expected_mode, received_mode."""
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   749
                if not files:
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   750
                        files = []
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   751
                CatalogError.__init__(self, files)
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   752
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   753
        def __str__(self):
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   754
                msg = _("The following catalog files have incorrect "
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   755
                    "permissions:\n")
1516
8c950a3b4171 10485 move pkg(5) to Python 2.6
Rich Burridge <rich.burridge@sun.com>
parents: 1505
diff changeset
   756
                for f in self._args:
1352
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   757
                        fname, emode, fmode = f
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   758
                        msg += _("\t%(fname)s: expected mode: %(emode)s, found "
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   759
                            "mode: %(fmode)s\n") % { "fname": fname,
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   760
                            "emode": emode, "fmode": fmode }
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   761
                return msg
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   762
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   763
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   764
class BadCatalogSignatures(CatalogError):
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   765
        """Used to indicate that the Catalog signatures are not valid."""
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   766
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   767
        def __str__(self):
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   768
                return _("The signature data for the '%s' catalog file is not "
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   769
                    "valid.") % self.data
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   770
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   771
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   772
class BadCatalogUpdateIdentity(CatalogError):
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   773
        """Used to indicate that the requested catalog updates could not be
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   774
        applied as the new catalog data is significantly different such that
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   775
        the old catalog cannot be updated to match it."""
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   776
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   777
        def __str__(self):
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   778
                return _("Unable to determine the updates needed for  "
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   779
                    "the current catalog using the provided catalog "
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   780
                    "update data in '%s'.") % self.data
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   781
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   782
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   783
class DuplicateCatalogEntry(CatalogError):
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   784
        """Used to indicate that the specified catalog operation could not be
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   785
        performed since it would result in a duplicate catalog entry."""
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   786
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   787
        def __str__(self):
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   788
                return _("Unable to perform '%(op)s' operation for catalog "
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   789
                    "%(name)s; completion would result in a duplicate entry "
1516
8c950a3b4171 10485 move pkg(5) to Python 2.6
Rich Burridge <rich.burridge@sun.com>
parents: 1505
diff changeset
   790
                    "for package '%(fmri)s'.") % { "op": self._args.get(
8c950a3b4171 10485 move pkg(5) to Python 2.6
Rich Burridge <rich.burridge@sun.com>
parents: 1505
diff changeset
   791
                    "operation", None), "name": self._args.get("catalog_name",
1352
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   792
                    None), "fmri": self.data }
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   793
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   794
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   795
class CatalogUpdateRequirements(CatalogError):
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   796
        """Used to indicate that an update request for the catalog could not
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   797
        be performed because update requirements were not satisfied."""
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   798
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   799
        def __str__(self):
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   800
                return _("Catalog updates can only be applied to an on-disk "
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   801
                    "catalog.")
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   802
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   803
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   804
class InvalidCatalogFile(CatalogError):
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   805
        """Used to indicate a Catalog file could not be loaded."""
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   806
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   807
        def __str__(self):
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   808
                return _("Catalog file '%s' is invalid.") % self.data
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   809
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   810
2022
40fbda1e14b7 16715 publisher refresh should validate retrieved catalog parts using catalog attributes
Shawn Walker <shawn.walker@oracle.com>
parents: 1970
diff changeset
   811
class MismatchedCatalog(CatalogError):
40fbda1e14b7 16715 publisher refresh should validate retrieved catalog parts using catalog attributes
Shawn Walker <shawn.walker@oracle.com>
parents: 1970
diff changeset
   812
        """Used to indicate that a Catalog's attributes and parts do not
40fbda1e14b7 16715 publisher refresh should validate retrieved catalog parts using catalog attributes
Shawn Walker <shawn.walker@oracle.com>
parents: 1970
diff changeset
   813
        match.  This is likely the result of an attributes file being
40fbda1e14b7 16715 publisher refresh should validate retrieved catalog parts using catalog attributes
Shawn Walker <shawn.walker@oracle.com>
parents: 1970
diff changeset
   814
        retrieved which doesn't match the parts that were retrieved such
40fbda1e14b7 16715 publisher refresh should validate retrieved catalog parts using catalog attributes
Shawn Walker <shawn.walker@oracle.com>
parents: 1970
diff changeset
   815
        as in a misconfigured or stale cache case."""
40fbda1e14b7 16715 publisher refresh should validate retrieved catalog parts using catalog attributes
Shawn Walker <shawn.walker@oracle.com>
parents: 1970
diff changeset
   816
40fbda1e14b7 16715 publisher refresh should validate retrieved catalog parts using catalog attributes
Shawn Walker <shawn.walker@oracle.com>
parents: 1970
diff changeset
   817
        def __str__(self):
40fbda1e14b7 16715 publisher refresh should validate retrieved catalog parts using catalog attributes
Shawn Walker <shawn.walker@oracle.com>
parents: 1970
diff changeset
   818
                return _("The content of the catalog for publisher '%s' "
40fbda1e14b7 16715 publisher refresh should validate retrieved catalog parts using catalog attributes
Shawn Walker <shawn.walker@oracle.com>
parents: 1970
diff changeset
   819
                    "doesn't match the catalog's attributes.  This is "
40fbda1e14b7 16715 publisher refresh should validate retrieved catalog parts using catalog attributes
Shawn Walker <shawn.walker@oracle.com>
parents: 1970
diff changeset
   820
                    "likely the result of a mix of older and newer "
40fbda1e14b7 16715 publisher refresh should validate retrieved catalog parts using catalog attributes
Shawn Walker <shawn.walker@oracle.com>
parents: 1970
diff changeset
   821
                    "catalog files being provided for the publisher.") % \
40fbda1e14b7 16715 publisher refresh should validate retrieved catalog parts using catalog attributes
Shawn Walker <shawn.walker@oracle.com>
parents: 1970
diff changeset
   822
                    self.data
40fbda1e14b7 16715 publisher refresh should validate retrieved catalog parts using catalog attributes
Shawn Walker <shawn.walker@oracle.com>
parents: 1970
diff changeset
   823
40fbda1e14b7 16715 publisher refresh should validate retrieved catalog parts using catalog attributes
Shawn Walker <shawn.walker@oracle.com>
parents: 1970
diff changeset
   824
1352
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   825
class ObsoleteCatalogUpdate(CatalogError):
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   826
        """Used to indicate that the specified catalog updates are for an older
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   827
        version of the catalog and cannot be applied."""
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   828
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   829
        def __str__(self):
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   830
                return _("Unable to determine the updates needed for the "
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   831
                    "catalog using the provided catalog update data in '%s'. "
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   832
                    "The specified catalog updates are for an older version "
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   833
                    "of the catalog and cannot be used.") % self.data
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   834
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   835
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   836
class UnknownCatalogEntry(CatalogError):
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   837
        """Used to indicate that an entry for the specified package FMRI or
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   838
        pattern could not be found in the catalog."""
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   839
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   840
        def __str__(self):
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   841
                return _("'%s' could not be found in the catalog.") % self.data
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   842
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   843
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   844
class UnknownUpdateType(CatalogError):
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   845
        """Used to indicate that the specified CatalogUpdate operation is
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   846
        unknown."""
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   847
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   848
        def __str__(self):
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   849
                return _("Unknown catalog update type '%s'") % self.data
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   850
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   851
1431
62b6033670e4 10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents: 1372
diff changeset
   852
class UnrecognizedCatalogPart(CatalogError):
62b6033670e4 10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents: 1372
diff changeset
   853
        """Raised when the catalog finds a CatalogPart that is unrecognized
62b6033670e4 10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents: 1372
diff changeset
   854
        or invalid."""
62b6033670e4 10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents: 1372
diff changeset
   855
62b6033670e4 10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents: 1372
diff changeset
   856
        def __str__(self):
62b6033670e4 10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents: 1372
diff changeset
   857
                return _("Unrecognized, unknown, or invalid CatalogPart '%s'") \
62b6033670e4 10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents: 1372
diff changeset
   858
                    % self.data
62b6033670e4 10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents: 1372
diff changeset
   859
62b6033670e4 10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents: 1372
diff changeset
   860
1352
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   861
class InventoryException(ApiException):
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   862
        """Used to indicate that some of the specified patterns to a catalog
1970
60471574c487 16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents: 1968
diff changeset
   863
        matching function did not match any catalog entries, or were invalid
60471574c487 16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents: 1968
diff changeset
   864
        patterns."""
1352
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   865
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   866
        def __init__(self, illegal=EmptyI, matcher=EmptyI, notfound=EmptyI,
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   867
            publisher=EmptyI, version=EmptyI):
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   868
                ApiException.__init__(self)
838
aafbe4737188 3245 need to support creation of multi-architecture (fat) packages
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents: 835
diff changeset
   869
                self.illegal = illegal
1352
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   870
                self.matcher = matcher
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   871
                self.notfound = set(notfound)
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   872
                self.publisher = publisher
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   873
                self.version = version
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   874
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   875
                self.notfound.update(matcher)
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   876
                self.notfound.update(publisher)
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   877
                self.notfound.update(version)
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   878
                self.notfound = list(self.notfound)
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   879
1945
a4fc142accb2 16111 pkgdepend expands format strings before passing through gettext
Richard Lowe <richlowe@richlowe.net>
parents: 1937
diff changeset
   880
                assert self.illegal or self.notfound
565
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   881
596
f4519e2a99bc 3704 InventoryException raised if optional dependencies not in catalog
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 565
diff changeset
   882
        def __str__(self):
f4519e2a99bc 3704 InventoryException raised if optional dependencies not in catalog
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 565
diff changeset
   883
                outstr = ""
f4519e2a99bc 3704 InventoryException raised if optional dependencies not in catalog
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 565
diff changeset
   884
                for x in self.illegal:
f4519e2a99bc 3704 InventoryException raised if optional dependencies not in catalog
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 565
diff changeset
   885
                        # Illegal FMRIs have their own __str__ method
f4519e2a99bc 3704 InventoryException raised if optional dependencies not in catalog
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 565
diff changeset
   886
                        outstr += "%s\n" % x
614
4b620a1e8c01 4080 Inventory Exception is overly verbose
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 596
diff changeset
   887
1352
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   888
                if self.matcher or self.publisher or self.version:
614
4b620a1e8c01 4080 Inventory Exception is overly verbose
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 596
diff changeset
   889
                        outstr += _("No matching package could be found for "
4b620a1e8c01 4080 Inventory Exception is overly verbose
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 596
diff changeset
   890
                            "the following FMRIs in any of the catalogs for "
926
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
   891
                            "the current publishers:\n")
614
4b620a1e8c01 4080 Inventory Exception is overly verbose
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 596
diff changeset
   892
1352
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   893
                        for x in self.matcher:
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   894
                                outstr += _("%s (pattern did not match)\n") % x
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   895
                        for x in self.publisher:
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   896
                                outstr += _("%s (publisher did not "
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   897
                                    "match)\n") % x
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   898
                        for x in self.version:
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
   899
                                outstr += _("%s (version did not match)\n") % x
596
f4519e2a99bc 3704 InventoryException raised if optional dependencies not in catalog
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 565
diff changeset
   900
                return outstr
565
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
   901
1027
e827313523d8 7774 image history discarded when bootenv operations fail or succeed
Shawn Walker <srw@sun.com>
parents: 1019
diff changeset
   902
1191
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
   903
# SearchExceptions
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
   904
1027
e827313523d8 7774 image history discarded when bootenv operations fail or succeed
Shawn Walker <srw@sun.com>
parents: 1019
diff changeset
   905
class SearchException(ApiException):
e827313523d8 7774 image history discarded when bootenv operations fail or succeed
Shawn Walker <srw@sun.com>
parents: 1019
diff changeset
   906
        """Based class used for all search-related api exceptions."""
e827313523d8 7774 image history discarded when bootenv operations fail or succeed
Shawn Walker <srw@sun.com>
parents: 1019
diff changeset
   907
        pass
e827313523d8 7774 image history discarded when bootenv operations fail or succeed
Shawn Walker <srw@sun.com>
parents: 1019
diff changeset
   908
e827313523d8 7774 image history discarded when bootenv operations fail or succeed
Shawn Walker <srw@sun.com>
parents: 1019
diff changeset
   909
1191
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
   910
class MalformedSearchRequest(SearchException):
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
   911
        """Raised when the server cannot understand the format of the
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
   912
        search request."""
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
   913
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
   914
        def __init__(self, url):
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
   915
                SearchException.__init__(self)
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
   916
                self.url = url
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
   917
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
   918
        def __str__(self):
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
   919
                return str(self.url)
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
   920
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
   921
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
   922
class NegativeSearchResult(SearchException):
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
   923
        """Returned when the search cannot find any matches."""
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
   924
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
   925
        def __init__(self, url):
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
   926
                SearchException.__init__(self)
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
   927
                self.url = url
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
   928
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
   929
        def __str__(self):
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
   930
                return _("The search at url %s returned no results.") % self.url
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
   931
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
   932
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
   933
class ProblematicSearchServers(SearchException):
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
   934
        """This class wraps exceptions which could appear while trying to
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
   935
        do a search request."""
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
   936
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
   937
        def __init__(self, failed=EmptyI, invalid=EmptyI, unsupported=EmptyI):
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
   938
                SearchException.__init__(self)
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
   939
                self.failed_servers = failed
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
   940
                self.invalid_servers  = invalid
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
   941
                self.unsupported_servers = unsupported
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
   942
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
   943
        def __str__(self):
1895
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1859
diff changeset
   944
                s = _("Some repositories failed to respond appropriately:\n")
1191
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
   945
                for pub, err in self.failed_servers:
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
   946
                        s += _("%(o)s:\n%(msg)s\n") % \
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
   947
                            { "o": pub, "msg": err}
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
   948
                for pub in self.invalid_servers:
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
   949
                        s += _("%s did not return a valid response.\n" \
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
   950
                            % pub)
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
   951
                if len(self.unsupported_servers) > 0:
1895
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1859
diff changeset
   952
                        s += _("Some repositories don't support requested "
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1859
diff changeset
   953
                            "search operation:\n")
1191
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
   954
                for pub, err in self.unsupported_servers:
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
   955
                        s += _("%(o)s:\n%(msg)s\n") % \
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
   956
                            { "o": pub, "msg": err}
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
   957
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
   958
                return s
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
   959
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
   960
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
   961
class SlowSearchUsed(SearchException):
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
   962
        """This exception is thrown when a local search is performed without
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
   963
        an index.  It's raised after all results have been yielded."""
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
   964
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
   965
        def __str__(self):
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
   966
                return _("Search performance is degraded.\n"
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
   967
                    "Run 'pkg rebuild-index' to improve search speed.")
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
   968
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
   969
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
   970
class UnsupportedSearchError(SearchException):
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
   971
        """Returned when a search protocol is not supported by the
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
   972
        remote server."""
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
   973
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
   974
        def __init__(self, url=None, proto=None):
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
   975
                SearchException.__init__(self)
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
   976
                self.url = url
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
   977
                self.proto = proto
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
   978
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
   979
        def __str__(self):
1895
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1859
diff changeset
   980
                s = _("Search repository does not support the requested "
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1859
diff changeset
   981
                    "protocol:")
1191
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
   982
                if self.url:
1895
0a260cc2a689 15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents: 1859
diff changeset
   983
                        s += "\nRepository URL: %s" % self.url
1191
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
   984
                if self.proto:
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
   985
                        s += "\nRequested operation: %s" % self.proto
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
   986
                return s
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
   987
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
   988
        def __cmp__(self, other):
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
   989
                if not isinstance(other, UnsupportedSearchError):
1945
a4fc142accb2 16111 pkgdepend expands format strings before passing through gettext
Richard Lowe <richlowe@richlowe.net>
parents: 1937
diff changeset
   990
                        return -1
1191
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
   991
                r = cmp(self.url, other.url)
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
   992
                if r != 0:
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
   993
                        return r
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
   994
                return cmp(self.proto, other.proto)
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
   995
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
   996
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
   997
# IndexingExceptions.
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
   998
1027
e827313523d8 7774 image history discarded when bootenv operations fail or succeed
Shawn Walker <srw@sun.com>
parents: 1019
diff changeset
   999
class IndexingException(SearchException):
565
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
  1000
        """ The base class for all exceptions that can occur while indexing. """
1027
e827313523d8 7774 image history discarded when bootenv operations fail or succeed
Shawn Walker <srw@sun.com>
parents: 1019
diff changeset
  1001
565
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
  1002
        def __init__(self, private_exception):
1027
e827313523d8 7774 image history discarded when bootenv operations fail or succeed
Shawn Walker <srw@sun.com>
parents: 1019
diff changeset
  1003
                SearchException.__init__(self)
565
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
  1004
                self.cause = private_exception.cause
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
  1005
1027
e827313523d8 7774 image history discarded when bootenv operations fail or succeed
Shawn Walker <srw@sun.com>
parents: 1019
diff changeset
  1006
565
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
  1007
class CorruptedIndexException(IndexingException):
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
  1008
        """This is used when the index is not in a correct state."""
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
  1009
        pass
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
  1010
1027
e827313523d8 7774 image history discarded when bootenv operations fail or succeed
Shawn Walker <srw@sun.com>
parents: 1019
diff changeset
  1011
1191
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
  1012
class InconsistentIndexException(IndexingException):
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
  1013
        """This is used when the existing index is found to have inconsistent
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
  1014
        versions."""
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
  1015
        def __init__(self, e):
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
  1016
                IndexingException.__init__(self, e)
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
  1017
                self.exception = e
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
  1018
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
  1019
        def __str__(self):
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
  1020
                return str(self.exception)
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
  1021
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
  1022
2028
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  1023
class IndexLockedException(IndexingException):
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  1024
        """This is used when an attempt to modify an index locked by another
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  1025
        process or thread is made."""
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  1026
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  1027
        def __init__(self, e):
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  1028
                IndexingException.__init__(self, e)
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  1029
                self.exception = e
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  1030
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  1031
        def __str__(self):
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  1032
                return str(self.exception)
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  1033
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  1034
565
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
  1035
class ProblematicPermissionsIndexException(IndexingException):
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
  1036
        """ This is used when the indexer is unable to create, move, or remove
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
  1037
        files or directories it should be able to. """
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
  1038
        def __str__(self):
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
  1039
                return "Could not remove or create " \
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
  1040
                    "%s because of incorrect " \
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
  1041
                    "permissions. Please correct this issue then " \
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
  1042
                    "rebuild the index." % self.cause
941
e7bff46da54e 6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents: 926
diff changeset
  1043
1286
2e5bb564a9e2 8948 search errors should make it clear that the rest of the command worked
Brock Pytlik <bpytlik@sun.com>
parents: 1256
diff changeset
  1044
class WrapIndexingException(ApiException):
2e5bb564a9e2 8948 search errors should make it clear that the rest of the command worked
Brock Pytlik <bpytlik@sun.com>
parents: 1256
diff changeset
  1045
        """This exception is used to wrap an indexing exception during install,
2089
c8b9d6341530 2775 pkg should provide a way to downgrade (reinstall) packages
Shawn Walker <shawn.walker@oracle.com>
parents: 2073
diff changeset
  1046
        uninstall, or update so that a more appropriate error message can be
c8b9d6341530 2775 pkg should provide a way to downgrade (reinstall) packages
Shawn Walker <shawn.walker@oracle.com>
parents: 2073
diff changeset
  1047
        displayed to the user."""
1286
2e5bb564a9e2 8948 search errors should make it clear that the rest of the command worked
Brock Pytlik <bpytlik@sun.com>
parents: 1256
diff changeset
  1048
2e5bb564a9e2 8948 search errors should make it clear that the rest of the command worked
Brock Pytlik <bpytlik@sun.com>
parents: 1256
diff changeset
  1049
        def __init__(self, e, tb, stack):
2e5bb564a9e2 8948 search errors should make it clear that the rest of the command worked
Brock Pytlik <bpytlik@sun.com>
parents: 1256
diff changeset
  1050
                ApiException.__init__(self)
2e5bb564a9e2 8948 search errors should make it clear that the rest of the command worked
Brock Pytlik <bpytlik@sun.com>
parents: 1256
diff changeset
  1051
                self.wrapped = e
2e5bb564a9e2 8948 search errors should make it clear that the rest of the command worked
Brock Pytlik <bpytlik@sun.com>
parents: 1256
diff changeset
  1052
                self.tb = tb
2e5bb564a9e2 8948 search errors should make it clear that the rest of the command worked
Brock Pytlik <bpytlik@sun.com>
parents: 1256
diff changeset
  1053
                self.stack = stack
2e5bb564a9e2 8948 search errors should make it clear that the rest of the command worked
Brock Pytlik <bpytlik@sun.com>
parents: 1256
diff changeset
  1054
2e5bb564a9e2 8948 search errors should make it clear that the rest of the command worked
Brock Pytlik <bpytlik@sun.com>
parents: 1256
diff changeset
  1055
        def __str__(self):
2e5bb564a9e2 8948 search errors should make it clear that the rest of the command worked
Brock Pytlik <bpytlik@sun.com>
parents: 1256
diff changeset
  1056
                tmp = self.tb.split("\n")
2e5bb564a9e2 8948 search errors should make it clear that the rest of the command worked
Brock Pytlik <bpytlik@sun.com>
parents: 1256
diff changeset
  1057
                res = tmp[:1] + [s.rstrip("\n") for s in self.stack] + tmp[1:]
2e5bb564a9e2 8948 search errors should make it clear that the rest of the command worked
Brock Pytlik <bpytlik@sun.com>
parents: 1256
diff changeset
  1058
                return "\n".join(res)
2e5bb564a9e2 8948 search errors should make it clear that the rest of the command worked
Brock Pytlik <bpytlik@sun.com>
parents: 1256
diff changeset
  1059
2e5bb564a9e2 8948 search errors should make it clear that the rest of the command worked
Brock Pytlik <bpytlik@sun.com>
parents: 1256
diff changeset
  1060
2e5bb564a9e2 8948 search errors should make it clear that the rest of the command worked
Brock Pytlik <bpytlik@sun.com>
parents: 1256
diff changeset
  1061
class WrapSuccessfulIndexingException(WrapIndexingException):
2e5bb564a9e2 8948 search errors should make it clear that the rest of the command worked
Brock Pytlik <bpytlik@sun.com>
parents: 1256
diff changeset
  1062
        """This exception is used to wrap an indexing exception during install,
2089
c8b9d6341530 2775 pkg should provide a way to downgrade (reinstall) packages
Shawn Walker <shawn.walker@oracle.com>
parents: 2073
diff changeset
  1063
        uninstall, or update which was recovered from by performing a full
c8b9d6341530 2775 pkg should provide a way to downgrade (reinstall) packages
Shawn Walker <shawn.walker@oracle.com>
parents: 2073
diff changeset
  1064
        reindex."""
1286
2e5bb564a9e2 8948 search errors should make it clear that the rest of the command worked
Brock Pytlik <bpytlik@sun.com>
parents: 1256
diff changeset
  1065
        pass
2e5bb564a9e2 8948 search errors should make it clear that the rest of the command worked
Brock Pytlik <bpytlik@sun.com>
parents: 1256
diff changeset
  1066
2e5bb564a9e2 8948 search errors should make it clear that the rest of the command worked
Brock Pytlik <bpytlik@sun.com>
parents: 1256
diff changeset
  1067
1191
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
  1068
# Query Parsing Exceptions
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
  1069
class BooleanQueryException(ApiException):
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
  1070
        """This exception is used when the children of a boolean operation
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
  1071
        have different return types.  The command 'pkg search foo AND <bar>'
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
  1072
        is the simplest example of this."""
941
e7bff46da54e 6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents: 926
diff changeset
  1073
e7bff46da54e 6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents: 926
diff changeset
  1074
        def __init__(self, e):
1191
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
  1075
                ApiException.__init__(self)
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
  1076
                self.e = e
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
  1077
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
  1078
        def __str__(self):
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
  1079
                return str(self.e)
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
  1080
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
  1081
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
  1082
class ParseError(ApiException):
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
  1083
        def __init__(self, e):
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
  1084
                ApiException.__init__(self)
941
e7bff46da54e 6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents: 926
diff changeset
  1085
                self.e = e
e7bff46da54e 6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents: 926
diff changeset
  1086
e7bff46da54e 6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents: 926
diff changeset
  1087
        def __str__(self):
1027
e827313523d8 7774 image history discarded when bootenv operations fail or succeed
Shawn Walker <srw@sun.com>
parents: 1019
diff changeset
  1088
                return str(self.e)
e827313523d8 7774 image history discarded when bootenv operations fail or succeed
Shawn Walker <srw@sun.com>
parents: 1019
diff changeset
  1089
565
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
  1090
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
  1091
class NonLeafPackageException(ApiException):
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
  1092
        """Removal of a package which satisfies dependencies has been attempted.
1027
e827313523d8 7774 image history discarded when bootenv operations fail or succeed
Shawn Walker <srw@sun.com>
parents: 1019
diff changeset
  1093
565
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
  1094
        The first argument to the constructor is the FMRI which we tried to
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
  1095
        remove, and is available as the "fmri" member of the exception.  The
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
  1096
        second argument is the list of dependent packages that prevent the
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
  1097
        removal of the package, and is available as the "dependents" member.
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
  1098
        """
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
  1099
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
  1100
        def __init__(self, *args):
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
  1101
                ApiException.__init__(self, *args)
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
  1102
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
  1103
                self.fmri = args[0]
1fb4f05220b9 3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
diff changeset
  1104
                self.dependents = args[1]
835
34ec4401dc48 686 Client needs a way to tell that a response is actually from an IPS server
johansen <johansen@sun.com>
parents: 717
diff changeset
  1105
2205
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
  1106
def _str_autofix(self):
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
  1107
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
  1108
        if getattr(self, "_autofix_pkgs", []):
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
  1109
                s = _("\nThis is happening because the following "
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
  1110
                    "packages needed to be repaired as\npart of this "
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
  1111
                    "operation:\n\n    ")
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
  1112
                s += "\n    ".join(str(f) for f in self._autofix_pkgs)
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
  1113
                s += _("\n\nYou will need to reestablish your access to the "
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
  1114
                        "repository or remove the\npackages in the list above.")
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
  1115
                return s
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
  1116
        return ""
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
  1117
835
34ec4401dc48 686 Client needs a way to tell that a response is actually from an IPS server
johansen <johansen@sun.com>
parents: 717
diff changeset
  1118
class InvalidDepotResponseException(ApiException):
34ec4401dc48 686 Client needs a way to tell that a response is actually from an IPS server
johansen <johansen@sun.com>
parents: 717
diff changeset
  1119
        """Raised when the depot doesn't have versions of operations
34ec4401dc48 686 Client needs a way to tell that a response is actually from an IPS server
johansen <johansen@sun.com>
parents: 717
diff changeset
  1120
        that the client needs to operate successfully."""
34ec4401dc48 686 Client needs a way to tell that a response is actually from an IPS server
johansen <johansen@sun.com>
parents: 717
diff changeset
  1121
        def __init__(self, url, data):
926
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1122
                ApiException.__init__(self)
835
34ec4401dc48 686 Client needs a way to tell that a response is actually from an IPS server
johansen <johansen@sun.com>
parents: 717
diff changeset
  1123
                self.url = url
34ec4401dc48 686 Client needs a way to tell that a response is actually from an IPS server
johansen <johansen@sun.com>
parents: 717
diff changeset
  1124
                self.data = data
34ec4401dc48 686 Client needs a way to tell that a response is actually from an IPS server
johansen <johansen@sun.com>
parents: 717
diff changeset
  1125
34ec4401dc48 686 Client needs a way to tell that a response is actually from an IPS server
johansen <johansen@sun.com>
parents: 717
diff changeset
  1126
        def __str__(self):
2205
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
  1127
                s = _("Unable to contact valid package repository")
835
34ec4401dc48 686 Client needs a way to tell that a response is actually from an IPS server
johansen <johansen@sun.com>
parents: 717
diff changeset
  1128
                if self.url:
2205
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
  1129
                        s += _(": %s") % self.url
835
34ec4401dc48 686 Client needs a way to tell that a response is actually from an IPS server
johansen <johansen@sun.com>
parents: 717
diff changeset
  1130
                if self.data:
2205
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
  1131
                        s += ("\nEncountered the following error(s):\n%s") % \
835
34ec4401dc48 686 Client needs a way to tell that a response is actually from an IPS server
johansen <johansen@sun.com>
parents: 717
diff changeset
  1132
                            self.data
2205
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
  1133
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
  1134
                s += _str_autofix(self)
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
  1135
835
34ec4401dc48 686 Client needs a way to tell that a response is actually from an IPS server
johansen <johansen@sun.com>
parents: 717
diff changeset
  1136
                return s
884
d780afc023ff 3718 plan_update_all needs to have an optional argument for the new BE name
Brock Pytlik <bpytlik@sun.com>
parents: 879
diff changeset
  1137
926
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1138
class DataError(ApiException):
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1139
        """Base exception class used for all data related errors."""
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1140
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1141
        def __init__(self, *args, **kwargs):
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1142
                ApiException.__init__(self, *args)
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1143
                if args:
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1144
                        self.data = args[0]
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1145
                else:
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1146
                        self.data = None
1516
8c950a3b4171 10485 move pkg(5) to Python 2.6
Rich Burridge <rich.burridge@sun.com>
parents: 1505
diff changeset
  1147
                self._args = kwargs
926
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1148
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1149
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1150
class InvalidP5IFile(DataError):
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1151
        """Used to indicate that the specified location does not contain a
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1152
        valid p5i-formatted file."""
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1153
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1154
        def __str__(self):
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1155
                if self.data:
1736
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1710
diff changeset
  1156
                        return _("The provided p5i data is in an unrecognized "
926
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1157
                            "format or does not contain valid publisher "
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1158
                            "information: %s") % self.data
1736
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1710
diff changeset
  1159
                return _("The provided p5i data is in an unrecognized format "
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1710
diff changeset
  1160
                    "or does not contain valid publisher information.")
926
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1161
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1162
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1163
class UnsupportedP5IFile(DataError):
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1164
        """Used to indicate that an attempt to read an unsupported version
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1165
        of pkg(5) info file was attempted."""
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1166
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1167
        def __str__(self):
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1168
                return _("Unsupported pkg(5) publisher information data "
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1169
                    "format.")
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1170
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1171
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1172
class TransportError(ApiException):
1191
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
  1173
        """Abstract exception class for all transport exceptions.
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
  1174
        Specific transport exceptions should be implemented in the
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
  1175
        transport code.  Callers wishing to catch transport exceptions
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
  1176
        should use this class.  Subclasses must implement all methods
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
  1177
        defined here that raise NotImplementedError."""
926
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1178
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1179
        def __str__(self):
1540
de040c9fd0c0 13003 exception messages not always displayed correctly with python 2.6
Shawn Walker <srw@sun.com>
parents: 1516
diff changeset
  1180
                raise NotImplementedError()
926
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1181
2205
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
  1182
        def _str_autofix(self):
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
  1183
                return _str_autofix(self)
53d0be594162 3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents: 2200
diff changeset
  1184
926
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1185
1191
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
  1186
class RetrievalError(ApiException):
926
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1187
        """Used to indicate that a a requested resource could not be
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1188
        retrieved."""
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1189
1191
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
  1190
        def __init__(self, data, location=None):
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
  1191
                ApiException.__init__(self)
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
  1192
                self.data = data
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
  1193
                self.location = location
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
  1194
926
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1195
        def __str__(self):
1191
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
  1196
                if self.location:
926
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1197
                        return _("Error encountered while retrieving data from "
1191
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
  1198
                            "'%s':\n%s") % (self.location, self.data)
926
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1199
                return _("Error encountered while retrieving data from: %s") % \
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1200
                    self.data
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1201
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1202
1191
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
  1203
class InvalidResourceLocation(ApiException):
926
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1204
        """Used to indicate that an invalid transport location was provided."""
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1205
1191
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
  1206
        def __init__(self, data):
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
  1207
                ApiException.__init__(self)
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
  1208
                self.data = data
a48bee2a4b2e 305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents: 1182
diff changeset
  1209
926
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1210
        def __str__(self):
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1211
                return _("'%s' is not a valid location.") % self.data
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1212
941
e7bff46da54e 6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents: 926
diff changeset
  1213
class BEException(ApiException):
e7bff46da54e 6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents: 926
diff changeset
  1214
        def __init__(self):
e7bff46da54e 6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents: 926
diff changeset
  1215
                ApiException.__init__(self)
926
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1216
884
d780afc023ff 3718 plan_update_all needs to have an optional argument for the new BE name
Brock Pytlik <bpytlik@sun.com>
parents: 879
diff changeset
  1217
class InvalidBENameException(BEException):
d780afc023ff 3718 plan_update_all needs to have an optional argument for the new BE name
Brock Pytlik <bpytlik@sun.com>
parents: 879
diff changeset
  1218
        def __init__(self, be_name):
d780afc023ff 3718 plan_update_all needs to have an optional argument for the new BE name
Brock Pytlik <bpytlik@sun.com>
parents: 879
diff changeset
  1219
                BEException.__init__(self)
d780afc023ff 3718 plan_update_all needs to have an optional argument for the new BE name
Brock Pytlik <bpytlik@sun.com>
parents: 879
diff changeset
  1220
                self.be_name = be_name
d780afc023ff 3718 plan_update_all needs to have an optional argument for the new BE name
Brock Pytlik <bpytlik@sun.com>
parents: 879
diff changeset
  1221
d780afc023ff 3718 plan_update_all needs to have an optional argument for the new BE name
Brock Pytlik <bpytlik@sun.com>
parents: 879
diff changeset
  1222
        def __str__(self):
1076
db86977aa656 8048 image update doesn't check to see if specified be-name already exists
Rich Burridge <rich.burridge@sun.com>
parents: 1068
diff changeset
  1223
                return _("'%s' is not a valid boot environment name.") % \
db86977aa656 8048 image update doesn't check to see if specified be-name already exists
Rich Burridge <rich.burridge@sun.com>
parents: 1068
diff changeset
  1224
                    self.be_name
db86977aa656 8048 image update doesn't check to see if specified be-name already exists
Rich Burridge <rich.burridge@sun.com>
parents: 1068
diff changeset
  1225
db86977aa656 8048 image update doesn't check to see if specified be-name already exists
Rich Burridge <rich.burridge@sun.com>
parents: 1068
diff changeset
  1226
class DuplicateBEName(BEException):
1945
a4fc142accb2 16111 pkgdepend expands format strings before passing through gettext
Richard Lowe <richlowe@richlowe.net>
parents: 1937
diff changeset
  1227
        """Used to indicate that there is an existing boot environment
1076
db86977aa656 8048 image update doesn't check to see if specified be-name already exists
Rich Burridge <rich.burridge@sun.com>
parents: 1068
diff changeset
  1228
        with this name"""
db86977aa656 8048 image update doesn't check to see if specified be-name already exists
Rich Burridge <rich.burridge@sun.com>
parents: 1068
diff changeset
  1229
db86977aa656 8048 image update doesn't check to see if specified be-name already exists
Rich Burridge <rich.burridge@sun.com>
parents: 1068
diff changeset
  1230
        def __init__(self, be_name):
db86977aa656 8048 image update doesn't check to see if specified be-name already exists
Rich Burridge <rich.burridge@sun.com>
parents: 1068
diff changeset
  1231
                BEException.__init__(self)
db86977aa656 8048 image update doesn't check to see if specified be-name already exists
Rich Burridge <rich.burridge@sun.com>
parents: 1068
diff changeset
  1232
                self.be_name = be_name
db86977aa656 8048 image update doesn't check to see if specified be-name already exists
Rich Burridge <rich.burridge@sun.com>
parents: 1068
diff changeset
  1233
db86977aa656 8048 image update doesn't check to see if specified be-name already exists
Rich Burridge <rich.burridge@sun.com>
parents: 1068
diff changeset
  1234
        def __str__(self):
db86977aa656 8048 image update doesn't check to see if specified be-name already exists
Rich Burridge <rich.burridge@sun.com>
parents: 1068
diff changeset
  1235
                return _("The boot environment '%s' already exists.") % \
db86977aa656 8048 image update doesn't check to see if specified be-name already exists
Rich Burridge <rich.burridge@sun.com>
parents: 1068
diff changeset
  1236
                    self.be_name
884
d780afc023ff 3718 plan_update_all needs to have an optional argument for the new BE name
Brock Pytlik <bpytlik@sun.com>
parents: 879
diff changeset
  1237
d780afc023ff 3718 plan_update_all needs to have an optional argument for the new BE name
Brock Pytlik <bpytlik@sun.com>
parents: 879
diff changeset
  1238
class BENamingNotSupported(BEException):
d780afc023ff 3718 plan_update_all needs to have an optional argument for the new BE name
Brock Pytlik <bpytlik@sun.com>
parents: 879
diff changeset
  1239
        def __init__(self, be_name):
d780afc023ff 3718 plan_update_all needs to have an optional argument for the new BE name
Brock Pytlik <bpytlik@sun.com>
parents: 879
diff changeset
  1240
                BEException.__init__(self)
d780afc023ff 3718 plan_update_all needs to have an optional argument for the new BE name
Brock Pytlik <bpytlik@sun.com>
parents: 879
diff changeset
  1241
                self.be_name = be_name
d780afc023ff 3718 plan_update_all needs to have an optional argument for the new BE name
Brock Pytlik <bpytlik@sun.com>
parents: 879
diff changeset
  1242
d780afc023ff 3718 plan_update_all needs to have an optional argument for the new BE name
Brock Pytlik <bpytlik@sun.com>
parents: 879
diff changeset
  1243
        def __str__(self):
d780afc023ff 3718 plan_update_all needs to have an optional argument for the new BE name
Brock Pytlik <bpytlik@sun.com>
parents: 879
diff changeset
  1244
                return _("""\
d780afc023ff 3718 plan_update_all needs to have an optional argument for the new BE name
Brock Pytlik <bpytlik@sun.com>
parents: 879
diff changeset
  1245
Boot environment naming during package install is not supported on this
2089
c8b9d6341530 2775 pkg should provide a way to downgrade (reinstall) packages
Shawn Walker <shawn.walker@oracle.com>
parents: 2073
diff changeset
  1246
version of OpenSolaris. Please update without the --be-name option.""")
884
d780afc023ff 3718 plan_update_all needs to have an optional argument for the new BE name
Brock Pytlik <bpytlik@sun.com>
parents: 879
diff changeset
  1247
d780afc023ff 3718 plan_update_all needs to have an optional argument for the new BE name
Brock Pytlik <bpytlik@sun.com>
parents: 879
diff changeset
  1248
class UnableToCopyBE(BEException):
d780afc023ff 3718 plan_update_all needs to have an optional argument for the new BE name
Brock Pytlik <bpytlik@sun.com>
parents: 879
diff changeset
  1249
        def __str__(self):
d780afc023ff 3718 plan_update_all needs to have an optional argument for the new BE name
Brock Pytlik <bpytlik@sun.com>
parents: 879
diff changeset
  1250
                return _("Unable to clone the current boot environment.")
d780afc023ff 3718 plan_update_all needs to have an optional argument for the new BE name
Brock Pytlik <bpytlik@sun.com>
parents: 879
diff changeset
  1251
d780afc023ff 3718 plan_update_all needs to have an optional argument for the new BE name
Brock Pytlik <bpytlik@sun.com>
parents: 879
diff changeset
  1252
class UnableToRenameBE(BEException):
d780afc023ff 3718 plan_update_all needs to have an optional argument for the new BE name
Brock Pytlik <bpytlik@sun.com>
parents: 879
diff changeset
  1253
        def __init__(self, orig, dest):
d780afc023ff 3718 plan_update_all needs to have an optional argument for the new BE name
Brock Pytlik <bpytlik@sun.com>
parents: 879
diff changeset
  1254
                BEException.__init__(self)
d780afc023ff 3718 plan_update_all needs to have an optional argument for the new BE name
Brock Pytlik <bpytlik@sun.com>
parents: 879
diff changeset
  1255
                self.original_name = orig
d780afc023ff 3718 plan_update_all needs to have an optional argument for the new BE name
Brock Pytlik <bpytlik@sun.com>
parents: 879
diff changeset
  1256
                self.destination_name = dest
d780afc023ff 3718 plan_update_all needs to have an optional argument for the new BE name
Brock Pytlik <bpytlik@sun.com>
parents: 879
diff changeset
  1257
d780afc023ff 3718 plan_update_all needs to have an optional argument for the new BE name
Brock Pytlik <bpytlik@sun.com>
parents: 879
diff changeset
  1258
        def __str__(self):
d780afc023ff 3718 plan_update_all needs to have an optional argument for the new BE name
Brock Pytlik <bpytlik@sun.com>
parents: 879
diff changeset
  1259
                d = {
d780afc023ff 3718 plan_update_all needs to have an optional argument for the new BE name
Brock Pytlik <bpytlik@sun.com>
parents: 879
diff changeset
  1260
                    "orig": self.original_name,
d780afc023ff 3718 plan_update_all needs to have an optional argument for the new BE name
Brock Pytlik <bpytlik@sun.com>
parents: 879
diff changeset
  1261
                    "dest": self.destination_name
d780afc023ff 3718 plan_update_all needs to have an optional argument for the new BE name
Brock Pytlik <bpytlik@sun.com>
parents: 879
diff changeset
  1262
                }
d780afc023ff 3718 plan_update_all needs to have an optional argument for the new BE name
Brock Pytlik <bpytlik@sun.com>
parents: 879
diff changeset
  1263
                return _("""\
d780afc023ff 3718 plan_update_all needs to have an optional argument for the new BE name
Brock Pytlik <bpytlik@sun.com>
parents: 879
diff changeset
  1264
A problem occurred while attempting to rename the boot environment
d780afc023ff 3718 plan_update_all needs to have an optional argument for the new BE name
Brock Pytlik <bpytlik@sun.com>
parents: 879
diff changeset
  1265
currently named %(orig)s to %(dest)s.""") % d
d780afc023ff 3718 plan_update_all needs to have an optional argument for the new BE name
Brock Pytlik <bpytlik@sun.com>
parents: 879
diff changeset
  1266
d780afc023ff 3718 plan_update_all needs to have an optional argument for the new BE name
Brock Pytlik <bpytlik@sun.com>
parents: 879
diff changeset
  1267
class UnableToMountBE(BEException):
d780afc023ff 3718 plan_update_all needs to have an optional argument for the new BE name
Brock Pytlik <bpytlik@sun.com>
parents: 879
diff changeset
  1268
        def __init__(self, be_name, be_dir):
d780afc023ff 3718 plan_update_all needs to have an optional argument for the new BE name
Brock Pytlik <bpytlik@sun.com>
parents: 879
diff changeset
  1269
                BEException.__init__(self)
d780afc023ff 3718 plan_update_all needs to have an optional argument for the new BE name
Brock Pytlik <bpytlik@sun.com>
parents: 879
diff changeset
  1270
                self.name = be_name
d780afc023ff 3718 plan_update_all needs to have an optional argument for the new BE name
Brock Pytlik <bpytlik@sun.com>
parents: 879
diff changeset
  1271
                self.mountpoint = be_dir
d780afc023ff 3718 plan_update_all needs to have an optional argument for the new BE name
Brock Pytlik <bpytlik@sun.com>
parents: 879
diff changeset
  1272
d780afc023ff 3718 plan_update_all needs to have an optional argument for the new BE name
Brock Pytlik <bpytlik@sun.com>
parents: 879
diff changeset
  1273
        def __str__(self):
d780afc023ff 3718 plan_update_all needs to have an optional argument for the new BE name
Brock Pytlik <bpytlik@sun.com>
parents: 879
diff changeset
  1274
                return _("Unable to mount %(name)s at %(mt)s") % \
d780afc023ff 3718 plan_update_all needs to have an optional argument for the new BE name
Brock Pytlik <bpytlik@sun.com>
parents: 879
diff changeset
  1275
                    {"name": self.name, "mt": self.mountpoint}
d780afc023ff 3718 plan_update_all needs to have an optional argument for the new BE name
Brock Pytlik <bpytlik@sun.com>
parents: 879
diff changeset
  1276
d780afc023ff 3718 plan_update_all needs to have an optional argument for the new BE name
Brock Pytlik <bpytlik@sun.com>
parents: 879
diff changeset
  1277
class BENameGivenOnDeadBE(BEException):
d780afc023ff 3718 plan_update_all needs to have an optional argument for the new BE name
Brock Pytlik <bpytlik@sun.com>
parents: 879
diff changeset
  1278
        def __init__(self, be_name):
d780afc023ff 3718 plan_update_all needs to have an optional argument for the new BE name
Brock Pytlik <bpytlik@sun.com>
parents: 879
diff changeset
  1279
                BEException.__init__(self)
d780afc023ff 3718 plan_update_all needs to have an optional argument for the new BE name
Brock Pytlik <bpytlik@sun.com>
parents: 879
diff changeset
  1280
                self.name = be_name
d780afc023ff 3718 plan_update_all needs to have an optional argument for the new BE name
Brock Pytlik <bpytlik@sun.com>
parents: 879
diff changeset
  1281
d780afc023ff 3718 plan_update_all needs to have an optional argument for the new BE name
Brock Pytlik <bpytlik@sun.com>
parents: 879
diff changeset
  1282
        def __str__(self):
d780afc023ff 3718 plan_update_all needs to have an optional argument for the new BE name
Brock Pytlik <bpytlik@sun.com>
parents: 879
diff changeset
  1283
                return _("""\
d780afc023ff 3718 plan_update_all needs to have an optional argument for the new BE name
Brock Pytlik <bpytlik@sun.com>
parents: 879
diff changeset
  1284
Naming a boot environment when operating on a non-live image is
d780afc023ff 3718 plan_update_all needs to have an optional argument for the new BE name
Brock Pytlik <bpytlik@sun.com>
parents: 879
diff changeset
  1285
not allowed.""")
926
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1286
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1287
917
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 884
diff changeset
  1288
class UnrecognizedOptionsToInfo(ApiException):
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 884
diff changeset
  1289
        def __init__(self, opts):
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 884
diff changeset
  1290
                ApiException.__init__(self)
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 884
diff changeset
  1291
                self._opts = opts
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 884
diff changeset
  1292
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 884
diff changeset
  1293
        def __str__(self):
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 884
diff changeset
  1294
                s = _("Info does not recognize the following options:")
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 884
diff changeset
  1295
                for o in self._opts:
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 884
diff changeset
  1296
                        s += _(" '") + str(o) + _("'")
eed22f430a9f 6902 api.info needs a "fast" flag or a way to pass a set of the information required
Brock Pytlik <bpytlik@sun.com>
parents: 884
diff changeset
  1297
                return s
926
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1298
941
e7bff46da54e 6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents: 926
diff changeset
  1299
class IncorrectIndexFileHash(ApiException):
e7bff46da54e 6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents: 926
diff changeset
  1300
        """This is used when the index hash value doesn't match the hash of the
e7bff46da54e 6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents: 926
diff changeset
  1301
        packages installed in the image."""
e7bff46da54e 6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents: 926
diff changeset
  1302
        pass
e7bff46da54e 6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents: 926
diff changeset
  1303
e7bff46da54e 6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents: 926
diff changeset
  1304
926
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1305
class PublisherError(ApiException):
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1306
        """Base exception class for all publisher exceptions."""
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1307
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1308
        def __init__(self, *args, **kwargs):
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1309
                ApiException.__init__(self, *args)
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1310
                if args:
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1311
                        self.data = args[0]
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1312
                else:
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1313
                        self.data = None
1516
8c950a3b4171 10485 move pkg(5) to Python 2.6
Rich Burridge <rich.burridge@sun.com>
parents: 1505
diff changeset
  1314
                self._args = kwargs
926
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1315
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1316
        def __str__(self):
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1317
                return str(self.data)
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1318
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1319
1087
293c0aa5f32e 8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents: 1076
diff changeset
  1320
class BadPublisherMetaRoot(PublisherError):
293c0aa5f32e 8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents: 1076
diff changeset
  1321
        """Used to indicate an operation on the publisher's meta_root failed
293c0aa5f32e 8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents: 1076
diff changeset
  1322
        because the meta_root is invalid."""
293c0aa5f32e 8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents: 1076
diff changeset
  1323
293c0aa5f32e 8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents: 1076
diff changeset
  1324
        def __str__(self):
293c0aa5f32e 8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents: 1076
diff changeset
  1325
                return _("Publisher meta_root '%(root)s' is invalid; unable "
293c0aa5f32e 8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents: 1076
diff changeset
  1326
                    "to complete operation: '%(op)s'.") % { "root": self.data,
1516
8c950a3b4171 10485 move pkg(5) to Python 2.6
Rich Burridge <rich.burridge@sun.com>
parents: 1505
diff changeset
  1327
                    "op": self._args.get("operation", None) }
1087
293c0aa5f32e 8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents: 1076
diff changeset
  1328
293c0aa5f32e 8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents: 1076
diff changeset
  1329
2028
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  1330
class BadPublisherAlias(PublisherError):
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  1331
        """Used to indicate that a publisher alias is not valid."""
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  1332
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  1333
        def __str__(self):
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  1334
                return _("'%s' is not a valid publisher alias.") % self.data
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  1335
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  1336
926
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1337
class BadPublisherPrefix(PublisherError):
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1338
        """Used to indicate that a publisher name is not valid."""
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1339
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1340
        def __str__(self):
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1341
                return _("'%s' is not a valid publisher name.") % self.data
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1342
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1343
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1344
class BadRepositoryAttributeValue(PublisherError):
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1345
        """Used to indicate that the specified repository attribute value is
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1346
        invalid."""
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1347
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1348
        def __str__(self):
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1349
                return _("'%(value)s' is not a valid value for repository "
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1350
                    "attribute '%(attribute)s'.") % {
1516
8c950a3b4171 10485 move pkg(5) to Python 2.6
Rich Burridge <rich.burridge@sun.com>
parents: 1505
diff changeset
  1351
                    "value": self._args["value"], "attribute": self.data }
926
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1352
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1353
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1354
class BadRepositoryCollectionType(PublisherError):
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1355
        """Used to indicate that the specified repository collection type is
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1356
        invalid."""
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1357
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1358
        def __init__(self, *args, **kwargs):
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1359
                PublisherError.__init__(self, *args, **kwargs)
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1360
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1361
        def __str__(self):
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1362
                return _("'%s' is not a valid repository collection type.") % \
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1363
                    self.data
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1364
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1365
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1366
class BadRepositoryURI(PublisherError):
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1367
        """Used to indicate that a repository URI is not syntactically valid."""
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1368
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1369
        def __str__(self):
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1370
                return _("'%s' is not a valid URI.") % self.data
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1371
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1372
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1373
class BadRepositoryURIPriority(PublisherError):
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1374
        """Used to indicate that the priority specified for a repository URI is
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1375
        not valid."""
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1376
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1377
        def __str__(self):
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1378
                return _("'%s' is not a valid URI priority; integer value "
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1379
                    "expected.") % self.data
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1380
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1381
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1382
class BadRepositoryURISortPolicy(PublisherError):
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1383
        """Used to indicate that the specified repository URI sort policy is
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1384
        invalid."""
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1385
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1386
        def __init__(self, *args, **kwargs):
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1387
                PublisherError.__init__(self, *args, **kwargs)
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1388
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1389
        def __str__(self):
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1390
                return _("'%s' is not a valid repository URI sort policy.") % \
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1391
                    self.data
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1392
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1393
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1394
class DisabledPublisher(PublisherError):
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1395
        """Used to indicate that an attempt to use a disabled publisher occurred
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1396
        during an operation."""
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1397
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1398
        def __str__(self):
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1399
                return _("Publisher '%s' is disabled and cannot be used for "
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1400
                    "packaging operations.") % self.data
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1401
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1402
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1403
class DuplicatePublisher(PublisherError):
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1404
        """Used to indicate that a publisher with the same name or alias already
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1405
        exists for an image."""
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1406
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1407
        def __str__(self):
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1408
                return _("A publisher with the same name or alias as '%s' "
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1409
                    "already exists.") % self.data
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1410
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1411
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1412
class DuplicateRepository(PublisherError):
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1413
        """Used to indicate that a repository with the same origin uris
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1414
        already exists for a publisher."""
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1415
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1416
        def __str__(self):
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1417
                return _("A repository with the same name or origin URIs "
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1418
                   "already exists for publisher '%s'.") % self.data
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1419
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1420
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1421
class DuplicateRepositoryMirror(PublisherError):
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1422
        """Used to indicate that a repository URI is already in use by another
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1423
        repository mirror."""
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1424
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1425
        def __str__(self):
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1426
                return _("Mirror '%s' already exists for the specified "
1504
265a1d6b86bd 9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents: 1461
diff changeset
  1427
                    "publisher.") % self.data
926
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1428
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1429
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1430
class DuplicateRepositoryOrigin(PublisherError):
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1431
        """Used to indicate that a repository URI is already in use by another
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1432
        repository origin."""
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1433
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1434
        def __str__(self):
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1435
                return _("Origin '%s' already exists for the specified "
1504
265a1d6b86bd 9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents: 1461
diff changeset
  1436
                    "publisher.") % self.data
265a1d6b86bd 9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents: 1461
diff changeset
  1437
265a1d6b86bd 9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents: 1461
diff changeset
  1438
265a1d6b86bd 9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents: 1461
diff changeset
  1439
class PublisherOriginRequired(PublisherError):
265a1d6b86bd 9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents: 1461
diff changeset
  1440
        """Used to indicate that the specified publisher must have at least one
265a1d6b86bd 9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents: 1461
diff changeset
  1441
        repository with at least one origin URI."""
265a1d6b86bd 9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents: 1461
diff changeset
  1442
265a1d6b86bd 9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents: 1461
diff changeset
  1443
        def __str__(self):
265a1d6b86bd 9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents: 1461
diff changeset
  1444
                return _("At least one origin is required for %s.  You must "
265a1d6b86bd 9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents: 1461
diff changeset
  1445
                "add a new origin before attempting to remove the specified "
265a1d6b86bd 9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents: 1461
diff changeset
  1446
                "origin(s).") % self.data
926
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1447
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1448
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1449
class RemovePreferredPublisher(PublisherError):
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1450
        """Used to indicate an attempt to remove the preferred publisher was
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1451
        made."""
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1452
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1453
        def __str__(self):
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1454
                return _("The preferred publisher cannot be removed.")
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1455
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1456
1505
cc598d70bbbe 4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents: 1504
diff changeset
  1457
class MoveRelativeToSelf(PublisherError):
cc598d70bbbe 4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents: 1504
diff changeset
  1458
        """Used to indicate an attempt to search a repo before or after itself"""
cc598d70bbbe 4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents: 1504
diff changeset
  1459
cc598d70bbbe 4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents: 1504
diff changeset
  1460
        def __str__(self):
cc598d70bbbe 4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents: 1504
diff changeset
  1461
                return _("Cannot search a repository before or after itself")
cc598d70bbbe 4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents: 1504
diff changeset
  1462
cc598d70bbbe 4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents: 1504
diff changeset
  1463
926
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1464
class SelectedRepositoryRemoval(PublisherError):
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1465
        """Used to indicate that an attempt to remove the selected repository
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1466
        for a publisher was made."""
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1467
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1468
        def __str__(self):
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1469
                return _("Cannot remove the selected repository for a "
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1470
                    "publisher.")
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1471
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1472
1256
921590dc232b 8863 error message unclear when trying to disable preferred publisher
Shawn Walker <srw@sun.com>
parents: 1254
diff changeset
  1473
class SetDisabledPublisherPreferred(PublisherError):
926
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1474
        """Used to indicate an attempt to set a disabled publisher as the
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1475
        preferred publisher was made."""
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1476
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1477
        def __str__(self):
996
31d152a5212b 7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 988
diff changeset
  1478
                return _("Publisher '%s' is disabled and cannot be set as the "
31d152a5212b 7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 988
diff changeset
  1479
                    "preferred publisher.") % self.data
926
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1480
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1481
1256
921590dc232b 8863 error message unclear when trying to disable preferred publisher
Shawn Walker <srw@sun.com>
parents: 1254
diff changeset
  1482
class SetPreferredPublisherDisabled(PublisherError):
921590dc232b 8863 error message unclear when trying to disable preferred publisher
Shawn Walker <srw@sun.com>
parents: 1254
diff changeset
  1483
        """Used to indicate that an attempt was made to set the preferred
921590dc232b 8863 error message unclear when trying to disable preferred publisher
Shawn Walker <srw@sun.com>
parents: 1254
diff changeset
  1484
        publisher as disabled."""
921590dc232b 8863 error message unclear when trying to disable preferred publisher
Shawn Walker <srw@sun.com>
parents: 1254
diff changeset
  1485
921590dc232b 8863 error message unclear when trying to disable preferred publisher
Shawn Walker <srw@sun.com>
parents: 1254
diff changeset
  1486
        def __str__(self):
921590dc232b 8863 error message unclear when trying to disable preferred publisher
Shawn Walker <srw@sun.com>
parents: 1254
diff changeset
  1487
                return _("The preferred publisher may not be disabled."
921590dc232b 8863 error message unclear when trying to disable preferred publisher
Shawn Walker <srw@sun.com>
parents: 1254
diff changeset
  1488
                    "  Another publisher must be set as the preferred "
921590dc232b 8863 error message unclear when trying to disable preferred publisher
Shawn Walker <srw@sun.com>
parents: 1254
diff changeset
  1489
                    "publisher before this publisher can be disabled.")
921590dc232b 8863 error message unclear when trying to disable preferred publisher
Shawn Walker <srw@sun.com>
parents: 1254
diff changeset
  1490
921590dc232b 8863 error message unclear when trying to disable preferred publisher
Shawn Walker <srw@sun.com>
parents: 1254
diff changeset
  1491
926
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1492
class UnknownLegalURI(PublisherError):
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1493
        """Used to indicate that no matching legal URI could be found using the
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1494
        provided criteria."""
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1495
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1496
        def __str__(self):
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1497
                return _("Unknown legal URI '%s'.") % self.data
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1498
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1499
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1500
class UnknownPublisher(PublisherError):
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1501
        """Used to indicate that no matching publisher could be found using the
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1502
        provided criteria."""
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1503
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1504
        def __str__(self):
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1505
                return _("Unknown publisher '%s'.") % self.data
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1506
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1507
1736
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1710
diff changeset
  1508
class UnknownRepositoryPublishers(PublisherError):
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1710
diff changeset
  1509
        """Used to indicate that one or more publisher prefixes are unknown by
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1710
diff changeset
  1510
        the specified repository."""
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1710
diff changeset
  1511
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1710
diff changeset
  1512
        def __init__(self, known=EmptyI, unknown=EmptyI, location=None,
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1710
diff changeset
  1513
            origins=EmptyI):
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1710
diff changeset
  1514
                ApiException.__init__(self)
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1710
diff changeset
  1515
                self.known = known
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1710
diff changeset
  1516
                self.location = location
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1710
diff changeset
  1517
                self.origins = origins
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1710
diff changeset
  1518
                self.unknown = unknown
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1710
diff changeset
  1519
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1710
diff changeset
  1520
        def __str__(self):
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1710
diff changeset
  1521
                if self.location:
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1710
diff changeset
  1522
                        return _("The repository at %(location)s does not "
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1710
diff changeset
  1523
                            "contain package data for %(unknown)s; only "
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1710
diff changeset
  1524
                            "%(known)s.\n\nThis is either because the "
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1710
diff changeset
  1525
                            "repository location is not valid, or because the "
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1710
diff changeset
  1526
                            "provided publisher does not match those known by "
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1710
diff changeset
  1527
                            "the repository.") % {
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1710
diff changeset
  1528
                            "unknown": ", ".join(self.unknown),
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1710
diff changeset
  1529
                            "location": self.location,
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1710
diff changeset
  1530
                            "known": ", ".join(self.known) }
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1710
diff changeset
  1531
                if self.origins:
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1710
diff changeset
  1532
                        return _("One or more of the repository origin(s) "
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1710
diff changeset
  1533
                            "listed below contains package data for "
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1710
diff changeset
  1534
                            "%(known)s; not %(unknown)s:\n\n%(origins)s\n\n"
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1710
diff changeset
  1535
                            "This is either because one of the repository "
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1710
diff changeset
  1536
                            "origins is not valid for this publisher, or "
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1710
diff changeset
  1537
                            "because the list of known publishers retrieved "
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1710
diff changeset
  1538
                            "from the repository origin does not match the "
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1710
diff changeset
  1539
                            "client.") % { "unknown": ", ".join(self.unknown),
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1710
diff changeset
  1540
                            "known": ", ".join(self.known),
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1710
diff changeset
  1541
                            "origins": "\n".join(str(o) for o in self.origins) }
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1710
diff changeset
  1542
                return _("The specified publisher repository does not "
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1710
diff changeset
  1543
                    "contain any package data for %(unknown)s; only "
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1710
diff changeset
  1544
                    "%(known)s.") % { "unknown": ", ".join(self.unknown),
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1710
diff changeset
  1545
                    "known": ", ".join(self.known) }
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1710
diff changeset
  1546
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1710
diff changeset
  1547
926
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1548
class UnknownRelatedURI(PublisherError):
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1549
        """Used to indicate that no matching related URI could be found using
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1550
        the provided criteria."""
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1551
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1552
        def __str__(self):
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1553
                return _("Unknown related URI '%s'.") % self.data
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1554
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1555
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1556
class UnknownRepository(PublisherError):
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1557
        """Used to indicate that no matching repository could be found using the
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1558
        provided criteria."""
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1559
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1560
        def __str__(self):
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1561
                return _("Unknown repository '%s'.") % self.data
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1562
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1563
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1564
class UnknownRepositoryMirror(PublisherError):
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1565
        """Used to indicate that a repository URI could not be found in the
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1566
        list of repository mirrors."""
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1567
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1568
        def __str__(self):
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1569
                return _("Unknown repository mirror '%s'.") % self.data
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1570
1431
62b6033670e4 10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents: 1372
diff changeset
  1571
class UnsupportedRepositoryOperation(PublisherError):
62b6033670e4 10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents: 1372
diff changeset
  1572
        """The publisher has no active repositories that support the
62b6033670e4 10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents: 1372
diff changeset
  1573
        requested operation."""
62b6033670e4 10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents: 1372
diff changeset
  1574
62b6033670e4 10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents: 1372
diff changeset
  1575
        def __init__(self, pub, operation):
62b6033670e4 10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents: 1372
diff changeset
  1576
                ApiException.__init__(self)
62b6033670e4 10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents: 1372
diff changeset
  1577
                self.data = None
62b6033670e4 10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents: 1372
diff changeset
  1578
                self.kwargs = None
62b6033670e4 10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents: 1372
diff changeset
  1579
                self.pub = pub
62b6033670e4 10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents: 1372
diff changeset
  1580
                self.op = operation
62b6033670e4 10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents: 1372
diff changeset
  1581
62b6033670e4 10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents: 1372
diff changeset
  1582
        def __str__(self):
62b6033670e4 10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents: 1372
diff changeset
  1583
                return _("Publisher '%s' has no repositories that support the"
1736
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1710
diff changeset
  1584
                    " '%s' operation.") % (self.pub, self.op)
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1710
diff changeset
  1585
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1710
diff changeset
  1586
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1710
diff changeset
  1587
class RepoPubConfigUnavailable(PublisherError):
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1710
diff changeset
  1588
        """Used to indicate that the specified repository does not provide
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1710
diff changeset
  1589
        publisher configuration information."""
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1710
diff changeset
  1590
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1710
diff changeset
  1591
        def __init__(self, location=None, pub=None):
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1710
diff changeset
  1592
                ApiException.__init__(self)
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1710
diff changeset
  1593
                self.location = location
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1710
diff changeset
  1594
                self.pub = pub
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1710
diff changeset
  1595
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1710
diff changeset
  1596
        def __str__(self):
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1710
diff changeset
  1597
                if not self.location and not self.pub:
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1710
diff changeset
  1598
                        return _("The specified package repository does not "
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1710
diff changeset
  1599
                            "provide publisher configuration information.")
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1710
diff changeset
  1600
                if self.location:
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1710
diff changeset
  1601
                        return _("The package repository at %s does not "
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1710
diff changeset
  1602
                            "provide publisher configuration information or "
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1710
diff changeset
  1603
                            "the information provided is incomplete.") % \
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1710
diff changeset
  1604
                            self.location
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1710
diff changeset
  1605
                return _("One of the package repository origins for %s does "
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1710
diff changeset
  1606
                    "not provide publisher configuration information or the "
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1710
diff changeset
  1607
                    "information provided is incomplete.") % self.pub
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1710
diff changeset
  1608
926
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1609
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1610
class UnknownRepositoryOrigin(PublisherError):
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1611
        """Used to indicate that a repository URI could not be found in the
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1612
        list of repository origins."""
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1613
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1614
        def __str__(self):
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1615
                return _("Unknown repository origin '%s'") % self.data
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1616
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1617
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1618
class UnsupportedRepositoryURI(PublisherError):
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1619
        """Used to indicate that the specified repository URI uses an
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1620
        unsupported scheme."""
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1621
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1622
        def __str__(self):
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1623
                if self.data:
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1624
                        scheme = urlparse.urlsplit(self.data,
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1625
                            allow_fragments=0)[0]
2144
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2126
diff changeset
  1626
                        return _("The URI '%(uri)s' uses the unsupported "
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2126
diff changeset
  1627
                            "scheme '%(scheme)s'.  Supported schemes are "
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2126
diff changeset
  1628
                            "file://, http://, and https://.") % {
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2126
diff changeset
  1629
                            "uri": self.data, "scheme": scheme }
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2126
diff changeset
  1630
                return _("The specified URI uses an unsupported scheme."
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2126
diff changeset
  1631
                    "  Supported schemes are: file://, http://, and https://.")
926
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1632
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1633
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1634
class UnsupportedRepositoryURIAttribute(PublisherError):
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1635
        """Used to indicate that the specified repository URI attribute is not
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1636
        supported for the URI's scheme."""
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1637
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1638
        def __str__(self):
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1639
                return _("'%(attr)s' is not supported for '%(scheme)s'.") % {
1516
8c950a3b4171 10485 move pkg(5) to Python 2.6
Rich Burridge <rich.burridge@sun.com>
parents: 1505
diff changeset
  1640
                    "attr": self.data, "scheme": self._args["scheme"] }
926
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1641
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1642
2026
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1643
class SigningException(ApiException):
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1644
        """The base class for exceptions related to manifest signing."""
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1645
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1646
        def __init__(self, pfmri=None, sig=None):
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1647
                self.pfmri = pfmri
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1648
                self.sig = sig
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1649
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1650
        # This string method is used by subclasses to fill in the details
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1651
        # about the package and signature involved.
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1652
        def __str__(self):
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1653
                if self.pfmri:
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1654
                        if self.sig:
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1655
                                return _("The relevant signature action is "
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1656
                                    "found in %(pfmri)s and has a hash of "
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1657
                                    "%(hsh)s") % \
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1658
                                    {"pfmri": self.pfmri, "hsh": self.sig.hash}
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1659
                        return _("The package involved is:%s") % self.pfmri
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1660
                if self.sig:
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1661
                        return _("The relevant signature action's value "
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1662
                            "attribute is %s") % self.sig.attrs["value"]
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1663
                return ""
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1664
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1665
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1666
class BadFileFormat(SigningException):
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1667
        """Exception used when a key, certificate or CRL file is not in a
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1668
        recognized format."""
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1669
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1670
        def __init__(self, txt):
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1671
                self.txt = txt
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1672
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1673
        def __str__(self):
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1674
                return self.txt
2200
155eda704b2f 16279 Need a way to revert certain editable files to a as-installed state
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents: 2197
diff changeset
  1675
2026
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1676
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1677
class UnsupportedSignatureVersion(SigningException):
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1678
        """Exception used when a signature reports a version which this version
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1679
        of pkg(5) doesn't support."""
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1680
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1681
        def __init__(self, version, *args, **kwargs):
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1682
                SigningException.__init__(self, *args, **kwargs)
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1683
                self.version = version
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1684
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1685
        def __str__(self):
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1686
                return _("The signature action %(act)s was made using a "
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1687
                    "version (%(ver)s) this version of pkg(5) doesn't "
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1688
                    "understand.") % {"act":self.sig, "ver":self.version}
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1689
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1690
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1691
class CertificateException(SigningException):
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1692
        """Base class for exceptions encountered while establishing the chain
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1693
        of trust."""
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1694
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1695
        def __init__(self, cert, pfmri=None):
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1696
                SigningException.__init__(self, pfmri)
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1697
                self.cert = cert
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1698
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1699
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1700
class ModifiedCertificateException(CertificateException):
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1701
        """Exception used when a certificate does not match its expected hash
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1702
        value."""
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1703
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1704
        def __init__(self, cert, path, pfmri=None):
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1705
                CertificateException.__init__(self, cert, pfmri)
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1706
                self.path = path
2200
155eda704b2f 16279 Need a way to revert certain editable files to a as-installed state
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents: 2197
diff changeset
  1707
2026
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1708
        def __str__(self):
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1709
                return _("Certificate %s has been modified on disk. Its hash "
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1710
                    "value is not what was expected.") % self.path
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1711
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1712
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1713
class UntrustedSelfSignedCert(CertificateException):
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1714
        """Exception used when a chain of trust is rooted in an untrusted
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1715
        self-signed certificate."""
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1716
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1717
        def __str__(self):
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1718
                return _("Chain was rooted in an untrusted self-signed "
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1719
                    "certificate.\n") + CertificateException.__str__(self)
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1720
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1721
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1722
class BrokenChain(CertificateException):
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1723
        """Exception used when a chain of trust can not be established between
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1724
        the leaf certificate and a trust anchor."""
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1725
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1726
        def __init__(self, cert, cert_exceptions, *args, **kwargs):
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1727
                CertificateException.__init__(self, cert, *args, **kwargs)
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1728
                self.ext_exs = cert_exceptions
2200
155eda704b2f 16279 Need a way to revert certain editable files to a as-installed state
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents: 2197
diff changeset
  1729
2026
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1730
        def __str__(self):
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1731
                s = ""
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1732
                if self.ext_exs:
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1733
                        s = _("The following problems were encountered:\n") + \
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1734
                        "\n".join([str(e) for e in self.ext_exs])
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1735
                return _("The certificate which issued this "
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1736
                    "certificate:%(subj)s could not be found. The issuer "
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1737
                    "is:%(issuer)s\n") % {"subj":self.cert.get_subject(),
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1738
                    "issuer":self.cert.get_issuer()} + s + \
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1739
                    CertificateException.__str__(self)
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1740
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1741
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1742
class RevokedCertificate(CertificateException):
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1743
        """Exception used when a chain of trust contains a revoked certificate.
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1744
        """
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1745
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1746
        def __init__(self, cert, reason, *args, **kwargs):
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1747
                CertificateException.__init__(self, cert, *args, **kwargs)
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1748
                self.reason = reason
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1749
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1750
        def __str__(self):
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1751
                return _("This certificate was revoked:%(cert)s for this "
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1752
                    "reason:\n%(reason)s") % {"cert":self.cert.get_subject(),
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1753
                    "reason":self.reason} + CertificateException.__str__(self)
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1754
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1755
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1756
class UnverifiedSignature(SigningException):
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1757
        """Exception used when a signature could not be verified by the
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1758
        expected certificate."""
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1759
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1760
        def __init__(self, sig, reason, pfmri=None):
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1761
                SigningException.__init__(self, pfmri)
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1762
                self.sig = sig
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1763
                self.reason = reason
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1764
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1765
        def __str__(self):
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1766
                if self.pfmri:
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1767
                        return _("A signature in %(pfmri)s could not be "
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1768
                            "verified for "
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1769
                            "this reason:\n%(reason)s\nThe signature's hash is "
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1770
                            "%(hash)s") % {"pfmri": self.pfmri,
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1771
                            "reason": self.reason,
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1772
                            "hash": self.sig.hash}
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1773
                return _("The signature with this signature value:\n"
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1774
                    "%(sigval)s\n could not be verified for this reason:\n"
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1775
                    "%(reason)s\n") % {"reason": self.reason,
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1776
                    "sigval": self.sig.attrs["value"]}
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1777
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1778
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1779
class RequiredSignaturePolicyException(SigningException):
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1780
        """Exception used when signatures were required but none were found."""
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1781
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1782
        def __init__(self, pub, pfmri=None):
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1783
                SigningException.__init__(self, pfmri)
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1784
                self.pub = pub
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1785
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1786
        def __str__(self):
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1787
                pub_str = self.pub.prefix
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1788
                if self.pfmri:
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1789
                        return _("The policy for %(pub_str)s requires "
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1790
                            "signatures to be present but no signature was "
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1791
                            "found in %(fmri_str)s.") % \
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1792
                            {"pub_str": pub_str, "fmri_str": self.pfmri}
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1793
                return _("The policy for %(pub_str)s requires signatures to be "
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1794
                    "present but no signature was found.") % {
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1795
                    "pub_str": pub_str}
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1796
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1797
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1798
class MissingRequiredNamesException(SigningException):
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1799
        """Exception used when a signature policy required names to be seen
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1800
        which weren't seen."""
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1801
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1802
        def __init__(self, pub, missing_names, pfmri=None):
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1803
                SigningException.__init__(self, pfmri)
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1804
                self.pub = pub
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1805
                self.missing_names = missing_names
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1806
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1807
        def __str__(self):
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1808
                pub_str = self.pub.prefix
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1809
                if self.pfmri:
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1810
                        return _("The policy for %(pub_str)s requires certain "
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1811
                            "CNs to be seen in a chain of trust. The following "
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1812
                            "required names couldn't be found for this "
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1813
                            "package:%(fmri_str)s.\n%(missing)s") % \
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1814
                            {"pub_str": pub_str, "fmri_str": self.pfmri,
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1815
                            "missing": "\n".join(self.missing_names)}
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1816
                return _("The policy for %(pub_str)s requires certain CNs to "
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1817
                    "be seen in a chain of trust. The following required names "
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1818
                    "couldn't be found.\n%(missing)s") % {"pub_str": pub_str,
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1819
                    "missing": "\n".join(self.missing_names)}
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1820
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1821
class UnsupportedCriticalExtension(SigningException):
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1822
        """Exception used when a certificate in the chain of trust uses a
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1823
        critical extension pkg5 doesn't understand."""
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1824
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1825
        def __init__(self, cert, ext):
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1826
                SigningException.__init__(self)
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1827
                self.cert = cert
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1828
                self.ext = ext
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1829
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1830
        def __str__(self):
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1831
                return _("The certificate whose subject is %(cert)s could not "
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1832
                    "be verified "
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1833
                    "because it uses a critical extension that pkg5 cannot "
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1834
                    "handle yet.\nExtension name:%(name)s\nExtension "
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1835
                    "value:%(val)s") % {"cert": self.cert.get_subject(),
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1836
                    "name":self.ext.get_name(), "val":self.ext.get_value()}
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1837
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1838
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1839
class InvalidPropertyValue(ApiException):
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1840
        """Exception used when a property was set to an invalid value."""
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1841
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1842
        def __init__(self, s):
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1843
                ApiException.__init__(self)
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1844
                self.str = s
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1845
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1846
        def __str__(self):
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1847
                return self.str
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1848
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  1849
926
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1850
class CertificateError(ApiException):
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1851
        """Base exception class for all certificate exceptions."""
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1852
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1853
        def __init__(self, *args, **kwargs):
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1854
                ApiException.__init__(self, *args)
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1855
                if args:
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1856
                        self.data = args[0]
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1857
                else:
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1858
                        self.data = None
1516
8c950a3b4171 10485 move pkg(5) to Python 2.6
Rich Burridge <rich.burridge@sun.com>
parents: 1505
diff changeset
  1859
                self._args = kwargs
926
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1860
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1861
        def __str__(self):
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1862
                return str(self.data)
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1863
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1864
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1865
class ExpiredCertificate(CertificateError):
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1866
        """Used to indicate that a certificate has expired."""
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1867
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1868
        def __str__(self):
1516
8c950a3b4171 10485 move pkg(5) to Python 2.6
Rich Burridge <rich.burridge@sun.com>
parents: 1505
diff changeset
  1869
                publisher = self._args.get("publisher", None)
8c950a3b4171 10485 move pkg(5) to Python 2.6
Rich Burridge <rich.burridge@sun.com>
parents: 1505
diff changeset
  1870
                uri = self._args.get("uri", None)
926
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1871
                if publisher:
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1872
                        if uri:
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1873
                                return _("Certificate '%(cert)s' for publisher "
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1874
                                    "'%(pub)s' needed to access '%(uri)s', "
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1875
                                    "has expired.  Please install a valid "
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1876
                                    "certificate.") % { "cert": self.data,
1130
18c4f3ce0c8c 9223 CertificateErrors during install or update can result in traceback
Shawn Walker <srw@sun.com>
parents: 1100
diff changeset
  1877
                                    "pub": publisher, "uri": uri }
926
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1878
                        return _("Certificate '%(cert)s' for publisher "
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1879
                            "'%(pub)s', has expired.  Please install a valid "
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1880
                            "certificate.") % { "cert": self.data,
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1881
                            "pub": publisher }
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1882
                if uri:
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1883
                        return _("Certificate '%(cert)s', needed to access "
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1884
                            "'%(uri)s', has expired.  Please install a valid "
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1885
                            "certificate.") % { "cert": self.data, "uri": uri }
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1886
                return _("Certificate '%s' has expired.  Please install a "
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1887
                    "valid certificate.") % self.data
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1888
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1889
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1890
class ExpiringCertificate(CertificateError):
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1891
        """Used to indicate that a certificate has expired."""
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1892
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1893
        def __str__(self):
1516
8c950a3b4171 10485 move pkg(5) to Python 2.6
Rich Burridge <rich.burridge@sun.com>
parents: 1505
diff changeset
  1894
                publisher = self._args.get("publisher", None)
8c950a3b4171 10485 move pkg(5) to Python 2.6
Rich Burridge <rich.burridge@sun.com>
parents: 1505
diff changeset
  1895
                uri = self._args.get("uri", None)
8c950a3b4171 10485 move pkg(5) to Python 2.6
Rich Burridge <rich.burridge@sun.com>
parents: 1505
diff changeset
  1896
                days = self._args.get("days", 0)
926
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1897
                if publisher:
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1898
                        if uri:
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1899
                                return _("Certificate '%(cert)s' for publisher "
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1900
                                    "'%(pub)s', needed to access '%(uri)s', "
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1901
                                    "will expire in '%(days)s' days.") % {
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1902
                                    "cert": self.data, "pub": publisher,
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1903
                                    "uri": uri, "days": days }
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1904
                        return _("Certificate '%(cert)s' for publisher "
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1905
                            "'%(pub)s' will expire in '%(days)s' days.") % {
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1906
                            "cert": self.data, "pub": publisher, "days": days }
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1907
                if uri:
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1908
                        return _("Certificate '%(cert)s', needed to access "
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1909
                            "'%(uri)s', will expire in '%(days)s' days.") % {
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1910
                            "cert": self.data, "uri": uri, "days": days }
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1911
                return _("Certificate '%(cert)s' will expire in "
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1912
                    "'%(days)s' days.") % { "cert": self.data, "days": days }
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1913
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1914
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1915
class InvalidCertificate(CertificateError):
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1916
        """Used to indicate that a certificate is invalid."""
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1917
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1918
        def __str__(self):
1516
8c950a3b4171 10485 move pkg(5) to Python 2.6
Rich Burridge <rich.burridge@sun.com>
parents: 1505
diff changeset
  1919
                publisher = self._args.get("publisher", None)
8c950a3b4171 10485 move pkg(5) to Python 2.6
Rich Burridge <rich.burridge@sun.com>
parents: 1505
diff changeset
  1920
                uri = self._args.get("uri", None)
926
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1921
                if publisher:
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1922
                        if uri:
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1923
                                return _("Certificate '%(cert)s' for publisher "
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1924
                                    "'%(pub)s', needed to access '%(uri)s', is "
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1925
                                    "invalid.") % { "cert": self.data,
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1926
                                    "pub": publisher, "uri": uri }
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1927
                        return _("Certificate '%(cert)s' for publisher "
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1928
                            "'%(pub)s' is invalid.") % { "cert": self.data,
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1929
                            "pub": publisher }
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1930
                if uri:
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1931
                        return _("Certificate '%(cert)s' needed to access "
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1932
                            "'%(uri)s' is invalid.") % { "cert": self.data,
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1933
                            "uri": uri }
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1934
                return _("Invalid certificate '%s'.") % self.data
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1935
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1936
1254
28871b08d49c 8463 missing key file error message says certificate is missing
Shawn Walker <srw@sun.com>
parents: 1191
diff changeset
  1937
class NoSuchKey(CertificateError):
28871b08d49c 8463 missing key file error message says certificate is missing
Shawn Walker <srw@sun.com>
parents: 1191
diff changeset
  1938
        """Used to indicate that a key could not be found."""
28871b08d49c 8463 missing key file error message says certificate is missing
Shawn Walker <srw@sun.com>
parents: 1191
diff changeset
  1939
28871b08d49c 8463 missing key file error message says certificate is missing
Shawn Walker <srw@sun.com>
parents: 1191
diff changeset
  1940
        def __str__(self):
1516
8c950a3b4171 10485 move pkg(5) to Python 2.6
Rich Burridge <rich.burridge@sun.com>
parents: 1505
diff changeset
  1941
                publisher = self._args.get("publisher", None)
8c950a3b4171 10485 move pkg(5) to Python 2.6
Rich Burridge <rich.burridge@sun.com>
parents: 1505
diff changeset
  1942
                uri = self._args.get("uri", None)
1254
28871b08d49c 8463 missing key file error message says certificate is missing
Shawn Walker <srw@sun.com>
parents: 1191
diff changeset
  1943
                if publisher:
28871b08d49c 8463 missing key file error message says certificate is missing
Shawn Walker <srw@sun.com>
parents: 1191
diff changeset
  1944
                        if uri:
28871b08d49c 8463 missing key file error message says certificate is missing
Shawn Walker <srw@sun.com>
parents: 1191
diff changeset
  1945
                                return _("Unable to locate key '%(key)s' for "
28871b08d49c 8463 missing key file error message says certificate is missing
Shawn Walker <srw@sun.com>
parents: 1191
diff changeset
  1946
                                    "publisher '%(pub)s' needed to access "
28871b08d49c 8463 missing key file error message says certificate is missing
Shawn Walker <srw@sun.com>
parents: 1191
diff changeset
  1947
                                    "'%(uri)s'.") % { "key": self.data,
28871b08d49c 8463 missing key file error message says certificate is missing
Shawn Walker <srw@sun.com>
parents: 1191
diff changeset
  1948
                                    "pub": publisher, "uri": uri }
28871b08d49c 8463 missing key file error message says certificate is missing
Shawn Walker <srw@sun.com>
parents: 1191
diff changeset
  1949
                        return _("Unable to locate key '%(key)s' for publisher "
28871b08d49c 8463 missing key file error message says certificate is missing
Shawn Walker <srw@sun.com>
parents: 1191
diff changeset
  1950
                            "'%(pub)s'.") % { "key": self.data, "pub": publisher
28871b08d49c 8463 missing key file error message says certificate is missing
Shawn Walker <srw@sun.com>
parents: 1191
diff changeset
  1951
                            }
28871b08d49c 8463 missing key file error message says certificate is missing
Shawn Walker <srw@sun.com>
parents: 1191
diff changeset
  1952
                if uri:
28871b08d49c 8463 missing key file error message says certificate is missing
Shawn Walker <srw@sun.com>
parents: 1191
diff changeset
  1953
                        return _("Unable to locate key '%(key)s' needed to "
28871b08d49c 8463 missing key file error message says certificate is missing
Shawn Walker <srw@sun.com>
parents: 1191
diff changeset
  1954
                            "access '%(uri)s'.") % { "key": self.data,
28871b08d49c 8463 missing key file error message says certificate is missing
Shawn Walker <srw@sun.com>
parents: 1191
diff changeset
  1955
                            "uri": uri }
28871b08d49c 8463 missing key file error message says certificate is missing
Shawn Walker <srw@sun.com>
parents: 1191
diff changeset
  1956
                return _("Unable to locate key '%s'.") % self.data
28871b08d49c 8463 missing key file error message says certificate is missing
Shawn Walker <srw@sun.com>
parents: 1191
diff changeset
  1957
28871b08d49c 8463 missing key file error message says certificate is missing
Shawn Walker <srw@sun.com>
parents: 1191
diff changeset
  1958
926
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1959
class NoSuchCertificate(CertificateError):
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1960
        """Used to indicate that a certificate could not be found."""
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1961
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1962
        def __str__(self):
1516
8c950a3b4171 10485 move pkg(5) to Python 2.6
Rich Burridge <rich.burridge@sun.com>
parents: 1505
diff changeset
  1963
                publisher = self._args.get("publisher", None)
8c950a3b4171 10485 move pkg(5) to Python 2.6
Rich Burridge <rich.burridge@sun.com>
parents: 1505
diff changeset
  1964
                uri = self._args.get("uri", None)
926
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1965
                if publisher:
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1966
                        if uri:
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1967
                                return _("Unable to locate certificate "
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1968
                                    "'%(cert)s' for publisher '%(pub)s' needed "
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1969
                                    "to access '%(uri)s'.") % {
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1970
                                    "cert": self.data, "pub": publisher,
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1971
                                    "uri": uri }
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1972
                        return _("Unable to locate certificate '%(cert)s' for "
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1973
                            "publisher '%(pub)s'.") % { "cert": self.data,
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1974
                            "pub": publisher }
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1975
                if uri:
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1976
                        return _("Unable to locate certificate '%(cert)s' "
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1977
                            "needed to access '%(uri)s'.") % {
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1978
                            "cert": self.data, "uri": uri }
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1979
                return _("Unable to locate certificate '%s'.") % self.data
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1980
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1981
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1982
class NotYetValidCertificate(CertificateError):
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1983
        """Used to indicate that a certificate is not yet valid (future
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1984
        effective date)."""
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1985
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1986
        def __str__(self):
1516
8c950a3b4171 10485 move pkg(5) to Python 2.6
Rich Burridge <rich.burridge@sun.com>
parents: 1505
diff changeset
  1987
                publisher = self._args.get("publisher", None)
8c950a3b4171 10485 move pkg(5) to Python 2.6
Rich Burridge <rich.burridge@sun.com>
parents: 1505
diff changeset
  1988
                uri = self._args.get("uri", None)
926
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1989
                if publisher:
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1990
                        if uri:
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1991
                                return _("Certificate '%(cert)s' for publisher "
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1992
                                    "'%(pub)s', needed to access '%(uri)s', "
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1993
                                    "has a future effective date.") % {
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1994
                                    "cert": self.data, "pub": publisher,
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1995
                                    "uri": uri }
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1996
                        return _("Certificate '%(cert)s' for publisher "
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1997
                            "'%(pub)s' has a future effective date.") % {
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1998
                            "cert": self.data, "pub": publisher }
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  1999
                if uri:
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  2000
                        return _("Certificate '%(cert)s' needed to access "
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  2001
                            "'%(uri)s' has a future effective date.") % {
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  2002
                            "cert": self.data, "uri": uri }
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  2003
                return _("Certificate '%s' has a future effective date.") % \
6ee411c9026a 5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents: 922
diff changeset
  2004
                    self.data
941
e7bff46da54e 6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents: 926
diff changeset
  2005
e7bff46da54e 6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents: 926
diff changeset
  2006
e7bff46da54e 6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents: 926
diff changeset
  2007
class ServerReturnError(ApiException):
2028
b2c674e6ee28 16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents: 2026
diff changeset
  2008
        """This exception is used when the server returns a line which the
1100
22a8b08d460a 7364 documentation and code comments needed for fix for 6175
Brock Pytlik <bpytlik@sun.com>
parents: 1087
diff changeset
  2009
        client cannot parse correctly."""
22a8b08d460a 7364 documentation and code comments needed for fix for 6175
Brock Pytlik <bpytlik@sun.com>
parents: 1087
diff changeset
  2010
941
e7bff46da54e 6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents: 926
diff changeset
  2011
        def __init__(self, line):
e7bff46da54e 6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents: 926
diff changeset
  2012
                ApiException.__init__(self)
e7bff46da54e 6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents: 926
diff changeset
  2013
                self.line = line
e7bff46da54e 6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents: 926
diff changeset
  2014
e7bff46da54e 6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents: 926
diff changeset
  2015
        def __str__(self):
1027
e827313523d8 7774 image history discarded when bootenv operations fail or succeed
Shawn Walker <srw@sun.com>
parents: 1019
diff changeset
  2016
                return _("Gave a bad response:%s") % self.line
1337
52e101b7cc31 9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents: 1335
diff changeset
  2017
1352
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
  2018
1337
52e101b7cc31 9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents: 1335
diff changeset
  2019
class MissingFileArgumentException(ApiException):
52e101b7cc31 9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents: 1335
diff changeset
  2020
        """This exception is used when a file was given as an argument but
52e101b7cc31 9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents: 1335
diff changeset
  2021
        no such file could be found."""
52e101b7cc31 9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents: 1335
diff changeset
  2022
        def __init__(self, path):
52e101b7cc31 9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents: 1335
diff changeset
  2023
                ApiException.__init__(self)
52e101b7cc31 9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents: 1335
diff changeset
  2024
                self.path = path
52e101b7cc31 9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents: 1335
diff changeset
  2025
52e101b7cc31 9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents: 1335
diff changeset
  2026
        def __str__(self):
52e101b7cc31 9293 there should be a way to automatically infer/audit package dependencies for a package
Brock Pytlik <bpytlik@sun.com>
parents: 1335
diff changeset
  2027
                return _("Could not find %s") % self.path
1352
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
  2028
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
  2029
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
  2030
class ManifestError(ApiException):
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
  2031
        """Base exception class for all manifest exceptions."""
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
  2032
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
  2033
        def __init__(self, *args, **kwargs):
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
  2034
                ApiException.__init__(self, *args, **kwargs)
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
  2035
                if args:
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
  2036
                        self.data = args[0]
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
  2037
                else:
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
  2038
                        self.data = None
1516
8c950a3b4171 10485 move pkg(5) to Python 2.6
Rich Burridge <rich.burridge@sun.com>
parents: 1505
diff changeset
  2039
                self._args = kwargs
1352
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
  2040
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
  2041
        def __str__(self):
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
  2042
                return str(self.data)
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
  2043
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
  2044
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
  2045
class BadManifestSignatures(ManifestError):
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
  2046
        """Used to indicate that the Manifest signatures are not valid."""
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
  2047
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
  2048
        def __str__(self):
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
  2049
                if self.data:
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
  2050
                        return _("The signature data for the manifest of the "
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
  2051
                            "'%s' package is not valid.") % self.data
5c92c9d342ef 11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents: 1337
diff changeset
  2052
                return _("The signature data for the manifest is not valid.")
1370
face1fe579ab 11400 image objects should always have a root
Brock Pytlik <bpytlik@sun.com>
parents: 1369
diff changeset
  2053
1736
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1710
diff changeset
  2054
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1710
diff changeset
  2055
class UnknownErrors(ApiException):
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1710
diff changeset
  2056
        """Used to indicate that one or more exceptions were encountered.
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1710
diff changeset
  2057
        This is intended for use with where multiple exceptions for multiple
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1710
diff changeset
  2058
        files are encountered and the errors have been condensed into a
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1710
diff changeset
  2059
        single exception and re-raised.  One example case would be rmtree()
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1710
diff changeset
  2060
        with shutil.Error."""
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1710
diff changeset
  2061
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1710
diff changeset
  2062
        def __init__(self, msg):
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1710
diff changeset
  2063
                ApiException.__init__(self)
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1710
diff changeset
  2064
                self.__msg = msg
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1710
diff changeset
  2065
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1710
diff changeset
  2066
        def __str__(self):
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1710
diff changeset
  2067
                return self.__msg
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1710
diff changeset
  2068
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1710
diff changeset
  2069
1370
face1fe579ab 11400 image objects should always have a root
Brock Pytlik <bpytlik@sun.com>
parents: 1369
diff changeset
  2070
# Image creation exceptions
face1fe579ab 11400 image objects should always have a root
Brock Pytlik <bpytlik@sun.com>
parents: 1369
diff changeset
  2071
class ImageCreationException(ApiException):
face1fe579ab 11400 image objects should always have a root
Brock Pytlik <bpytlik@sun.com>
parents: 1369
diff changeset
  2072
        def __init__(self, path):
1736
727dda1e7968 11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents: 1710
diff changeset
  2073
                ApiException.__init__(self)
1370
face1fe579ab 11400 image objects should always have a root
Brock Pytlik <bpytlik@sun.com>
parents: 1369
diff changeset
  2074
                self.path = path
face1fe579ab 11400 image objects should always have a root
Brock Pytlik <bpytlik@sun.com>
parents: 1369
diff changeset
  2075
face1fe579ab 11400 image objects should always have a root
Brock Pytlik <bpytlik@sun.com>
parents: 1369
diff changeset
  2076
        def __str__(self):
face1fe579ab 11400 image objects should always have a root
Brock Pytlik <bpytlik@sun.com>
parents: 1369
diff changeset
  2077
                raise NotImplementedError()
face1fe579ab 11400 image objects should always have a root
Brock Pytlik <bpytlik@sun.com>
parents: 1369
diff changeset
  2078
face1fe579ab 11400 image objects should always have a root
Brock Pytlik <bpytlik@sun.com>
parents: 1369
diff changeset
  2079
face1fe579ab 11400 image objects should always have a root
Brock Pytlik <bpytlik@sun.com>
parents: 1369
diff changeset
  2080
class ImageAlreadyExists(ImageCreationException):
face1fe579ab 11400 image objects should always have a root
Brock Pytlik <bpytlik@sun.com>
parents: 1369
diff changeset
  2081
        def __str__(self):
face1fe579ab 11400 image objects should always have a root
Brock Pytlik <bpytlik@sun.com>
parents: 1369
diff changeset
  2082
                return _("there is already an image at: %s.\nTo override, use "
face1fe579ab 11400 image objects should always have a root
Brock Pytlik <bpytlik@sun.com>
parents: 1369
diff changeset
  2083
                    "the -f (force) option.") % self.path
face1fe579ab 11400 image objects should always have a root
Brock Pytlik <bpytlik@sun.com>
parents: 1369
diff changeset
  2084
face1fe579ab 11400 image objects should always have a root
Brock Pytlik <bpytlik@sun.com>
parents: 1369
diff changeset
  2085
2097
068cc63b4d6e 17055 image configuration should use pkg.config classes
Shawn Walker <shawn.walker@oracle.com>
parents: 2089
diff changeset
  2086
class ImageCfgEmptyError(ApiException):
068cc63b4d6e 17055 image configuration should use pkg.config classes
Shawn Walker <shawn.walker@oracle.com>
parents: 2089
diff changeset
  2087
        """Used to indicate that the image configuration is invalid."""
068cc63b4d6e 17055 image configuration should use pkg.config classes
Shawn Walker <shawn.walker@oracle.com>
parents: 2089
diff changeset
  2088
068cc63b4d6e 17055 image configuration should use pkg.config classes
Shawn Walker <shawn.walker@oracle.com>
parents: 2089
diff changeset
  2089
        def __str__(self):
2144
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2126
diff changeset
  2090
                return _("The configuration data for the image rooted at "
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2126
diff changeset
  2091
                    "%s is empty or missing.") % self.data
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2126
diff changeset
  2092
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2126
diff changeset
  2093
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2126
diff changeset
  2094
class UnsupportedImageError(ApiException):
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2126
diff changeset
  2095
        """Used to indicate that the image at a specific location is in a format
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2126
diff changeset
  2096
        not supported by this version of the pkg(5) API."""
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2126
diff changeset
  2097
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2126
diff changeset
  2098
        def __init__(self, path):
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2126
diff changeset
  2099
                ApiException.__init__(self)
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2126
diff changeset
  2100
                self.path = path
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2126
diff changeset
  2101
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2126
diff changeset
  2102
        def __str__(self):
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2126
diff changeset
  2103
                return _("The image rooted at %s is invalid or is not "
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2126
diff changeset
  2104
                    "supported by this version of the packaging system.") % \
2ac203b826ab 7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents: 2126
diff changeset
  2105
                    self.path
2097
068cc63b4d6e 17055 image configuration should use pkg.config classes
Shawn Walker <shawn.walker@oracle.com>
parents: 2089
diff changeset
  2106
068cc63b4d6e 17055 image configuration should use pkg.config classes
Shawn Walker <shawn.walker@oracle.com>
parents: 2089
diff changeset
  2107
1370
face1fe579ab 11400 image objects should always have a root
Brock Pytlik <bpytlik@sun.com>
parents: 1369
diff changeset
  2108
class CreatingImageInNonEmptyDir(ImageCreationException):
face1fe579ab 11400 image objects should always have a root
Brock Pytlik <bpytlik@sun.com>
parents: 1369
diff changeset
  2109
        def __str__(self):
face1fe579ab 11400 image objects should always have a root
Brock Pytlik <bpytlik@sun.com>
parents: 1369
diff changeset
  2110
                return _("the specified image path is not empty: %s.\nTo "
face1fe579ab 11400 image objects should always have a root
Brock Pytlik <bpytlik@sun.com>
parents: 1369
diff changeset
  2111
                    "override, use the -f (force) option.") % self.path
2026
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  2112
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  2113
2073
9fcacc9e5eaa 16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents: 2034
diff changeset
  2114
def _convert_error(e, ignored_errors=EmptyI):
9fcacc9e5eaa 16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents: 2034
diff changeset
  2115
        """Converts the provided exception into an ApiException equivalent if
9fcacc9e5eaa 16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents: 2034
diff changeset
  2116
        possible.  Returns a new exception object if converted or the original
9fcacc9e5eaa 16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents: 2034
diff changeset
  2117
        if not.
9fcacc9e5eaa 16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents: 2034
diff changeset
  2118
9fcacc9e5eaa 16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents: 2034
diff changeset
  2119
        'ignored_errors' is an optional list of errno values for which None
9fcacc9e5eaa 16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents: 2034
diff changeset
  2120
        should be returned.
9fcacc9e5eaa 16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents: 2034
diff changeset
  2121
        """
9fcacc9e5eaa 16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents: 2034
diff changeset
  2122
9fcacc9e5eaa 16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents: 2034
diff changeset
  2123
        if not hasattr(e, "errno"):
9fcacc9e5eaa 16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents: 2034
diff changeset
  2124
                return e
2026
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  2125
        if e.errno in ignored_errors:
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  2126
                return None
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  2127
        if e.errno in (errno.EACCES, errno.EPERM):
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  2128
                return PermissionsException(e.filename)
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  2129
        if e.errno == errno.EROFS:
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  2130
                return ReadOnlyFileSystemException(e.filename)
d1b30615bc99 9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents: 2022
diff changeset
  2131
        return e