mirror of
https://github.com/BOSWatch/BW3-Core.git
synced 2026-01-06 16:50:27 +01:00
add logging
This commit is contained in:
parent
0ee177f8ea
commit
0b3d71cd4a
|
|
@ -22,6 +22,7 @@ logging.debug("- %s loaded", __name__)
|
||||||
|
|
||||||
class ProcessManager:
|
class ProcessManager:
|
||||||
def __init__(self, process, textMode=False):
|
def __init__(self, process, textMode=False):
|
||||||
|
logging.debug("create process instance %s - textMode: %s", process, textMode)
|
||||||
self._args = []
|
self._args = []
|
||||||
self._args.append(process)
|
self._args.append(process)
|
||||||
self._stdin = None
|
self._stdin = None
|
||||||
|
|
@ -29,27 +30,34 @@ class ProcessManager:
|
||||||
self._stderr = subprocess.STDOUT
|
self._stderr = subprocess.STDOUT
|
||||||
self._processHandle = None
|
self._processHandle = None
|
||||||
self._textMode = textMode
|
self._textMode = textMode
|
||||||
pass
|
|
||||||
|
def __del__(self):
|
||||||
|
self.stop()
|
||||||
|
|
||||||
def addArgument(self, arg):
|
def addArgument(self, arg):
|
||||||
|
logging.debug("add argument to process: %s -> %s", self._args[0], arg)
|
||||||
self._args.append(arg)
|
self._args.append(arg)
|
||||||
|
|
||||||
def clearArguments(self):
|
def clearArguments(self):
|
||||||
self._args = []
|
self._args = []
|
||||||
|
|
||||||
def run(self):
|
def start(self):
|
||||||
|
logging.debug("start new process: %s", self._args[0])
|
||||||
self._processHandle = subprocess.Popen(self._args,
|
self._processHandle = subprocess.Popen(self._args,
|
||||||
stdin=self._stdin,
|
stdin=self._stdin,
|
||||||
stdout=self._stdout,
|
stdout=self._stdout,
|
||||||
stderr=self._stderr,
|
stderr=self._stderr,
|
||||||
shell=False,
|
|
||||||
universal_newlines=self._textMode)
|
universal_newlines=self._textMode)
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
if self._processHandle and self.isRunning:
|
if self._processHandle and self.isRunning:
|
||||||
|
logging.debug("stopping process: %s", self._args[0])
|
||||||
self._processHandle.terminate()
|
self._processHandle.terminate()
|
||||||
while self.isRunning:
|
while self.isRunning:
|
||||||
pass
|
pass
|
||||||
|
return self._processHandle.returnCode
|
||||||
|
logging.debug("process not running: %s", self._args[0])
|
||||||
|
return 0
|
||||||
|
|
||||||
def readline(self):
|
def readline(self):
|
||||||
"""!Read one line from stdout stream or None"""
|
"""!Read one line from stdout stream or None"""
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue