[docs]classPluginException(Exception):r"""A class that represents exceptions with your plugin"""
[docs]classPluginNotInitialized(PluginException):r"""This is raised when you try to access something that needs data from the initialize method, and it hasn't been called yet."""def__init__(self)->None:super().__init__("The plugin hasn't been initialized yet")
[docs]classEnvNotSet(PluginException):"""This is raised when an environment variable that flow automatically sets is not set and can not be retrieved. This should only get raised when your plugin gets run, but not by flow. .. versionadded: 1.1.0 Attributes ----------- name: :class:`str` The name of the environment variable that was not found alternative: Optional[:class:`str`] Optionally, the name of the keyword argument in the :class:`~flogin.testing.plugin_tester.PluginTester` constructor that will set the variable for you. """def__init__(self,name:str,alternative:str|None=None)->None:self.name=nameself.alternative=alternativealt=(f"If you ran your plugin via the plugin tester, you can use the {alternative!r} keyword argument to quickly set this."ifalternativeelse"")super().__init__(f"The {name!r} environment variable is not set. These should be set by flow when it runs your plugin. {alt}")
[docs]classPipException(Exception):r"""This is a base class to represent errors derived from the :class:`~flogin.pip.Pip` object. .. versionadded:: 2.0.0 """
[docs]classUnableToDownloadPip(PipException):r"""This is an exception which is used to indicate that an error occurred while attempting to download pip. .. versionadded:: 2.0.0 Attributes ---------- error: :class:`requests.exceptions.HTTPError` | :class:`requests.Timeout` | :class:`requests.ConnectionError` The error that was raised by the :doc:`req:index` module. """def__init__(self,err:requests.RequestException)->None:super().__init__(err)self.error=err
[docs]classPipExecutionError(PipException):r"""This is an exception which is raised whenever :meth:`flogin.pip.Pip.run` gets a return code that isn't ``0``. .. versionadded:: 2.0.0 Attributes ---------- error: :class:`subprocess.CalledProcessError` The original error that was raised by subprocess """def__init__(self,err:CalledProcessError)->None:super().__init__(f"An error occurred while attempting to use pip: {err.stderr.decode()}")self.error=err@propertydefoutput(self)->str:""":class:`str` The output from :attr:`subprocess.CalledProcessError.output`"""returnself.error.output.decode()@propertydefreturncode(self)->int:""":class:`int` The returncode from :attr:`subprocess.CalledProcessError.returncode`"""returnself.error.returncode@propertydefstderr(self)->str:""":class:`str` The stderr from :attr:`subprocess.CalledProcessError.stderr`"""returnself.error.stderr.decode()