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

Hide command prompt on Windows when running subprocess. #136

Closed
wants to merge 2 commits into from

Conversation

rohinnz
Copy link

@rohinnz rohinnz commented Apr 4, 2019

No description provided.

@coveralls
Copy link

coveralls commented Apr 4, 2019

Coverage Status

Coverage decreased (-28.5%) to 71.547% when pulling 992aab5 on rohinnz:windows-hide-terminal into 0c222a9 on dsoprea:master.

stderr=subprocess.STDOUT,
cwd=wd,
env=env)
if sys.platform.lower().startswith('win'):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

subprocess.STARTF_USESHOWWINDOW is only defined in Windows. Just try to get it and handle AttributeError if it doesn't exist. We don't want to get involved with detecting platform names.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

startupinfo = subprocess.STARTUPINFO()
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW

p = subprocess.Popen(
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just create an empty kwargs variable above, add startupinfo to it if we're in Windows, and expand/unsplat the kwargs into the existing call rather than duplicating it.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

startupinfo = subprocess.STARTUPINFO()
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW

p = subprocess.Popen(
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While we're here, let's refactor to use subprocess.check_output() rather than subprocess.Popen() directly.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That could go in another pull request as just a code refactor.

@dsoprea
Copy link
Owner

dsoprea commented Apr 5, 2019

Also, unit-test coverage dropped by a third with your change. Please investigate.

@rohinnz
Copy link
Author

rohinnz commented Apr 9, 2019

I've updated the pull request.

Unsure why unit-test coverage dropped by a third. It is either unrelated to this pull request or coveralls reporting is inaccurate. Other pull requests have similar issues.

@dsoprea
Copy link
Owner

dsoprea commented Apr 23, 2023

Closed due to ignored conflicts.

@dsoprea dsoprea closed this Apr 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants