Skip to content

Commit

Permalink
Log a warning when an executable is found, but does not have the exec…
Browse files Browse the repository at this point in the history
… bit set
  • Loading branch information
pmrv committed Jul 22, 2024
1 parent 7a4fe2a commit fbc12df
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pyiron_snippets/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,9 @@ def cond(path):
isexec = os.access(
path, os.X_OK, effective_ids=os.access in os.supports_effective_ids
)
if isfile and not isexec:
from pyiron_snippets.logger import logger
logger.warning(f"Found file '{path}', but skipping it because it is not executable!")
return isfile and isexec

for path in filter(cond, self._resolver.search(self._glob)):
Expand Down
3 changes: 3 additions & 0 deletions tests/unit/test_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import os.path
import unittest
from pyiron_snippets.resources import ResourceNotFound, ResourceResolver, ExecutableResolver
from pyiron_snippets.logger import logger

class TestResolvers(unittest.TestCase):
"""
Expand Down Expand Up @@ -55,6 +56,8 @@ def test_executable(self):
for suffix in (None, "sh", "bat"):
with self.subTest(suffix=suffix):
res = ExecutableResolver([self.res1], code="code1", module="module1", suffix=suffix)
with self.assertLogs(logger, level="WARNING"):
res.list()
if os.name != "nt":
# no exec bits are present on windows it seems
self.assertNotIn("versionnonexec", res.available_versions,
Expand Down

0 comments on commit fbc12df

Please sign in to comment.