I've got a project script that is having trouble accessing one of it's global variables.
ignitionName = '/ignition-desktop-av4v6h5:'
def historyPathConvert_MasterToEdge(self):
#if this is an edge panel the path needs to be updated
if self.parent.parent.edge:
#get the current pens dataset
penData = system.dataset.toPyDataSet(self.tagPens)
#get headers for the dataset
headers = list(penData.getColumnNames())
#initialize empty list
newPenData = []
#get the index for the tag path column
TAG_PATH_index = penData.getColumnIndex('TAG_PATH')
#for each row in the pen dataset
for row in penData:
#create row as a list
newRow = list(row)
#update the tag path to the tag provider
newRow[TAG_PATH_index] = row[TAG_PATH_index].replace(Trending.ignitionName,'/')
#append the row to the list
newPenData.append(newRow)
#create dataset from list and assign to dataset
data = system.dataset.toDataSet(headers, newPenData)
if data is not None:
self.tagPens = data
This script comes back with an error on line 27 when I try and do the string replacement with the pre-defined global string. It's acting like the global variable doesn't exist, even though it auto-completes
Traceback (most recent call last):
File "<event:actionPerformed>", line 1, in <module>
File "<custom-function updatePaths>", line 7, in updatePaths
File "<module:Trending>", line 27, in historyPathConvert_MasterToEdge
AttributeError: 'com.inductiveautomation.ignition.common.script.Pro' object has no attribute 'ignitionName'
at org.python.core.Py.AttributeError(Py.java:178)
at org.python.core.PyObject.noAttributeError(PyObject.java:965)
at org.python.core.PyObject.__getattr__(PyObject.java:959)
at org.python.pycode._pyx292.historyPathConvert_MasterToEdge$1(<module:Trending>:35)
at org.python.pycode._pyx292.call_function(<module:Trending>)
at org.python.core.PyTableCode.call(PyTableCode.java:173)
at org.python.core.PyBaseCode.call(PyBaseCode.java:134)
at org.python.core.PyFunction.__call__(PyFunction.java:416)
at org.python.pycode._pyx294.updatePaths$1(<custom-function updatePaths>:7)
at org.python.pycode._pyx294.call_function(<custom-function updatePaths>)
at org.python.core.PyTableCode.call(PyTableCode.java:173)
at org.python.core.PyBaseCode.call(PyBaseCode.java:134)
at org.python.core.PyFunction.__call__(PyFunction.java:416)
at org.python.core.PyMethod.__call__(PyMethod.java:126)
at org.python.pycode._pyx293.f$0(<event:actionPerformed>:1)
at org.python.pycode._pyx293.call_function(<event:actionPerformed>)
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:803)
at com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter.runActions(ActionAdapter.java:207)
at com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter.invoke(ActionAdapter.java:300)
at com.inductiveautomation.factorypmi.application.binding.action.RelayInvocationHandler.invoke(RelayInvocationHandler.java:57)
at com.sun.proxy.$Proxy52.actionPerformed(Unknown Source)
at java.desktop/javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at java.desktop/javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at java.desktop/javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at java.desktop/javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at java.desktop/javax.swing.plaf.basic.BasicButtonListener.focusLost(Unknown Source)
at java.desktop/java.awt.AWTEventMulticaster.focusLost(Unknown Source)
at java.desktop/java.awt.AWTEventMulticaster.focusLost(Unknown Source)
at java.desktop/java.awt.Component.processFocusEvent(Unknown Source)
at java.desktop/java.awt.Component.processEvent(Unknown Source)
at java.desktop/java.awt.Container.processEvent(Unknown Source)
at java.desktop/java.awt.Component.dispatchEventImpl(Unknown Source)
at java.desktop/java.awt.Container.dispatchEventImpl(Unknown Source)
at java.desktop/java.awt.Component.dispatchEvent(Unknown Source)
at java.desktop/java.awt.KeyboardFocusManager.redispatchEvent(Unknown Source)
at java.desktop/java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(Unknown Source)
at java.desktop/java.awt.DefaultKeyboardFocusManager.dispatchEvent(Unknown Source)
at java.desktop/java.awt.Component.dispatchEventImpl(Unknown Source)
at java.desktop/java.awt.Container.dispatchEventImpl(Unknown Source)
at java.desktop/java.awt.Component.dispatchEvent(Unknown Source)
at java.desktop/java.awt.KeyboardFocusManager.dispatchAndCatchException(Unknown Source)
at java.desktop/java.awt.KeyboardFocusManager.processCurrentLightweightRequests(Unknown Source)
at java.desktop/java.awt.KeyboardFocusManager$4.run(Unknown Source)
at java.desktop/java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.desktop/java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.desktop/java.awt.EventQueue$4.run(Unknown Source)
at java.desktop/java.awt.EventQueue$4.run(Unknown Source)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.desktop/java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.desktop/java.awt.EventDispatchThread.run(Unknown Source)
Ignition v8.1.27 (b2023042509)
Java: Azul Systems, Inc. 11.0.18
What am I missing?