Fix for an Issue #591

This commit is contained in:
Miroslav Stampar 2014-01-02 10:55:40 +01:00
parent 854a55166c
commit 0b4fcb6845

View File

@ -187,8 +187,11 @@ class Task(object):
return None return None
def engine_get_returncode(self): def engine_get_returncode(self):
if self.process:
self.process.poll() self.process.poll()
return self.process.returncode return self.process.returncode
else:
return None
def engine_has_terminated(self): def engine_has_terminated(self):
return isinstance(self.engine_get_returncode(), int) return isinstance(self.engine_get_returncode(), int)
@ -510,6 +513,9 @@ def scan_status(taskid):
logger.warning("[%s] Invalid task ID provided to scan_status()" % taskid) logger.warning("[%s] Invalid task ID provided to scan_status()" % taskid)
return jsonize({"success": False, "message": "Invalid task ID"}) return jsonize({"success": False, "message": "Invalid task ID"})
if DataStore.tasks[taskid].engine_get_returncode() is None:
status = "not running"
else:
status = "terminated" if DataStore.tasks[taskid].engine_has_terminated() is True else "running" status = "terminated" if DataStore.tasks[taskid].engine_has_terminated() is True else "running"
logger.debug("[%s] Retrieved scan status" % taskid) logger.debug("[%s] Retrieved scan status" % taskid)