Skip to content

Commit f998823

Browse files
committed
Add more debug logging
1 parent dca1637 commit f998823

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

pyautoenv.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,8 @@ def venv_activator(args: Args) -> Union[str, None]:
244244
"""
245245
for path in venv_candidate_dirs(args):
246246
for activate_script in iter_candidate_activators(path, args):
247+
if __debug__:
248+
logger.debug("venv_activator: candidate '%s'", activate_script)
247249
if os.path.isfile(activate_script):
248250
return activate_script
249251
return None
@@ -280,6 +282,10 @@ def poetry_activator(args: Args) -> Union[str, None]:
280282
if env_list:
281283
env_dir = max(env_list, key=lambda p: os.stat(p).st_mtime)
282284
for env_activator in iter_candidate_activators(env_dir, args):
285+
if __debug__:
286+
logger.debug(
287+
"poetry_activator: candidate: '%s'", env_activator
288+
)
283289
if os.path.isfile(env_activator):
284290
return env_activator
285291
return None
@@ -296,15 +302,23 @@ def poetry_env_list(directory: str) -> List[str]:
296302
if cache_dir is None:
297303
return []
298304
env_name = poetry_env_name(directory)
305+
if __debug__:
306+
logger.debug("poetry_env_list: env name: '%s'", env_name)
299307
if env_name is None:
300308
return []
309+
virtual_env_path = os.path.join(cache_dir, "virtualenvs")
310+
if __debug__:
311+
logger.debug("poetry_env_list: venvs path: '%s'", virtual_env_path)
301312
try:
302313
return [
303314
f.path
304-
for f in os.scandir(os.path.join(cache_dir, "virtualenvs"))
315+
for f in os.scandir(virtual_env_path)
305316
if f.name.startswith(f"{env_name}-py")
306317
]
307318
except OSError:
319+
if __debug__:
320+
logger.debug("poetry_env_list: os error:")
321+
logger.exception("")
308322
return []
309323

310324

0 commit comments

Comments
 (0)