How to use the snapcraft.internal.errors.SnapcraftError function in snapcraft

To help you get started, we’ve selected a few snapcraft examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github snapcore / snapcraft / snapcraft / plugins / catkin.py View on Github external
"dependency: {dependency_type!r}."
    )

    def __init__(self, dependency_type, dependency):
        super().__init__(dependency_type=dependency_type, dependency=dependency)


class CatkinWorkspaceIsRootError(errors.SnapcraftError):
    fmt = "source-space cannot be the root of the Catkin workspace; use a subdirectory."


class CatkinCannotResolveRoscoreError(errors.SnapcraftError):
    fmt = "Failed to determine system dependency for roscore."


class CatkinAptDependencyFetchError(errors.SnapcraftError):
    fmt = "Failed to fetch apt dependencies: {message}"

    def __init__(self, message):
        super().__init__(message=message)


class CatkinNoHighestVersionPathError(errors.SnapcraftError):
    fmt = "Failed to determine highest path in {path!r}: nothing found."

    def __init__(self, path):
        super().__init__(path=path)


class CatkinGccVersionError(errors.SnapcraftError):
    fmt = "Failed to determine gcc version: {message}"
github snapcore / snapcraft / snapcraft / plugins / colcon.py View on Github external
_ROS_KEYRING_PATH = os.path.join(snapcraft.internal.common.get_keyringsdir(), "ros.gpg")


class ColconInvalidSystemDependencyError(errors.SnapcraftError):
    fmt = (
        "Package {dependency!r} isn't a valid system dependency. Did you "
        "forget to add it to colcon-packages? If not, add the Ubuntu package "
        "containing it to stage-packages until you can get it into the rosdep "
        "database."
    )

    def __init__(self, dependency):
        super().__init__(dependency=dependency)


class ColconUnsupportedDependencyTypeError(errors.SnapcraftError):
    fmt = (
        "Package {dependency!r} resolved to an unsupported type of "
        "dependency: {dependency_type!r}."
    )

    def __init__(self, dependency_type, dependency):
        super().__init__(dependency_type=dependency_type, dependency=dependency)


class ColconWorkspaceIsRootError(errors.SnapcraftError):
    fmt = (
        "colcon-source-space cannot be the root of the colcon workspace; use a "
        "subdirectory."
    )
github snapcore / snapcraft / snapcraft / internal / lxd / errors.py View on Github external
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see .

import logging
from typing import List  # noqa

from snapcraft.internal.errors import SnapcraftError


logger = logging.getLogger(__name__)


class ContainerError(SnapcraftError):
    """Base class for all container-related exceptions.

    :cvar fmt: A format string that daughter classes override

    """


class ContainerArchitectureError(ContainerError):

    fmt = (
        "Failed to detect container architecture: "
        "The output from 'lxc info' could not be read:\n{lxc_info}"
    )

    def __init__(self, lxc_info: str) -> None:
        super().__init__(lxc_info=lxc_info)
github snapcore / snapcraft / snapcraft / internal / errors.py View on Github external
fmt = "Unable to determine host OS version codename"


class InvalidContainerImageInfoError(SnapcraftError):

    fmt = (
        "Failed to parse container image info: "
        "SNAPCRAFT_IMAGE_INFO is not a valid JSON string: {image_info}"
    )

    def __init__(self, image_info: str) -> None:
        super().__init__(image_info=image_info)


class PatcherError(SnapcraftError):
    pass


class PatcherGenericError(PatcherError):

    fmt = (
        "{elf_file!r} cannot be patched to function properly in a classic "
        "confined snap: {message}"
    )

    def __init__(self, *, elf_file, process_exception):
        message = "{} failed with exit code {}".format(
            " ".join(process_exception.cmd), process_exception.returncode
        )
        super().__init__(elf_file=elf_file, message=message)
github snapcore / snapcraft / snapcraft / internal / errors.py View on Github external
class MountPointNotFoundError(SnapcraftError):
    fmt = "Nothing is mounted at {mount_point!r}"

    def __init__(self, mount_point):
        super().__init__(mount_point=mount_point)


class RootNotMountedError(SnapcraftError):
    fmt = "{root!r} is not mounted"

    def __init__(self, root):
        super().__init__(root=root)


class InvalidMountinfoFormat(SnapcraftError):
    fmt = "Unable to parse mountinfo row: {row}"

    def __init__(self, row):
        super().__init__(row=row)


class CrossCompilationNotSupported(SnapcraftError):
    fmt = (
        "The plugin used by {part_name!r} does not support cross-compiling "
        "to a different target architecture."
    )

    def __init__(self, *, part_name: str) -> None:
        super().__init__(part_name=part_name)
