Update pulp-manage-db to handle default answer, closes #2467 #2874
Conversation
|
@elyezer, thanks for your PR! By analyzing the history of the files in this pull request, we identified @werwty, @jeremycline and @mhrivnak to be potential reviewers. |
|
I wanted to write tests for the function but I was not sure where to add them. Let me know and I will be happy to add some unit tests in order to ensure all it is going to work as expected. |
|
@elyezer If this PR came with no tests that would be fine with me. Also can you paste a link to this PR on the issue and transition the issue to POST which is the correct state for issues which have a PR associated with them. |
|
@elyezer Also can you update the commit to use the http://docs.pulpproject.org/en/2.12/nightly/dev-guide/contributing/branching.html#commit-messages |
Definitely, I was expecting for a comment like this. Thanks for pointing me out to the proper documentation. |
| @@ -294,4 +294,4 @@ def _start_logging(): | |||
|
|
|||
| def _user_input_continue(question): | |||
| reply = str(raw_input(_(question + ' (y/N): '))).lower().strip() | |||
| return reply[0] == 'y' | |||
| return not len(reply) == 0 and reply[0] == 'y' | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this would be better as:
try:
return reply[0] == 'y'
except IndexError:
return False
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought using conditions would be much faster than try/catch but that is not the case:
In [7]: def test1(s):
...: try:
...: return s[0] == 'y'
...: except IndexError:
...: return False
...:
In [10]: def test2(s):
...: return not len(s) == 0 and s[0] == 'y'
...:
In [14]: %timeit "test1('')"
100000000 loops, best of 3: 7.81 ns per loop
In [15]: %timeit "test2('')"
100000000 loops, best of 3: 7.75 ns per loopI will update the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for putting in a PR on this! Can you update in the way suggested please? I think it's more Pythonic.
Proper handle the default/highlighted answer (empty input) for the continue question asked when workers are still running. Closes #2467
|
@bmbouter updated the PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
Since we removed the feature in #2883 I am closing this PR. |
Race condition was possible when applicability generation was running in parallel for the same consumer profiles. closes pulp#2874 https://pulp.plan.io/issues/2874
Race condition was possible when applicability generation was running in parallel for the same consumer profiles. closes pulp#2874 https://pulp.plan.io/issues/2874
Race condition was possible when applicability generation was running in parallel for the same consumer profiles. closes pulp#2874 https://pulp.plan.io/issues/2874
Default to no when any input is given for the continue question when running
pulp-manage-db.
I did some testing and the new condition works:
Fixes https://pulp.plan.io/issues/2467