Question: Internal PIP module logfile check
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.
@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.
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.