From 0cb79569dde2ce6ed11dedd72e30840b331e99d0 Mon Sep 17 00:00:00 2001 From: Bastian Schroll Date: Tue, 5 Mar 2019 08:33:35 +0100 Subject: [PATCH] improve docstrings --- boswatch/processManager.py | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/boswatch/processManager.py b/boswatch/processManager.py index d0f0e39..6f2c7af 100644 --- a/boswatch/processManager.py +++ b/boswatch/processManager.py @@ -21,6 +21,7 @@ logging.debug("- %s loaded", __name__) class ProcessManager: + """!class to manage a extern sub process""" def __init__(self, process, textMode=False): logging.debug("create process instance %s - textMode: %s", process, textMode) self._args = [] @@ -35,13 +36,18 @@ class ProcessManager: self.stop() def addArgument(self, arg): + """!add a new argument + + @param arg: argument to add as string""" logging.debug("add argument to process: %s -> %s", self._args[0], arg) self._args.append(arg) def clearArguments(self): - self._args = [] + """!clear all arguments""" + self._args = self._args[0:1] # kept first element (process name) def start(self): + """!start the new process""" logging.debug("start new process: %s", self._args[0]) self._processHandle = subprocess.Popen(self._args, stdin=self._stdin, @@ -50,6 +56,9 @@ class ProcessManager: universal_newlines=self._textMode) def stop(self): + """!Stop the process by sending SIGTERM and wait for ending + + @return return code of process""" if self._processHandle and self.isRunning: logging.debug("stopping process: %s", self._args[0]) self._processHandle.terminate() @@ -60,7 +69,9 @@ class ProcessManager: return 0 def readline(self): - """!Read one line from stdout stream or None""" + """!Read one line from stdout stream + + @return singe line or None""" if self.isRunning and self._stdout is not None: try: line = self._processHandle.stdout.readline().strip() @@ -71,29 +82,32 @@ class ProcessManager: return None def setStdin(self, stdin): - """!Set the stdin stream""" + """!Set the stdin stream instance""" self._stdin = stdin def setStdout(self, stdout): - """!Set the stdout stream""" + """!Set the stdout stream instance""" self._stdout = stdout def setStderr(self, stderr): - """!Set the stderr stream""" + """!Set the stderr stream instance""" self._stderr = stderr @property def stdout(self): - """!Get the stdout stream""" + """!Property to get the stdout stream""" return self._processHandle.stdout @property def stderr(self): - """!Get the stderr stream""" + """!Property to get the stderr stream""" return self._processHandle.stderr @property def isRunning(self): + """!Property to get process running state + + @return True or False""" if self._processHandle: if self._processHandle.poll() is None: return True