Exemple #1
0
 def testGrass(self):
     '''Test GRASS is installed QGIS-89 (2)'''
     folder = ProcessingConfig.getSetting(GrassUtils.GRASS_FOLDER)
     ProcessingConfig.removeSetting(GrassUtils.GRASS_FOLDER)
     msg = GrassUtils.checkGrassIsInstalled()
     self.assertIsNone(msg)
     ProcessingConfig.setSettingValue(GrassUtils.GRASS_FOLDER, folder)
Exemple #2
0
    def qgis_session_info(self):
        # import re
        # from processing.algs.saga.SagaAlgorithmProvider import SagaAlgorithmProvider
        # from processing.algs.saga import SagaUtils
        # from processing.algs.grass.GrassUtils import GrassUtils
        # from processing.algs.grass7.Grass7Utils import Grass7Utils
        # from processing.algs.otb.OTBAlgorithmProvider import OTBAlgorithmProvider
        # from processing.algs.otb.OTBUtils import getInstalledVersion
        # from processing.algs.taudem.TauDEMUtils import TauDEMUtils
        # from osgeo import gdal
        # from processing.tools.system import isWindows, isMac
        # QGIS version
        qgis = QGis.QGIS_VERSION
        # GRASS versions
        # grassPath returns "" if called under Linux and if there is no GRASS
        # installation
        GrassUtils.checkGrassIsInstalled()
        g6 = GrassUtils.isGrassInstalled
        if g6 is True and isWindows():
            g6 = GrassUtils.grassPath()
            # extract everything followed by grass-, i.e. extract the version number
            g6 = re.findall("grass-(.*)", g6)
        if g6 is True and isMac():
            g6 = GrassUtils.grassPath()[0:21]
            g6 = os.listdir(g6)
            delim = ';'
            g6 = delim.join(g6)
            g6 = re.findall('[0-9].[0-9].[0-9]', g6)
        Grass7Utils.checkGrass7IsInstalled()
        g7 = Grass7Utils.isGrass7Installed
        if g7 is True and isWindows():
            g7 = Grass7Utils.grassPath()
            g7 = re.findall('grass-(.*)', g7)
        if g7 is True and isMac():
            g7 = Grass7Utils.grassPath()[0:21]
            g7 = os.listdir(g7)
            delim = ';'
            g7 = delim.join(g7)
            #g7 = re.findall(';(grass[0-9].);', g7)
            g7 = re.findall('[0-9].[0-9].[0-9]', g7)
        # installed SAGA version usable with QGIS
        saga = SagaUtils.getSagaInstalledVersion()
        # supported SAGA versions
        my_dict = SagaAlgorithmProvider.supportedVersions
        saga_versions = my_dict.keys()
        saga_versions.sort()

        # GDAL
        gdal_v = gdal.VersionInfo('VERSION_NUM')
        gdal_v = '.'.join([gdal_v[0], gdal_v[2], gdal_v[4]])

        ## this is good to have for the future, but so far, I would not report
        ## these software versions since we don't know if they actually work
        ## with QGIS (without additional functions such as run_taudem...)
        ## OTB versions
        # otb = getInstalledVersion()
        # otb = OTBUtils.getInstalledVersion()
        ## TauDEM versions (currently not in use because no function to extract
        ## Taudem version in 'TauDEMUtils')
        # TauDEMUtils.taudemMultifilePath()

        # finally, put it all into a named dictionary
        keys = ["qgis_version", "gdal", "grass6", "grass7", "saga",\
                "supported_saga_versions"]
        values = [qgis, gdal_v, g6, g7, saga, saga_versions]
        info = dict(zip(keys, values))
        return info
