Move package management code out of subproc.py
This commit is contained in:
73
package_manager/messages.py
Normal file
73
package_manager/messages.py
Normal file
@@ -0,0 +1,73 @@
|
||||
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 SubprocError(SubprocMessage):
|
||||
"""Superclass for all fatal error messages sent from the subprocess."""
|
||||
|
||||
def __init__(self, message: str):
|
||||
self.message = message
|
||||
|
||||
class SubprocWarning(SubprocMessage):
|
||||
"""Superclass for all non-fatal warning 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 FileConflictError(InstallError):
|
||||
"""Sent when installation would overwrite existing files."""
|
||||
|
||||
def __init__(self, message: str, conflicts: list):
|
||||
self.message = message
|
||||
self.conflicts = conflicts
|
||||
|
||||
class DownloadError(SubprocMessage):
|
||||
"""Sent when there was an error downloading something."""
|
||||
|
||||
def __init__(self, status_code: int, description: str):
|
||||
self.status_code = status_code
|
||||
self.description = description
|
||||
|
||||
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."""
|
||||
|
Reference in New Issue
Block a user