Fix old python support in scan_services

Python 2.4/RHEL5 doesn't support in-line conditionals so this breaks it
out into a normal multi-line condition
This commit is contained in:
Matthew Jones 2016-01-12 11:26:55 -05:00
parent 84c2e71907
commit c442f4923b

View File

@ -66,7 +66,10 @@ class ServiceScanService(BaseService):
if len(line_data) < 4:
continue # Skipping because we expected more data
service_name = " ".join(line_data[3:])
service_state = "running" if line_data[1] == "+" else "stopped"
if line_data[1] == "+":
service_state = "running"
else:
service_state = "stopped"
services.append({"name": service_name, "state": service_state, "source": "sysv"})
rc, stdout, stderr = self.module.run_command("%s list" % initctl_path)
real_stdout = stdout.replace("\r","")