Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IsADirectoryError on open log file #135

Open
llicour opened this issue Jul 7, 2023 · 2 comments
Open

IsADirectoryError on open log file #135

llicour opened this issue Jul 7, 2023 · 2 comments
Labels

Comments

@llicour
Copy link

llicour commented Jul 7, 2023

Hi. After upgrading from 0.17.1 to 0.22.2, i got following error

  File "/Users/20010116/.pyenv/versions/3.9.17/envs/venv-ddiapi2-py39/lib/python3.9/site-packages/xprocess/pytest_xprocess.py", line 59, in xprocess
    open(log_file, errors="surrogateescape").close()
IsADirectoryError: [Errno 21] Is a directory: '/Users/20010116/Documents/Workspace/ddi/infrasvc-ddi-api/.pytest_cache/d/.xprocess/consumer_start_consumer/log'

Digging the error, i found that get_log_files list all objects in root directory, including directory (i have one that is named "log")
I suggest to add a condition to verify if object is a file

def get_log_files(root_dir):
    proc_dirs = [f.path for f in os.scandir(root_dir) if f.is_dir()]
    return [
        os.path.join(proc_dir, f)
        for proc_dir in proc_dirs
        for f in os.listdir(proc_dir)
        if f.endswith("log") and os.path.isfile(os.path.join(proc_dir, f))
    ]
@llicour llicour added the bug label Jul 7, 2023
@northernSage
Copy link
Member

northernSage commented Mar 16, 2024

Hey @llicour , thanks for taking the time to open the issue! Could you provide a bit more info? Maybe sharing how you are using xprocess? The reason I ask is because there should not be nested directories inside xprocess cache dir at all so we should first understand how this happened before moving further with any changes :bowtie:

@northernSage
Copy link
Member

A minimal example to reproduce the issue would go a long way to help this getting fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants