mwilliamson / spur.py

Run commands and manipulate files locally or over SSH using the same interface
BSD 2-Clause "Simplified" License
267 stars 37 forks source link

check_call and check_output #76

Closed mristin closed 6 years ago

mristin commented 6 years ago

I implemented a wrapper around spur and added check_call and check_output to mimic subprocess.check_call and check_output, respectively.

Should I make a pull request and add them to spur.py?

mwilliamson commented 6 years ago

Hmm, I think the implementation for check_call(...) and check_output(...) would be run(...) and run(...).output. It feels like those two use cases are already handled without much complexity with the current API, and recent Python versions also suggest using subprocess.run() instead of the older API. Is there a reason why using run(...) directly is inconvenient?

mristin commented 6 years ago

Sorry, you are completely right. I had some dead code lying around related to paramiko and closing of the out and err streams which confused me.

Just before I go on and refactor the code base: shell.run() and shell.run(...).output involve no closing of the streams, right?

mwilliamson commented 6 years ago

I'm not sure which streams you're referring to? To the best of my recollection, yhey don't close any file objects that get passed in, if that's what you mean.

mristin commented 6 years ago

The discussion was moved to #77.