I can’t think of a way to get running tasks on the ignition gateway on windows. Can’t seem import psutil or get stdout from system.util.execute. Anybody got anything? I have a process that needs to be started if it is not running for some reason, and want to check first obviously.
Check out ProcessBuilder.
Check this https://www.blog.pythonlibrary.org/2010/10/03/how-to-find-and-list-all-running-processes-with-python/
At the end of the article, you’ll find “The Cross-Platform Solution!”.
Hope this will help you out
That won’t work. psutil does not exist in Jython.
kwj, you will have to invoke a native task manager app and pull the results back using ProcessBuilder.
This is a script I made for an old project.
It checks if a specific process is running or not. ( in this case I put chrome.exe as an example )
command = ‘TASKLIST’, ‘/FI’, ‘imagename eq %s’ % processname
# shell=True hides the shell window, stdout to PIPE enables communicate() to get the tasklist command result
process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE)
# trimming it to the actual lines with information
process_out = process.communicate().strip().split(’\r\n’)
# if TASKLIST returns single line without processname: it’s not running
if len(process_out) > 1 and processname in process_out[-1]:
print(‘process “%s” is running!’ % processname)
print(‘process “%s” is NOT running!’ % processname)
This is perfect. Thank you very much.