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

Updated pip module internal check for log. #29535

Merged
merged 1 commit into from
Dec 11, 2015

Conversation

abednarik
Copy link
Contributor

When using pip you can append --log to store pip logs. In this case i made a change to make sure
argument to --log is not a directory, other way pip will throw and error. Also we need to make sure that
we have write permissions to that file.
Finally i made a small update on this file regarding indentation following pep8 standards.

Related to issue #29470

In this case, since is a feature hope is ok to make this PR against develop.

@abednarik
Copy link
Contributor Author

Hmm...a test related to this commit is failing. It's just fin that if a directory is used us an argument, this will fail, since pip also throw an error. I don't get it why tests fail like this

Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/mock.py", line 1201, in patched
    return func(*args, **keywargs)
  File "/testing/tests/unit/modules/pip_test.py", line 326, in test_install_log_argument_in_resulting_command
    pip.install(pkg, log=log_path)
  File "/testing/salt/modules/pip.py", line 531, in install
    '\'{0}\' is a directory. Use --log path_to_file'.format(log))
IOError: '/tmp/pip-install.log' is a directory. Use --log path_to_file

Thi sis the test

    @patch('os.path')
    def test_install_log_argument_in_resulting_command(self, mock_path):
        pkg = 'pep8'
        log_path = '/tmp/pip-install.log'
        mock = MagicMock(return_value={'retcode': 0, 'stdout': ''})
        with patch.dict(pip.__salt__, {'cmd.run_all': mock}):
            pip.install(pkg, log=log_path)
            mock.assert_called_once_with(
                ['pip', 'install', '--log', log_path, pkg],
                saltenv='base',
                runas=None,
                cwd=None,
                use_vt=False,
                python_shell=False,
            )

Any advice, help is much appreciated.

@cachedout
Copy link
Contributor

@jfindlay Could you help out here please?

@jfindlay jfindlay added Execution-Module Platform Relates to OS, containers, platform-based utilities like FS, system based apps labels Dec 9, 2015
@abednarik abednarik force-pushed the pip_module_proper_log_check branch from c22a3dc to 835758e Compare December 10, 2015 01:59
When using pip you can append --log to store pip logs. In this case i made a change to make sure
argument to --log is not a directory, other way pip will throw and error. Also we need to make sure that
we have write permissions to that file.
@abednarik abednarik force-pushed the pip_module_proper_log_check branch from 835758e to 7c4fa3a Compare December 11, 2015 17:32
@cachedout cachedout mentioned this pull request Dec 11, 2015
@cachedout cachedout merged commit 7c4fa3a into saltstack:develop Dec 11, 2015
@abednarik abednarik deleted the pip_module_proper_log_check branch December 15, 2015 01:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Execution-Module Platform Relates to OS, containers, platform-based utilities like FS, system based apps
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants