This repository has been archived on 2023-02-07. You can view files and clone it, but cannot push or open issues or pull requests.
Files
blender-package-manager-addon/package_manager/messages.py
Ellwood Zwovic 2f6357e40e Cleanup: Move package download/install code out of subproc.py
Instead do such things in bpkg, and only handle interfacing between
blender and bpkg in subproc.py
2017-07-26 02:08:01 -07:00

74 lines
2.0 KiB
Python

from .bpkg import Repository
class Message:
"""Superclass for all message sent over pipes."""
# Blender messages
class BlenderMessage(Message):
"""Superclass for all messages sent from Blender to the subprocess."""
class Abort(BlenderMessage):
"""Sent when the user requests abortion of a task."""
# Subproc messages
class SubprocMessage(Message):
"""Superclass for all messages sent from the subprocess to Blender."""
class Progress(SubprocMessage):
"""Send from subprocess to Blender to report progress.
:ivar progress: the progress percentage, from 0-1.
"""
def __init__(self, progress: float):
self.progress = progress
class Success(SubprocMessage):
"""Sent when an operation finished sucessfully."""
class RepositoryResult(SubprocMessage):
"""Sent when an operation returns a repository to be used on the parent process."""
def __init__(self, repository: Repository):
self.repository = repository
class Aborted(SubprocMessage):
"""Sent as response to Abort message."""
# subproc warnings
class SubprocWarning(SubprocMessage):
"""Superclass for all non-fatal warning messages sent from the subprocess."""
def __init__(self, message: str):
self.message = message
# subproc errors
class SubprocError(SubprocMessage):
"""Superclass for all fatal error messages sent from the subprocess."""
def __init__(self, message: str):
self.message = message
class InstallError(SubprocError):
"""Sent when there was an error installing something."""
class UninstallError(SubprocError):
"""Sent when there was an error uninstalling something."""
class BadRepositoryError(SubprocError):
"""Sent when a repository can't be used for some reason"""
class DownloadError(SubprocMessage):
"""Sent when there was an error downloading something."""
def __init__(self, message: str, status_code: int = None):
self.status_code = status_code
self.message = message