You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Catch FileNotFound for all subprocess.run() calls and raise a ProviderError.
Why it needs to get done
If the executable is not available, FileNotFound bubbles up as an internal error via craft-application.
Example
(testcraft_venv) root@u2204-parts-dev:/opt/testcraft/examples/ruff# testcraft pack
testcraft internal error: FileNotFoundError(2, 'No such file or directory')
Full execution log: '/root/.local/state/testcraft/log/testcraft-20240620-161753.039218.log'
2024-06-20 16:17:53.076 Executing on host: lxc remote list --format=yaml
2024-06-20 16:17:53.077 testcraft internal error: FileNotFoundError(2, 'No such file or directory')
2024-06-20 16:17:53.080 Traceback (most recent call last):
2024-06-20 16:17:53.080 File .../craft_application/application.py", line 536, in run
2024-06-20 16:17:53.080 self.run_managed(platform, build_for)
2024-06-20 16:17:53.080 File .../craft_application/application.py", line 361, in run_managed
2024-06-20 16:17:53.080 with self.services.provider.instance(
2024-06-20 16:17:53.080 File "/usr/lib/python3.10/contextlib.py", line 135, in __enter__
2024-06-20 16:17:53.080 return next(self.gen)
2024-06-20 16:17:53.080 File .../craft_application/services/provider.py", line 120, in instance
2024-06-20 16:17:53.080 with provider.launched_environment(
2024-06-20 16:17:53.080 File "/usr/lib/python3.10/contextlib.py", line 135, in __enter__
2024-06-20 16:17:53.080 return next(self.gen)
2024-06-20 16:17:53.080 File "/root/testcraft_venv/lib/python3.10/site-packages/craft_providers/lxd/lxd_provider.py", line 137, in launched_environment
2024-06-20 16:17:53.080 image.add_remote(lxc=self.lxc)
2024-06-20 16:17:53.080 File "/root/testcraft_venv/lib/python3.10/site-packages/craft_providers/lxd/remotes.py", line 97, in add_remote
2024-06-20 16:17:53.080 if self.remote_name in lxc.remote_list():
2024-06-20 16:17:53.080 File "/root/testcraft_venv/lib/python3.10/site-packages/craft_providers/lxd/lxc.py", line 1001, in remote_list
2024-06-20 16:17:53.080 proc = self._run_lxc(command, capture_output=True)
2024-06-20 16:17:53.080 File "/root/testcraft_venv/lib/python3.10/site-packages/craft_providers/lxd/lxc.py", line 104, in _run_lxc
2024-06-20 16:17:53.080 return subprocess.run(lxc_cmd, check=check, stdin=stdin.value, **kwargs)
2024-06-20 16:17:53.080 File "/usr/lib/python3.10/subprocess.py", line 503, in run
2024-06-20 16:17:53.080 with Popen(*popenargs, **kwargs) as process:
2024-06-20 16:17:53.080 File "/usr/lib/python3.10/subprocess.py", line 971, in __init__
2024-06-20 16:17:53.080 self._execute_child(args, executable, preexec_fn, close_fds,
2024-06-20 16:17:53.080 File "/usr/lib/python3.10/subprocess.py", line 1863, in _execute_child
2024-06-20 16:17:53.080 raise child_exception_type(errno_num, err_msg, err_filename)
2024-06-20 16:17:53.080 FileNotFoundError: [Errno 2] No such file or directory: 'lxc'
The text was updated successfully, but these errors were encountered:
What needs to get done
Catch
FileNotFound
for allsubprocess.run()
calls and raise aProviderError
.Why it needs to get done
If the executable is not available,
FileNotFound
bubbles up as an internal error via craft-application.Example
The text was updated successfully, but these errors were encountered: