Skip to content
This repository has been archived by the owner on Jul 13, 2021. It is now read-only.

ProcessHelper.run_subprocess to return output text alongside return code #211

Open
bocekm opened this issue Jan 31, 2017 · 4 comments
Open
Assignees

Comments

@bocekm
Copy link
Collaborator

bocekm commented Jan 31, 2017

ProcessHelper.run_subprocess currently returns return value of a command that it executes. However if anybody wants to get standard output of the command, the only option is to save it to a file and then read this file. This seems ridiculous to me.
Update the run_subprocess so it returns the captured standard output into alongside the return value, for example in a tuple. Then no temp file is needed just to read the command output.

@bocekm bocekm self-assigned this Jan 31, 2017
@bocekm
Copy link
Collaborator Author

bocekm commented Sep 18, 2017

Consider returning triple, where stdout and stderr will be separate, alongside the return value.

@AloisMahdal
Copy link
Collaborator

Is the helper even necessary, though? Why not just use Python's standard lib?

It does some juggling with coding and stuff, but I'm not sure why/if it's really needed. I just used subprocess.Popen directly (maybe even should have used subprocess.check_output but I thought I need the other one to pass environment) and it worked just fine.

@AloisMahdal
Copy link
Collaborator

By the way, the list of helpers is pretty impressive:

ConfigFilesHelper
ConfigHelper
DirHelper
FileHelper
LoggerHelper
MessageHelper
ModuleHelper
OpenSCAPHelper
PostupgradeHelper
ProcessHelper
ReportHelper
ScanningHelper
TarballHelper
UIHelper
XccdfHelper

@bocekm
Copy link
Collaborator Author

bocekm commented Sep 18, 2017

@AloisMahdal, it's useful. You used subprocess.Popen and that took you 7 lines - that's perfect length for a small utility function.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants