当前位置: 首页>>代码示例>>Python>>正文


Python SextanteUtils.userFolder方法代码示例

本文整理汇总了Python中sextante.core.SextanteUtils.SextanteUtils.userFolder方法的典型用法代码示例。如果您正苦于以下问题:Python SextanteUtils.userFolder方法的具体用法?Python SextanteUtils.userFolder怎么用?Python SextanteUtils.userFolder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sextante.core.SextanteUtils.SextanteUtils的用法示例。


在下文中一共展示了SextanteUtils.userFolder方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: executeGrass

# 需要导入模块: from sextante.core.SextanteUtils import SextanteUtils [as 别名]
# 或者: from sextante.core.SextanteUtils.SextanteUtils import userFolder [as 别名]
 def executeGrass(commands, progress):
     if SextanteUtils.isWindows():
         GrassUtils.createGrassScript(commands)
         command = ["cmd.exe", "/C ", GrassUtils.grassScriptFilename()]
     else:
         gisrc =  SextanteUtils.userFolder() + os.sep + "sextante.gisrc"
         os.putenv("GISRC", gisrc)
         os.putenv("GRASS_MESSAGE_FORMAT", "gui")
         os.putenv("GRASS_BATCH_JOB", GrassUtils.grassBatchJobFilename())
         GrassUtils.createGrassBatchJobFileFromGrassCommands(commands)
         os.chmod(GrassUtils.grassBatchJobFilename(), stat.S_IEXEC | stat.S_IREAD | stat.S_IWRITE)
         if SextanteUtils.isMac():
             command = GrassUtils.grassPath() + os.sep + "grass.sh " + GrassUtils.grassMapsetFolder() + "/user"
         else:
             command = "grass64 " + GrassUtils.grassMapsetFolder() + "/user"
     loglines = []
     loglines.append("GRASS execution console output")
     proc = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stdin=subprocess.PIPE,stderr=subprocess.STDOUT, universal_newlines=True).stdout
     for line in iter(proc.readline, ""):
         if "GRASS_INFO_PERCENT" in line:
             try:
                 progress.setPercentage(int(line[len("GRASS_INFO_PERCENT")+ 2:]))
             except:
                 pass
         else:
             loglines.append(line)
             progress.setConsoleInfo(line)
     if SextanteConfig.getSetting(GrassUtils.GRASS_LOG_CONSOLE):
         SextanteLog.addToLog(SextanteLog.LOG_INFO, loglines)
     shutil.rmtree(GrassUtils.grassMapsetFolder(), True)
开发者ID:mokerjoke,项目名称:Quantum-GIS,代码行数:32,代码来源:GrassUtils.py

示例2: RScriptsFolder

# 需要导入模块: from sextante.core.SextanteUtils import SextanteUtils [as 别名]
# 或者: from sextante.core.SextanteUtils.SextanteUtils import userFolder [as 别名]
    def RScriptsFolder():
        folder = SextanteConfig.getSetting(RUtils.RSCRIPTS_FOLDER)
        if folder == None:
            folder = unicode(os.path.join(SextanteUtils.userFolder(), "rscripts"))
        mkdir(folder)

        return os.path.abspath(folder)
开发者ID:Adam-Brown,项目名称:Quantum-GIS,代码行数:9,代码来源:RUtils.py

示例3: modelsFolder

# 需要导入模块: from sextante.core.SextanteUtils import SextanteUtils [as 别名]
# 或者: from sextante.core.SextanteUtils.SextanteUtils import userFolder [as 别名]
    def modelsFolder():
        folder = SextanteConfig.getSetting(ModelerUtils.MODELS_FOLDER)
        if folder == None:
            folder = unicode(os.path.join(SextanteUtils.userFolder(), "models"))
        mkdir(folder)

        return os.path.abspath(folder)
开发者ID:Adam-Brown,项目名称:Quantum-GIS,代码行数:9,代码来源:ModelerUtils.py

示例4: modelsFolder

# 需要导入模块: from sextante.core.SextanteUtils import SextanteUtils [as 别名]
# 或者: from sextante.core.SextanteUtils.SextanteUtils import userFolder [as 别名]
    def modelsFolder():
        folder = SextanteConfig.getSetting(ModelerUtils.MODELS_FOLDER)
        if folder == None:
            folder = SextanteUtils.userFolder() + os.sep + "models"
        mkdir(folder)

        return folder
开发者ID:hCivil,项目名称:Quantum-GIS,代码行数:9,代码来源:ModelerUtils.py

示例5: scriptsFolder

# 需要导入模块: from sextante.core.SextanteUtils import SextanteUtils [as 别名]
# 或者: from sextante.core.SextanteUtils.SextanteUtils import userFolder [as 别名]
    def scriptsFolder():
        folder = SextanteConfig.getSetting(ScriptUtils.SCRIPTS_FOLDER)
        if folder == None:
            folder = SextanteUtils.userFolder() + os.sep + "scripts"
        mkdir(folder)

        return folder
开发者ID:hCivil,项目名称:Quantum-GIS,代码行数:9,代码来源:ScriptUtils.py

示例6: sagaBatchJobFilename

# 需要导入模块: from sextante.core.SextanteUtils import SextanteUtils [as 别名]
# 或者: from sextante.core.SextanteUtils.SextanteUtils import userFolder [as 别名]
    def sagaBatchJobFilename():

        if SextanteUtils.isWindows():
            filename = "saga_batch_job.bat";
        else:
            filename = "saga_batch_job.sh";

        batchfile = SextanteUtils.userFolder() + os.sep + filename

        return batchfile
开发者ID:geonux,项目名称:Quantum-GIS,代码行数:12,代码来源:SagaUtils.py

示例7: createGrassScript

# 需要导入模块: from sextante.core.SextanteUtils import SextanteUtils [as 别名]
# 或者: from sextante.core.SextanteUtils.SextanteUtils import userFolder [as 别名]
    def createGrassScript(commands):
        folder = GrassUtils.grassPath()
        shell = GrassUtils.grassWinShell()

        script = GrassUtils.grassScriptFilename()
        gisrc =  SextanteUtils.userFolder() + os.sep + "sextante.gisrc"

        #temporary gisrc file
        output = open(gisrc, "w")
        location = "temp_location"
        mapset = "user"
        gisdbase = GrassUtils.grassDataFolder()
        #gisdbase = os.path.join(os.path.expanduser("~"), "sextante", "tempdata", "grassdata")
        output.write("GISDBASE: " + gisdbase + "\n");
        output.write("LOCATION_NAME: " + location + "\n");
        output.write("MAPSET: " + mapset + "\n");
        output.write("GRASS_GUI: text\n");
        output.close()

        output=open(script, "w")
        output.write("set HOME=" + os.path.expanduser("~") + "\n");
        output.write("set GISRC=" + gisrc + "\n")
        output.write("set GRASS_SH=" + shell + "\\bin\\sh.exe\n")
        output.write("set PATH=" + shell + os.sep + "bin;" + shell + os.sep + "lib;" + "%PATH%\n")
        output.write("set WINGISBASE=" + folder + "\n")
        output.write("set GISBASE=" + folder + "\n");
        output.write("set GRASS_PROJSHARE=" + folder + os.sep + "share" + os.sep + "proj" + "\n")
        output.write("set GRASS_MESSAGE_FORMAT=gui\n")
        #Replacement code for etc/Init.bat
        output.write("if \"%GRASS_ADDON_PATH%\"==\"\" set PATH=%WINGISBASE%\\bin;%WINGISBASE%\\lib;%PATH%\n")
        output.write("if not \"%GRASS_ADDON_PATH%\"==\"\" set PATH=%WINGISBASE%\\bin;%WINGISBASE%\\lib;%GRASS_ADDON_PATH%;%PATH%\n")
        output.write("\n")
        output.write("set GRASS_VERSION=" + GrassUtils.getGrassVersion() + "\n")
        output.write("if not \"%LANG%\"==\"\" goto langset\n")
        output.write("FOR /F \"usebackq delims==\" %%i IN (`\"%WINGISBASE%\\etc\\winlocale\"`) DO @set LANG=%%i\n")
        output.write(":langset\n")
        output.write("\n")
        output.write("set PATHEXT=%PATHEXT%;.PY\n")
        output.write("set PYTHONPATH=%PYTHONPATH%;%WINGISBASE%\\etc\\python;%WINGISBASE%\\etc\\wxpython\\n")
        output.write("\n")
        output.write("g.gisenv.exe set=\"MAPSET=" + mapset + "\"\n")
        output.write("g.gisenv.exe set=\"LOCATION=" + location + "\"\n")
        output.write("g.gisenv.exe set=\"LOCATION_NAME=" + location + "\"\n")
        output.write("g.gisenv.exe set=\"GISDBASE=" + gisdbase + "\"\n")
        output.write("g.gisenv.exe set=\"GRASS_GUI=text\"\n")
        for command in commands:
            output.write(command + "\n")
        output.write("\n");
        output.write("exit\n");
        output.close();
开发者ID:homann,项目名称:Quantum-GIS,代码行数:52,代码来源:GrassUtils.py

示例8: prepareGrassExecution

