[processing] add function to retrieve Processing version

Initial idea by Etienne Trimaille
This commit is contained in:
Alexander Bruy 2016-04-01 11:25:00 +03:00
parent 687b6fdeaa
commit 9c96be1214
2 changed files with 13 additions and 0 deletions

View File

@ -54,6 +54,8 @@ class AlgorithmsTest:
"""
This is the main test function. All others will be executed based on the definitions in testdata/algorithm_tests.yaml
"""
ver = processing.version()
print "Processing {}.{}.{}".format(ver / 10000, ver / 100 % 100, ver % 100)
with open(os.path.join(processingTestDataPath(), self.test_definition_file()), 'r') as stream:
algorithm_tests = yaml.load(stream)

View File

@ -25,6 +25,9 @@ __copyright__ = '(C) 2013, Victor Olaya'
__revision__ = '$Format:%H$'
import os
import ConfigParser
from processing.core.Processing import Processing
from processing.gui.Postprocessing import handleAlgorithmResults
from processing.core.parameters import ParameterSelection
@ -75,3 +78,11 @@ def runalg(algOrName, *args, **kwargs):
def runandload(name, *args, **kwargs):
return Processing.runAlgorithm(name, handleAlgorithmResults, *args, **kwargs)
def version():
pluginPath = os.path.split(os.path.dirname(__file__))[0]
cfg = ConfigParser.SafeConfigParser()
cfg.read(os.path.join(pluginPath, 'metadata.txt'))
ver = cfg.get('general', 'version').split('.')
return 10000 * int(ver[0]) + 100 * int(ver[1]) + int(ver[2])