2020-03-01 12:20:36 +00:00
|
|
|
from __future__ import absolute_import
|
|
|
|
import psutil
|
2020-03-01 06:23:38 +00:00
|
|
|
import os
|
|
|
|
|
|
|
|
|
2020-03-01 12:20:36 +00:00
|
|
|
def get_services():
|
|
|
|
return [svc.as_dict() for svc in psutil.win_service_iter()]
|
|
|
|
|
|
|
|
|
2020-03-01 06:23:38 +00:00
|
|
|
def run_python_script(filename, timeout):
|
|
|
|
python_bin = os.path.join("c:\\salt\\bin", "python.exe")
|
|
|
|
file_path = os.path.join("c:\\windows\\temp", filename)
|
|
|
|
__salt__["cp.get_file"](
|
|
|
|
"salt://scripts/userdefined/{0}".format(filename), file_path
|
|
|
|
)
|
|
|
|
return __salt__["cmd.run_all"](
|
|
|
|
"{0} {1}".format(python_bin, file_path), timeout=timeout
|
|
|
|
)
|