def doGet(request, session):
import operator
from com.inductiveautomation.ignition.gateway import IgnitionGateway
results = []
context = IgnitionGateway.get()
for project in context.getProjectManager().projectNames:
results.append({
'name': project
})
results = sorted(results, key=operator.itemgetter('name'))
return {
'json': {
'parameters': {},
'totalResults': len(results),
'projects': results
}
}
I know this is an old thread but posing because I had the same question and was struggling with some of the other solutions.
There is a system function that will return a list of project on a gateway.
https://docs.inductiveautomation.com/display/DOC81/system.project.getProjectNames
I was curious, so I did a quick search and found this:
It looks like this was added in 2020, but looking at the posts on this thread between 2020 and now; most of them have strayed a bit from the original topic, so I guess it makes sense that they don't mention this.
Hi John,
Did you find an answer to this question?
I'm looking for the same information and was surprised that the info is not included in the getProjectInfo() function.
I'm using the IgnitionGateway context to return a list of projects as suggested above.
How can I filter to only return runnable projects? Thought there might be a flag or something indicting if it is inheritable or not stashed in the .getProjectProps() function, but I can't decipher which of the many objects returned it might be held in.
Call ProjectManagerBase::getProject
and then Project::isRunnable
.
Thanks Kevin. Appreciate you working on a Saturday too!
Got this working with...
from com.inductiveautomation.ignition.gateway import IgnitionGateway
ign = IgnitionGateway.get().getProjectManager()
options = []
for project in list(ign.projectNames):
obj = ign.getProject(project).get()
system.perspective.print('%s %s %s'%(project, obj.isRunnable(), obj.getDescription()))
if obj.isRunnable(): options.append({'label': project, 'value': project})
return options