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

DM-16220: Use subprocess.run for all external commands #62

Merged
merged 3 commits into from Oct 29, 2018

Conversation

timj
Copy link
Member

@timj timj commented Oct 16, 2018

Standardize on the modern way for running external commands.

@timj timj requested a review from ktlim October 16, 2018 23:35
@timj timj changed the title Use subprocess.run for all external commands DM-16220: Use subprocess.run for all external commands Oct 16, 2018
@timj
Copy link
Member Author

timj commented Oct 17, 2018

Turns out that python 3.7 has a significantly better subprocess.run() with capture_output=True text=True. The version in 3.6 has neither and needs explicit stdout, stderr capturing and explicit byte decoding. Much more untidy than I was hoping for.


try:
retval = subprocess.run(cmd, shell=shell, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
check=True, text=True)
Copy link
Contributor

Choose a reason for hiding this comment

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

Wait, I thought 3.6 doesn't support text. You need universal_newlines, I think.

@timj timj merged commit 57c515d into master Oct 29, 2018
@timj timj deleted the tickets/DM-16220 branch October 29, 2018 19:31
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

2 participants