Skip to content

Add an env keyword argument to _util.get_subprocess_output#5987

Merged
L3n41c merged 14 commits into
masterfrom
lenaic/get_subprocess_output_env
Sep 3, 2020
Merged

Add an env keyword argument to _util.get_subprocess_output#5987
L3n41c merged 14 commits into
masterfrom
lenaic/get_subprocess_output_env

Conversation

@L3n41c

@L3n41c L3n41c commented Jul 17, 2020

Copy link
Copy Markdown
Member

What does this PR do?

Add an env keyword argument to _util.get_subprocess_output.

Motivation

For DataDog/integrations-core#7095, I would need a python check to be able to spawn a command with custom environment variables.

Additional Notes

Anything else we should know when reviewing?

Describe your test plan

We can patch a python check to make it execute env with a custom environment variable and have the check log the output.

@L3n41c
L3n41c force-pushed the lenaic/get_subprocess_output_env branch from 47afb1c to 25812be Compare August 12, 2020 13:34
@L3n41c
L3n41c force-pushed the lenaic/get_subprocess_output_env branch from cc2871c to ea9963d Compare August 13, 2020 09:12
@L3n41c
L3n41c force-pushed the lenaic/get_subprocess_output_env branch 3 times, most recently from 26e49f4 to 1d45abf Compare August 14, 2020 14:23
@L3n41c
L3n41c force-pushed the lenaic/get_subprocess_output_env branch from fc24030 to 13604c9 Compare August 14, 2020 15:01
@L3n41c
L3n41c force-pushed the lenaic/get_subprocess_output_env branch from 8307382 to 03bce84 Compare August 14, 2020 15:41
@L3n41c
L3n41c marked this pull request as ready for review August 14, 2020 20:19
@L3n41c
L3n41c requested a review from a team as a code owner August 14, 2020 20:19

@hush-hush hush-hush left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good to go overall, only a few nit·pick.

Comment thread rtloader/common/builtins/_util.c Outdated
Comment thread rtloader/common/builtins/_util.c Outdated
Comment thread rtloader/common/builtins/_util.c Outdated
@L3n41c
L3n41c requested a review from hush-hush September 1, 2020 10:06

@truthbk truthbk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Some small comments from my side, not sure if @hush-hush has anything else to add.

Nice job 👍

#define _SUBPROCESS_OUTPUT_ERROR_NS_NAME _UTIL_MODULE_NAME _DOT _SUBPROCESS_OUTPUT_ERROR_NAME

#ifdef DATADOG_AGENT_THREE
# define PY_ARG_PARSE_TUPLE_KEYWORD_ONLY "$"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you add a comment here that this was introduce in python 3.3+?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Sure !
Done: fedca6c.

returned.
*/
PyObject *subprocess_output(PyObject *self, PyObject *args)
PyObject *subprocess_output(PyObject *self, PyObject *args, PyObject *kw)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The doxygen documentation above has to be updated to account for kwargs.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Indeed !
Done: fedca6c.

}

func charArrayToSlice(array **C.char) (res []string) {
if array == nil {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

🍰

@hush-hush hush-hush left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good to me after the comments from @truthbk are answered

@L3n41c
L3n41c requested a review from truthbk September 2, 2020 08:00
@L3n41c
L3n41c merged commit 0d5d893 into master Sep 3, 2020
@L3n41c
L3n41c deleted the lenaic/get_subprocess_output_env branch September 3, 2020 21:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants