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
This is a quick fix for #977. I have tried hard to write a test for this, but have failed.
When this PR is applied, and using the setup described in #977 , you get:
pelita-server remote-server --address 127.0.0.1 --port 10000 --team /tmp/broken.py
Use --session-key 762890741955 to for the admin API.
Team /tmp/broken.py did not return a filename. Skipping. Error:
Failure while loading team '/tmp/broken.py'
ERROR: No module named 'does_not_exist'
Traceback (most recent call last):
File "<frozen runpy>", line 203, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "/home/tiziano/git/pelita/pelita/scripts/pelita_player.py", line 392, in <module>
main()
~~~~^^
File "/usr/lib/python3/dist-packages/click/core.py", line 1514, in __call__
return self.main(*args, **kwargs)
~~~~~~~~~^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/click/core.py", line 1435, in main
rv = self.invoke(ctx)
File "/usr/lib/python3/dist-packages/click/core.py", line 1902, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
File "/usr/lib/python3/dist-packages/click/core.py", line 1298, in invoke
return ctx.invoke(self.callback, **ctx.params)
~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/click/core.py", line 853, in invoke
return callback(*args, **kwargs)
File "/home/tiziano/git/pelita/pelita/scripts/pelita_player.py", line 357, in cli_check_team
return check_team(team)
File "/home/tiziano/git/pelita/pelita/scripts/pelita_player.py", line 365, in check_team
print(load_team(team).team_name)
~~~~~~~~~^^^^^^
File "/home/tiziano/git/pelita/pelita/scripts/pelita_player.py", line 252, in load_team
team = load_team_from_module(spec)
File "/home/tiziano/git/pelita/pelita/scripts/pelita_player.py", line 301, in load_team_from_module
module = importlib.import_module(modname)
File "/usr/lib/python3.14/importlib/__init__.py", line 88, in import_module
return _bootstrap._gcd_import(name, package, level)
~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<frozen importlib._bootstrap>", line 1406, in _gcd_import
File "<frozen importlib._bootstrap>", line 1371, in _find_and_load
File "<frozen importlib._bootstrap>", line 1342, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 938, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 759, in exec_module
File "<frozen importlib._bootstrap>", line 491, in _call_with_frames_removed
File "/tmp/broken.py", line 1, in <module>
import does_not_exist
ModuleNotFoundError: No module named 'does_not_exist'
which is maybe too verbose, but at least gives a clear hint where to go to fix the problem.
Can you make it so that _check_team returns a tuple in either case? So that we don’t have to distinguish the return signature depending on the input value.
Or maybe we just add check=True to subprocess.run and fail hard.
otizonaizit
changed the title
Be noisy if there are errors while trying to lead a team in the server
Be noisy if there are errors while trying to load a team in the server
Aug 27, 2026
Can you make it so that _check_team returns a tuple in either case? So that we don’t have to distinguish the return signature depending on the input value.
done
Or maybe we just add check=True to subprocess.run and fail hard.
I didn't dare to do this. I think the right solution is to fix pelita-player check-team to return a non-zero exit status when a team fails to load. This way we can work cleanly and do not have to depend on the presence of strings in stderr/stdout...
I didn't dare to do this. I think the right solution is to fix pelita-player check-team to return a non-zero exit status when a team fails to load. This way we can work cleanly and do not have to depend on the presence of strings in stderr/stdout...
But that’s what I meant: pelita-player check-team will return 1 on failure and then check=True will raise.
But anyway I am also fine with merging it as is. Thanks.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a quick fix for #977. I have tried hard to write a test for this, but have failed.
When this PR is applied, and using the setup described in #977 , you get:
which is maybe too verbose, but at least gives a clear hint where to go to fix the problem.
Fixes #977