# 需要导入模块: from sextante.core.SextanteUtils import SextanteUtils [as 别名]
# 或者: from sextante.core.SextanteUtils.SextanteUtils import userFolder [as 别名]
    def prepareGrassExecution(commands):
        if SextanteUtils.isWindows():
            GrassUtils.createGrassScript(commands)
            command = ["cmd.exe", "/C ", GrassUtils.grassScriptFilename()]
        else:
            gisrc =  SextanteUtils.userFolder() + os.sep + "sextante.gisrc"
            os.putenv("GISRC", gisrc)
            os.putenv("GRASS_MESSAGE_FORMAT", "gui")
            os.putenv("GRASS_BATCH_JOB", GrassUtils.grassBatchJobFilename())
            GrassUtils.createGrassBatchJobFileFromGrassCommands(commands)
            os.chmod(GrassUtils.grassBatchJobFilename(), stat.S_IEXEC | stat.S_IREAD | stat.S_IWRITE)
            if SextanteUtils.isMac():
                command = GrassUtils.grassPath() + os.sep + "grass.sh " + GrassUtils.grassMapsetFolder() + "/PERMANENT"
            else:
                command = "grass64 " + GrassUtils.grassMapsetFolder() + "/PERMANENT"

        return command
开发者ID:Nald,项目名称:Quantum-GIS,代码行数:19,代码来源:GrassUtils.py

示例9: getImportCommands

# 需要导入模块: from sextante.core.SextanteUtils import SextanteUtils [as 别名]
# 或者: from sextante.core.SextanteUtils.SextanteUtils import userFolder [as 别名]
    def getImportCommands(self):
        commands = []
        # if rgdal is not available, try to install it
        # just use main mirror
        commands.append('options("repos"="http://cran.at.r-project.org/")')
        rLibDir = "%s/rlibs" % SextanteUtils.userFolder().replace("\\","/")
        if not os.path.isdir(rLibDir):
            os.mkdir(rLibDir)
        # .libPaths("%s") substitutes the personal libPath with "%s"! With '.libPaths(c("%s",deflibloc))' it is added without replacing and we can use all installed R packages!
        commands.append('deflibloc <- .libPaths()[1]')
        commands.append('.libPaths(c("%s",deflibloc))' % rLibDir )
        commands.append(
            'tryCatch(find.package("rgdal"), error=function(e) install.packages("rgdal", dependencies=TRUE, lib="%s"))' % rLibDir)
        commands.append("library(\"rgdal\")");
        if not self.useRasterPackage or self.passFileNames:
            commands.append(
                'tryCatch(find.package("raster"), error=function(e) install.packages("raster", dependencies=TRUE, lib="%s"))' % rLibDir)
            commands.append("library(\"raster\")");
            
        for param in self.parameters:
            if isinstance(param, ParameterRaster):
                value = param.value
                value = value.replace("\\", "/")
                if self.passFileNames:
                    commands.append(param.name + " = \"" + value + "\"")
                elif self.useRasterPackage:
                    commands.append(param.name + " = " + "brick(\"" + value + "\")")
                else:
                    commands.append(param.name + " = " + "readGDAL(\"" + value + "\")")
            if isinstance(param, ParameterVector):
                value = param.getSafeExportedLayer()
                value = value.replace("\\", "/")
                filename = os.path.basename(value)
                filename = filename[:-4]
                folder = os.path.dirname(value)
                if self.passFileNames:
                    commands.append(param.name + " = \"" + value + "\"")
                else:
                    commands.append(param.name + " = readOGR(\"" + folder + "\",layer=\"" + filename + "\")")
            if isinstance(param, ParameterTable):
                value = param.value
                if not value.lower().endswith("csv"):
                    raise GeoAlgorithmExecutionException("Unsupported input file format.\n" + value)
                if self.passFileNames:
                    commands.append(param.name + " = \"" + value + "\"")
                else:
                    commands.append(param.name + " <- read.csv(\"" + value + "\", head=TRUE, sep=\",\")")
            elif isinstance(param, (ParameterTableField, ParameterString, ParameterFile)):
                commands.append(param.name + "=\"" + param.value + "\"")
            elif isinstance(param, (ParameterNumber, ParameterSelection)):
                commands.append(param.name + "=" + str(param.value))
            elif isinstance(param, ParameterBoolean):
                if param.value:
                    commands.append(param.name + "=TRUE")
                else:
                    commands.append(param.name + "=FALSE")
            elif isinstance(param, ParameterMultipleInput):
                iLayer = 0;
                if param.datatype == ParameterMultipleInput.TYPE_RASTER:
                    layers = param.value.split(";")
                    for layer in layers:
                        #if not layer.lower().endswith("asc") and not layer.lower().endswith("tif") and not self.passFileNames:
                            #raise GeoAlgorithmExecutionException("Unsupported input file format.\n" + layer)
                        layer = layer.replace("\\", "/")
                        if self.passFileNames:
                            commands.append("tempvar" + str(iLayer)+ " <- \"" + layer + "\"")
                        elif self.useRasterPackage:
                            commands.append("tempvar" + str(iLayer)+ " <- " + "brick(\"" + layer + "\")")
                        else:
                            commands.append("tempvar" + str(iLayer)+ " <- " + "readGDAL(\"" + layer + "\")")
                        iLayer+=1
                else:
                    exported = param.getSafeExportedLayers()
                    layers = exported.split(";")
                    for layer in layers:
                        if not layer.lower().endswith("shp") and not self.passFileNames:
                            raise GeoAlgorithmExecutionException("Unsupported input file format.\n" + layer)
                        layer = layer.replace("\\", "/")
                        filename = os.path.basename(layer)
                        filename = filename[:-4]
                        if self.passFileNames:
                            commands.append("tempvar" + str(iLayer)+ " <- \"" + layer + "\"")
                        else:
                            commands.append("tempvar" + str(iLayer) + " <- " + "readOGR(\"" + layer + "\",layer=\"" + filename + "\")")
                        iLayer+=1
                s = ""
                s += param.name
                s += (" = c(")
                iLayer = 0
                for layer in layers:
                    if iLayer != 0:
                        s +=","
                    s += "tempvar" + str(iLayer)
                    iLayer += 1
                s+=")\n"
                commands.append(s)

        if self.showPlots:
            htmlfilename = self.getOutputValue(RAlgorithm.RPLOTS)
            self.plotsFilename = htmlfilename +".png"
