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

Question: Internal PIP module logfile check #29470

Closed
abednarik opened this issue Dec 6, 2015 · 2 comments
Closed

Question: Internal PIP module logfile check #29470

abednarik opened this issue Dec 6, 2015 · 2 comments
Labels
Execution-Module Feature new functionality including changes to functionality and code refactors, etc. Platform Relates to OS, containers, platform-based utilities like FS, system based apps
Milestone

Comments

@abednarik
Copy link
Contributor

I was trying to fix another issue and I cam acrross this line [ https://github.com/saltstack/salt/blob/develop/salt/modules/pip.py#L530 ]

Let me put a small block of code here

    if log:
        try:
            # TODO make this check if writeable
            os.path.exists(log)
        except IOError:
            raise IOError('\'{0}\' is not writeable'.format(log))

        cmd.extend(['--log', log])

I'm not a experience python developer, but os.path.exists() will return True or False but will not throw an exception in that context. Also log variable could be a directory, for example and I think is not something expected.

Please, be aware that I'm doing this just for fun and because I enjoy using Salt :)

I would try to do something like trying to open the file in write mode o using os.access to check permissions instead of the current implementation.
In any case, let me know and i will happy to submit a PR.

@jfindlay jfindlay added Feature new functionality including changes to functionality and code refactors, etc. Execution-Module Platform Relates to OS, containers, platform-based utilities like FS, system based apps labels Dec 8, 2015
@jfindlay jfindlay added this to the Approved milestone Dec 8, 2015
@jfindlay
Copy link
Contributor

jfindlay commented Dec 8, 2015

@abednarik, a writable check can be done with if os.access(log, os.W_OK), and you are welcome to send in a pull request.

@abednarik
Copy link
Contributor Author

I'm working on this, since we also need to be sure that is not a directory, other way pip will fail. I will send a PR, at least with something better today.

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Execution-Module Feature new functionality including changes to functionality and code refactors, etc. Platform Relates to OS, containers, platform-based utilities like FS, system based apps
Projects
None yet
Development

No branches or pull requests

2 participants