How can I use app instance and use it in importing code [solved]

Hi I trying to get access to
app.projectName.getValue()
app.projectPath.getValue()
variables

in some automation for my working those options:
nn = natron.getActiveInstance()
ID = nn.getAppID()
app = natron.getGuiInstance(ID)
selectedNodes = app.getSelectedNodes()
or
app = natron.getGuiInstance(0)
app.selectAllNodes(app)

In general I think that first varian better
But when I trying to do same thing with like this
if app.projectName.getValue() == “Untitled.ntp”:
print app.projectName.getValue()

I am trying to check some information about project like (name and scene information ) I resived - Error about … func is not a property of object … Ok
main program is singelton and we need to get instance … But in deferent places it’s working correctly?

if I use in script editor string like this
app1.projectName.getValue()
all well done

My variant is creating “project” node and setup correct paths for scene in it.

But how can use this function projectName.getValue() stable from script to script?

Thank you!

I find a simple way for 100% guarantee have instance of natronGUI
for this i used to global variable:


conf.py
def init(app_in):
global app
app = []
app.append(app_in)

def natron_app():
return app[0]


init.py
def Project_Callback(app):
conf.init(app)


node_organize.py
app = conf.natron_app()
print app.projectPath.getValue()
print app.projectName.getValue()

It is solution is not very beautiful, but for my it stable working

Everytime I open natron , I see the following message on ScriptEditor

Capture

should I use this definition of global variable to solve it ?