mirror of
https://gitlab.com/pamhyr/pamhyr2.git
synced 2026-10-30 03:20:41 +01:00
Solver: Minor change.
This commit is contained in:
1 parent
21c59dbcac
commit
d893db4ef7
2 files changed
+26
-13
No files matched your search
+15
-8
@@ -3,7 +3,6 @@
|
||||
import os
|
||||
|
||||
from signal import SIGTERM, SIGSTOP, SIGCONT
|
||||
from subprocess import Popen, PIPE, STDOUT, TimeoutExpired
|
||||
from enum import Enum
|
||||
|
||||
from Model.Except import NotImplementedMethodeError
|
||||
@@ -12,9 +11,6 @@ class STATUS(Enum):
|
||||
NOT_LAUNCHED = -1
|
||||
STOPED = 0
|
||||
RUNNING = 1
|
||||
FAILED = 2
|
||||
CONF_ERROR = 3
|
||||
KILLED = 4
|
||||
PAUSED = 5
|
||||
|
||||
class AbstractSolver(object):
|
||||
@@ -90,6 +86,15 @@ class AbstractSolver(object):
|
||||
def status(self, status):
|
||||
self._status = status
|
||||
|
||||
def is_running(self):
|
||||
return self._status == STATUS.RUNNING
|
||||
|
||||
def is_paused(self):
|
||||
return self._status == STATUS.PAUSED
|
||||
|
||||
def is_stoped(self):
|
||||
return self._status == STATUS.STOPED
|
||||
|
||||
@name.setter
|
||||
def name(self, name):
|
||||
self._name = name
|
||||
@@ -137,6 +142,7 @@ class AbstractSolver(object):
|
||||
self._process.readyRead.connect(self._data_ready)
|
||||
self._process.finished.connect(self._finished)
|
||||
|
||||
self._status = STATUS.RUNNING
|
||||
return True
|
||||
|
||||
def run_output_data_fomater(self):
|
||||
@@ -153,6 +159,7 @@ class AbstractSolver(object):
|
||||
def _finished(self, exit_code, exit_status):
|
||||
if self._output is not None:
|
||||
self._output.put(exit_code)
|
||||
self._status = STATUS.STOPED
|
||||
|
||||
def run(self, process, output_queue):
|
||||
self._process = process
|
||||
@@ -167,12 +174,12 @@ class AbstractSolver(object):
|
||||
return True
|
||||
|
||||
self._process.kill()
|
||||
self._status = STATUS.KILLED
|
||||
self._status = STATUS.STOPED
|
||||
return True
|
||||
|
||||
def start(self):
|
||||
if self._process is None:
|
||||
return False
|
||||
def start(self, process = None):
|
||||
if process is not None:
|
||||
self._process = process
|
||||
|
||||
if self._status == STATUS.PAUSED:
|
||||
os.kill(self._process.pid(), SIGCONT)
|
||||
|
||||
Reference in new issue
Block a user