ExecutableService: option to return stderr added
Ilya committed
May 6, 2017 at 20:33 UTC
391533ca89195b84b4ed46b848a647cdd13b5f7d
1 file changed
+3
-2
python.d/python_modules/base.py
+3
-2
@@ -873,7 +873,7 @@ class ExecutableService(SimpleService):
873
SimpleService.__init__(self, configuration=configuration, name=name)
874
self.command = None
875
876
- def _get_raw_data(self):
876
+ def _get_raw_data(self, stderr=False):
877
"""
878
Get raw data from executed command
879
:return: <list>
@@ -884,7 +884,8 @@ class ExecutableService(SimpleService):
884
self.error("Executing command", self.command, "resulted in error:", str(error))
885
return None
886
data = list()
887
- for line in p.stdout.readlines():
887
+ std = p.stderr if stderr else p.stdout
888
+ for line in std.readlines():
889
data.append(line.decode())
890
891
return data or None