#.........这里部分代码省略.........
开发者ID:jietaowang,项目名称:Quantum-GIS,代码行数:103,代码来源:RAlgorithm.py

示例10: WpsDescriptionFolder

# 需要导入模块: from sextante.core.SextanteUtils import SextanteUtils [as 别名]
# 或者: from sextante.core.SextanteUtils.SextanteUtils import userFolder [as 别名]
 def WpsDescriptionFolder():
     folder = SextanteConfig.getSetting(WpsAlgorithmProvider.WPS_DESCRIPTIONS)
     if folder == None:
         folder = unicode(os.path.join(SextanteUtils.userFolder(), "wps"))
     mkdir(folder)
     return os.path.abspath(folder)
开发者ID:bpross-52n,项目名称:qgis-wps-client,代码行数:8,代码来源:WpsAlgorithmProvider.py

示例11: getRScriptFilename

# 需要导入模块: from sextante.core.SextanteUtils import SextanteUtils [as 别名]
# 或者: from sextante.core.SextanteUtils.SextanteUtils import userFolder [as 别名]
 def getRScriptFilename():
     return SextanteUtils.userFolder() + os.sep + "sextante_script.r"
开发者ID:Adam-Brown,项目名称:Quantum-GIS,代码行数:4,代码来源:RUtils.py

示例12: classificationFile

# 需要导入模块: from sextante.core.SextanteUtils import SextanteUtils [as 别名]
# 或者: from sextante.core.SextanteUtils.SextanteUtils import userFolder [as 别名]
 def classificationFile():
     return os.path.join(SextanteUtils.userFolder(), "sextante_qgis_algclass.txt")
开发者ID:Nald,项目名称:Quantum-GIS,代码行数:4,代码来源:AlgorithmClassification.py

示例13: grassScriptFilename

# 需要导入模块: from sextante.core.SextanteUtils import SextanteUtils [as 别名]
# 或者: from sextante.core.SextanteUtils.SextanteUtils import userFolder [as 别名]
 def grassScriptFilename():
     '''this is used in windows. We create a script that initializes
     GRASS and then uses grass commands'''
     filename = "grass_script.bat"
     filename = SextanteUtils.userFolder() + os.sep + filename
     return filename
开发者ID:Nald,项目名称:Quantum-GIS,代码行数:8,代码来源:GrassUtils.py

示例14: grassBatchJobFilename

# 需要导入模块: from sextante.core.SextanteUtils import SextanteUtils [as 别名]
# 或者: from sextante.core.SextanteUtils.SextanteUtils import userFolder [as 别名]
 def grassBatchJobFilename():
     '''This is used in linux. This is the batch job that we assign to
     GRASS_BATCH_JOB and then call GRASS and let it do the work'''
     filename = "grass_batch_job.sh"
     batchfile = SextanteUtils.userFolder() + os.sep + filename
     return batchfile
开发者ID:Nald,项目名称:Quantum-GIS,代码行数:8,代码来源:GrassUtils.py

示例15: configFile

# 需要导入模块: from sextante.core.SextanteUtils import SextanteUtils [as 别名]
# 或者: from sextante.core.SextanteUtils.SextanteUtils import userFolder [as 别名]
 def configFile():
     return os.path.join(SextanteUtils.userFolder(), "sextante_qgis.conf")
开发者ID:Adam-Brown,项目名称:Quantum-GIS,代码行数:4,代码来源:SextanteConfig.py


注:本文中的sextante.core.SextanteUtils.SextanteUtils.userFolder方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。