Importing QGIS script parameters from another script

After my comments I add an example to try to help you.

I have Two script "A" and "B" and for in firts time execute the Script B ,and the user enter inputs for script (parameter_1 and parameter_2) and after execute Script A. I this script have a log that you can show print in a custom tab.

For get parameters values taht the user write in a Script B I'm using QSettings class.

Script A

import imp, os.path
from qgis.core import QgsMessageLog

Log = lambda m: QgsMessageLog.logMessage(m, 'Test Scripts')

def import_(filename):
    (path, name) = os.path.split(filename)
    (name, ext) = os.path.splitext(name)
    print name
    print path

    (file, filename, data) = imp.find_module(name, [path])
    return imp.load_module(name, file, filename, data)

foo = import_("C:\\Users\\fjraga\\.qgis2\\processing\\scripts\\b.py")
param1,param2=foo.getParameters()
Log("Parameter 1: "+ str(param1))
Log("Parameter 2: "+ str(param2))

#Other call
foo.CallFromA("Calling from A script")
#Name
n=foo.GetNameValue()
Log("Name : "+ str(n))

Script B

##parameter_1=string
##parameter_2=number
from PyQt4.QtCore import QSettings
from qgis.core import QgsMessageLog

Log = lambda m: QgsMessageLog.logMessage(m, 'Test Scripts')
name="My Name"
try:
    QSettings().setValue( '/myscript/processing/b/parameter_1', parameter_1 )
    QSettings().setValue( '/myscript/processing/b/parameter_2', parameter_2 )
except:
    None

def getParameters():
    parameter_1_out = QSettings().value( '/myscript/processing/b/parameter_1')
    parameter_2_out = QSettings().value( '/myscript/processing/b/parameter_2')
    return parameter_1_out,parameter_2_out

def CallFromA(value):
    Log(value)
    return 

def GetNameValue():
    return name

First,Execute B and write the inputs: enter image description here

And after execute A and you can show the logs messages,

enter image description here

I hope this helped you


Ok, this doesn’t really answer your question, but since I had the same problem, I thought you might be interested in the workaround I found:

In the QGIS Processing-Options that can be found in the processing menu (top of QGIS windows in the menu bar), under “Scripts” you can add a user defined path (by simply putting a “;” and start a new path) to the place where your scripts are stored, e.g. at a central storage. This way, QGIS will load the latest version of your scripts at startup. It would be necessary to modify this path in the installations of all your colleges, but ones done, your all set. And theoretically the second scripts wouldn’t be necessary, cause you will always end up with the latest “update” of your scripts.

Hope this helps.