Exemple #3
0
 def qgis_session_info(self):
   # import re
   # from processing.algs.saga.SagaAlgorithmProvider import SagaAlgorithmProvider
   # from processing.algs.saga import SagaUtils
   # from processing.algs.grass.GrassUtils import GrassUtils
   # from processing.algs.grass7.Grass7Utils import Grass7Utils
   # from processing.algs.otb.OTBAlgorithmProvider import OTBAlgorithmProvider
   # from processing.algs.otb.OTBUtils import getInstalledVersion
   # from processing.algs.taudem.TauDEMUtils import TauDEMUtils
   # from osgeo import gdal
   # from processing.tools.system import isWindows, isMac
   # QGIS version
   qgis = QGis.QGIS_VERSION
   # GRASS versions
   # grassPath returns "" if called under Linux and if there is no GRASS 
   # installation
   GrassUtils.checkGrassIsInstalled()
   g6 = GrassUtils.isGrassInstalled
   if g6 is True and isWindows():
     g6 = GrassUtils.grassPath()
     # extract everything followed by grass-, i.e. extract the version number
     g6 = re.findall("grass-(.*)", g6)
   if g6 is True and isMac():
     g6 = GrassUtils.grassPath()[0:21]
     g6 = os.listdir(g6)
     delim = ';'
     g6 = delim.join(g6)
     g6 = re.findall('[0-9].[0-9].[0-9]', g6)
   Grass7Utils.checkGrass7IsInstalled()
   g7 = Grass7Utils.isGrass7Installed
   if g7 is True and isWindows():
     g7 = Grass7Utils.grassPath()
     g7 = re.findall('grass-(.*)',  g7)
   if g7 is True and isMac():
     g7 = Grass7Utils.grassPath()[0:21]
     g7 = os.listdir(g7)
     delim = ';'
     g7 = delim.join(g7)
     #g7 = re.findall(';(grass[0-9].);', g7)
     g7 = re.findall('[0-9].[0-9].[0-9]', g7)
   # installed SAGA version usable with QGIS
   saga = SagaUtils.getSagaInstalledVersion()
   # supported SAGA versions
   try:
     # supportedVersions were deleted from SagaAlgorithmProvider since 
     # QGIS 2.18.10. At least this is the case with custom applications...
     my_dict = SagaAlgorithmProvider.supportedVersions
     saga_versions = my_dict.keys()
     saga_versions.sort()
   except:
     # with QGIS 2.18.10 only SAGA 2.3.0 and 2.3.1 is suppported 
     # well, observe next QGIS releases and try to avoid the hard-coding!
     saga_versions = [""]
   # GDAL
   gdal_v = gdal.VersionInfo('VERSION_NUM')
   gdal_v = '.'.join([gdal_v[0], gdal_v[2], gdal_v[4]])
   
   ## this is good to have for the future, but so far, I would not report 
   ## these software versions since we don't know if they actually work
   ## with QGIS (without additional functions such as run_taudem...)
   ## OTB versions
   # otb = getInstalledVersion()
   # otb = OTBUtils.getInstalledVersion()
   ## TauDEM versions (currently not in use because no function to extract
   ## Taudem version in 'TauDEMUtils')
   # TauDEMUtils.taudemMultifilePath()
   
   # finally, put it all into a named dictionary
   keys = ["qgis_version", "gdal", "grass6", "grass7", "saga",\
           "supported_saga_versions"]
   values = [qgis, gdal_v, g6, g7, saga, saga_versions]
   info = dict(zip(keys, values))
   return info
 # verify if the provider is well installed
 if provider.getName() == 'saga':
     from processing.algs.saga.SagaUtils import SagaUtils
     msg = SagaUtils.checkSagaIsInstalled()
     if msg:
         logging.info(msg)
         continue
 elif provider.getName() == 'r':
     from processing.algs.r.RUtils import RUtils
     msg = RUtils.checkRIsInstalled()
     if msg:
         logging.info(msg)
         continue
 elif provider.getName() == 'grass':
     from processing.algs.grass.GrassUtils import GrassUtils
     msg = GrassUtils.checkGrassIsInstalled()
     if msg:
         logging.info(msg)
         continue
 elif provider.getName() == 'grass7':
     from processing.algs.grass.Grass7Utils import Grass7Utils
     msg = Grass7Utils.checkGrass7IsInstalled()
     if msg:
         logging.info(msg)
         continue
 #logging.info( provider.getName()+' active and install')
 # sort algorithms
 sortedlist = sorted(provider.algs, key=lambda alg: alg.name)
 for alg in sortedlist:
     if algList and str( alg.commandLineName() ) not in algList :
         continue;