github snapcore / snapcraft / snapcraft / plugins / catkin.py View on Github external
class CatkinWorkspaceIsRootError(errors.SnapcraftError):
    fmt = "source-space cannot be the root of the Catkin workspace; use a subdirectory."


class CatkinCannotResolveRoscoreError(errors.SnapcraftError):
    fmt = "Failed to determine system dependency for roscore."


class CatkinAptDependencyFetchError(errors.SnapcraftError):
    fmt = "Failed to fetch apt dependencies: {message}"

    def __init__(self, message):
        super().__init__(message=message)


class CatkinNoHighestVersionPathError(errors.SnapcraftError):
    fmt = "Failed to determine highest path in {path!r}: nothing found."

    def __init__(self, path):
        super().__init__(path=path)


class CatkinGccVersionError(errors.SnapcraftError):
    fmt = "Failed to determine gcc version: {message}"

    def __init__(self, message):
        super().__init__(message=message)


class CatkinPackagePathNotFoundError(errors.SnapcraftError):
    fmt = "Failed to find package path: {path!r}"
github snapcore / snapcraft / snapcraft / internal / errors.py View on Github external
class NoNextStepError(SnapcraftError):
    fmt = "The {part_name!r} part has run through its entire lifecycle"

    def __init__(self, part_name):
        super().__init__(part_name=part_name)


class MountPointNotFoundError(SnapcraftError):
    fmt = "Nothing is mounted at {mount_point!r}"

    def __init__(self, mount_point):
        super().__init__(mount_point=mount_point)


class RootNotMountedError(SnapcraftError):
    fmt = "{root!r} is not mounted"

    def __init__(self, root):
        super().__init__(root=root)


class InvalidMountinfoFormat(SnapcraftError):
    fmt = "Unable to parse mountinfo row: {row}"

    def __init__(self, row):
        super().__init__(row=row)


class CrossCompilationNotSupported(SnapcraftError):
    fmt = (
        "The plugin used by {part_name!r} does not support cross-compiling "
github snapcore / snapcraft / snapcraft / internal / errors.py View on Github external
super().__init__(part_name=part_name, message=message)


class MissingCommandError(SnapcraftError):

    fmt = (
        "Failed to run command: "
        "One or more packages are missing, please install:"
        " {required_commands!r}"
    )

    def __init__(self, required_commands):
        super().__init__(required_commands=required_commands)


class InvalidWikiEntryError(SnapcraftError):

    fmt = (
        "Invalid wiki entry: "
        "{error!r}"
        # FIXME include how to fix each of the possible wiki errors.
        # https://bugs.launchpad.net/snapcraft/+bug/1727490
        # --elopio - 2017-10-25
    )

    def __init__(self, error=None):
        super().__init__(error=error)


class MissingGadgetError(SnapcraftError):

    fmt = (
github snapcore / snapcraft / snapcraft / internal / errors.py View on Github external
"incompatible with files in this snap:\n"
        "{file_list}"
    )

    def __init__(
        self, *, base: str, linker_version: str, file_list: Dict[str, str]
    ) -> None:
        spaced_file_list = ("    {} ({})".format(k, v) for k, v in file_list.items())
        super().__init__(
            base=base,
            linker_version=linker_version,
            file_list="\n".join(sorted(spaced_file_list)),
        )


class PrimeFileConflictError(SnapcraftError):

    fmt = (
        "Failed to filter files: "
        "The following files have been excluded by the `stage` keyword, "
        "but included by the `prime` keyword: {fileset!r}. "
        "Edit the `snapcraft.yaml` to make sure that the files included in "
        "`prime` are also included in `stage`."
    )


class PluginError(SnapcraftError):

    fmt = (
        "Failed to load plugin: "
        "{message}"
        # FIXME include how to fix each of the possible plugin errors.
github snapcore / snapcraft / snapcraft / internal / errors.py View on Github external
class InvalidBuildPropertiesError(SnapcraftError):

    fmt = (
        "Failed to load plugin: "
        "Invalid build properties specified by {plugin_name!r} plugin: "
        "{properties}"
        # TODO add a link to some docs about build properties?
        # --elopio - 2017-10-25
    )

    def __init__(self, plugin_name, properties):
        super().__init__(plugin_name=plugin_name, properties=properties)


class StagePackageDownloadError(SnapcraftError):

    fmt = (
        "Failed to fetch stage packages: "
        "Error downloading packages for part {part_name!r}: {message}."
    )

    def __init__(self, part_name, message):
        super().__init__(part_name=part_name, message=message)


class OsReleaseIdError(SnapcraftError):

    fmt = "Unable to determine host OS ID"


class OsReleaseNameError(SnapcraftError):