System.perspective.getSessionInfo()

Hi guys, as I know that Ignition gateway has a page called Perspective Sessions. May I know that it is possible to display all the data there in my project and display in a table format. From what I research I know that there is a script called ( System.perspective.getSessionInfo() ) can do it but I had try many times already it still cant work for me. May I know that anyone here have the example of these script.

Thanks in advance

	sessions = system.perspective.getSessionInfo()
	data = []
	for session in sessions:
		keys = session.keys()
		newRow = []
		for key in keys:
			newRow.append(str(session[key]))
		data.append(newRow)
	self.getSibling("Table").props.data = system.dataset.toDataSet(keys, data)

Can u please help me to get name , title and description from this syntax
system.perspective.getProjectInfo()
I tried the above methods , but couldn’t find.

For easy reference: system.perspective.getProjectInfo - Ignition User Manual 8.1 - Ignition Documentation

projectInfo = system.perspective.getProjectInfo()

name = projectInfo['name']
title = projectInfo['title']
description = projectInfo['description']
1 Like

I had tried this in the gateway scope and it is pushing the error, don’t know what I had done is wrong, the same script that you had gave even I tried. Anything specific that I need to check??

com.inductiveautomation.ignition.common.script.JythonExecException: Traceback (most recent call last): File “”, line 1, in at com.inductiveautomation.perspective.gateway.script.PerspectiveScriptingFunctions.lambda$getProjectInfo$26(PerspectiveScriptingFunctions.java:853) at java.base/java.util.Optional.orElseThrow(Unknown Source) at com.inductiveautomation.perspective.gateway.script.PerspectiveScriptingFunctions.getProjectInfo(PerspectiveScriptingFunctions.java:853) at jdk.internal.reflect.GeneratedMethodAccessor95.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) java.lang.IllegalArgumentException: java.lang.IllegalArgumentException: No perspective session attached to this thread.

at org.python.core.Py.JavaError(Py.java:547)

at org.python.core.Py.JavaError(Py.java:538)

at org.python.core.PyReflectedFunction.call(PyReflectedFunction.java:192)

at com.inductiveautomation.ignition.common.script.ScriptManager$ReflectedInstanceFunction.call(ScriptManager.java:541)

at org.python.core.PyObject.call(PyObject.java:446)

at org.python.core.PyObject.call(PyObject.java:450)

at org.python.pycode._pyx7.f$0(:6)

at org.python.pycode._pyx7.call_function()

at org.python.core.PyTableCode.call(PyTableCode.java:173)

at org.python.core.PyCode.call(PyCode.java:18)

at org.python.core.Py.runCode(Py.java:1687)

at com.inductiveautomation.ignition.common.script.ScriptManager.runCode(ScriptManager.java:788)

at com.inductiveautomation.ignition.gateway.project.ProjectScriptLifecycle$TrackingProjectScriptManager.runCode(ProjectScriptLifecycle.java:797)

at com.inductiveautomation.ignition.common.script.ScriptManager.runCode(ScriptManager.java:740)

at com.inductiveautomation.ignition.gateway.project.ProjectScriptLifecycle$TrackingProjectScriptManager.runCode(ProjectScriptLifecycle.java:778)

at com.inductiveautomation.ignition.common.script.TimerScriptTask.run(TimerScriptTask.java:90)

at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)

at java.base/java.util.concurrent.FutureTask.runAndReset(Unknown Source)

at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)

at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)

at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

at java.base/java.lang.Thread.run(Unknown Source)

Caused by: org.python.core.PyException: java.lang.IllegalArgumentException: java.lang.IllegalArgumentException: No perspective session attached to this thread.

… 22 common frames omitted

Caused by: java.lang.IllegalArgumentException: No perspective session attached to this thread.

at com.inductiveautomation.perspective.gateway.script.PerspectiveScriptingFunctions.lambda$getProjectInfo$26(PerspectiveScriptingFunctions.java:853)

at java.base/java.util.Optional.orElseThrow(Unknown Source)

at com.inductiveautomation.perspective.gateway.script.PerspectiveScriptingFunctions.getProjectInfo(PerspectiveScriptingFunctions.java:853)

at jdk.internal.reflect.GeneratedMethodAccessor95.invoke(Unknown Source)

at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.base/java.lang.reflect.Method.invoke(Unknown Source)

at org.python.core.PyReflectedFunction.call(PyReflectedFunction.java:190)

Of course it will fail since the mentioned fucntion needs to be executed in the CS scope.
Just put in a button or somewhere within the the client or session. Gateway is not the place for it!

1 Like

Thanks, It worked, one more doubt Is there any way that I can get all the perspective project alone. I don’t want any vision project list.

system.perspective.getProjectInfo() only returns info about perspective projects.

Also, it is available in the gateway scope, so I would expect it to execute just fine from a gateway script.

Perhaps @cmallonee can give a bit more information?

Thanks for the information, I tried that, its showing some errors. Can someone help me on this I want to get all perspective projects from the gateway(atleast project names.). Is there any way to do that?