uhd-urz / elAPI

An extensible API client for eLabFTW
GNU Affero General Public License v3.0
5 stars 0 forks source link

Plugin commands without elapi_plugin_metadata.yml file throw an error #118

Closed mhxion closed 1 month ago

mhxion commented 1 month ago

elapi will fail for the following elapi_plugin_metadata.yml:

cli_script: ~/Workshop/try-numpy-with-elapi/cli.py
venv_dir: 

Running elapi will show:

  File "/Users/culdesac/.local/bin/elapi", line 5, in <module>
    from elapi.cli.elapi import app
  File "/Users/culdesac/.local/pipx/venvs/venvs/elapi/lib/python3.12/site-packages/elapi/cli/elapi.py", line 1141, in <module>
    for plugin_info in external_local_plugin_typer_apps:
  File "/Users/culdesac/.local/pipx/venvs/venvs/elapi/lib/python3.12/site-packages/elapi/cli/_plugin_handler.py", line 273, in get_typer_apps
    for metadata in self.get_plugin_metadata():
  File "/Users/culdesac/.local/pipx/venvs/venvs/elapi/lib/python3.12/site-packages/elapi/cli/_plugin_handler.py", line 237, in get_plugin_metadata
    metadata = Validate(ExternalPluginLocationValidator(path)).get()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/culdesac/.local/pipx/venvs/venvs/elapi/lib/python3.12/site-packages/elapi/core_validators/base.py", line 51, in get
    return typ.validate(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/culdesac/.local/pipx/venvs/venvs/elapi/lib/python3.12/site-packages/elapi/cli/_plugin_handler.py", line 166, in validate
    VENV_PATH = ProperPath(VENV_PATH)
                ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/culdesac/.local/pipx/venvs/venvs/elapi/lib/python3.12/site-packages/elapi/path.py", line 24, in __init__
    self.kind = kind
    ^^^^^^^^^
  File "/Users/culdesac/.local/pipx/venvs/venvs/elapi/lib/python3.12/site-packages/elapi/path.py", line 109, in kind
    if self.expanded.is_dir()
       ^^^^^^^^^^^^^
  File "/Users/culdesac/.local/pipx/venvs/venvs/elapi/lib/python3.12/site-packages/elapi/path.py", line 94, in expanded
    return Path(self.name).expanduser()
           ^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.12/3.12.4/Frameworks/Python.framework/Versions/3.12/lib/python3.12/pathlib.py", line 1162, in __init__
    super().__init__(*args)
  File "/opt/homebrew/Cellar/python@3.12/3.12.4/Frameworks/Python.framework/Versions/3.12/lib/python3.12/pathlib.py", line 373, in __init__
    raise TypeError(
TypeError: argument should be a str or an os.PathLike object where __fspath__ returns a str, not 'NoneType'

plugin_name can be null and doesn't cause this issue.