MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / _try_read

Function _try_read

e2e/python/test_sandbox_landlock.py:85–99  ·  view source on GitHub ↗

Return a closure that attempts to read a directory listing.

()

Source from the content-addressed store, hash-verified

83
84
85def _try_read():
86 """Return a closure that attempts to read a directory listing."""
87
88 def fn(path):
89 import os
90
91 try:
92 entries = os.listdir(path)
93 return f"OK:{len(entries)}"
94 except PermissionError:
95 return "EPERM"
96 except OSError as e:
97 return f"ERROR:{e.errno}"
98
99 return fn
100
101
102def _check_user_owns_path():

Calls

no outgoing calls

Tested by

no test coverage detected