Beispiel #1
0
    def RScriptsFolder():
        folder = ProcessingConfig.getSetting(RUtils.RSCRIPTS_FOLDER)
        if folder == None:
            folder = unicode(os.path.join(ProcessingUtils.userFolder(), "rscripts"))
        mkdir(folder)

        return os.path.abspath(folder)
Beispiel #2
0
    def createGrassScript(commands):
        folder = GrassUtils.grassPath()
        shell = GrassUtils.grassWinShell()

        script = GrassUtils.grassScriptFilename()
        gisrc = ProcessingUtils.userFolder() + os.sep + "processing.gisrc"

        #temporary gisrc file
        output = open(gisrc, "w")
        location = "temp_location"
        gisdbase = GrassUtils.grassDataFolder()
        #gisdbase = os.path.join(os.path.expanduser("~"), "processing", "tempdata", "grassdata")
        output.write("GISDBASE: " + gisdbase + "\n")
        output.write("LOCATION_NAME: " + location + "\n")
        output.write("MAPSET: PERMANENT \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=PERMANENT\"\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()
Beispiel #3
0
 def WpsDescriptionFolder():
     folder = ProcessingConfig.getSetting(
         WpsAlgorithmProvider.WPS_DESCRIPTIONS)
     if folder == None:
         folder = str(os.path.join(ProcessingUtils.userFolder(), "wps"))
     mkdir(folder)
     return os.path.abspath(folder)
Beispiel #4
0
    def modelsFolder():
        folder = ProcessingConfig.getSetting(ModelerUtils.MODELS_FOLDER)
        if folder == None:
            folder = unicode(os.path.join(ProcessingUtils.userFolder(), "models"))
        mkdir(folder)

        return os.path.abspath(folder)
Beispiel #5
0
    def modelsFolder():
        folder = ProcessingConfig.getSetting(ModelerUtils.MODELS_FOLDER)
        if folder == None:
            folder = unicode(
                os.path.join(ProcessingUtils.userFolder(), "models"))
        mkdir(folder)

        return os.path.abspath(folder)
Beispiel #6
0
    def RScriptsFolder():
        folder = ProcessingConfig.getSetting(RUtils.RSCRIPTS_FOLDER)
        if folder == None:
            folder = unicode(
                os.path.join(ProcessingUtils.userFolder(), "rscripts"))
        mkdir(folder)

        return os.path.abspath(folder)
Beispiel #7
0
    def sagaBatchJobFilename():

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

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

        return batchfile
Beispiel #8
0
    def sagaBatchJobFilename():

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

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

        return batchfile
Beispiel #9
0
    def createGrassScript(commands):
        folder = GrassUtils.grassPath()
        shell = GrassUtils.grassWinShell()

        script = GrassUtils.grassScriptFilename()
        gisrc =  ProcessingUtils.userFolder() + os.sep + "processing.gisrc"

        #temporary gisrc file
        output = open(gisrc, "w")
        location = "temp_location"
        gisdbase = GrassUtils.grassDataFolder()
        #gisdbase = os.path.join(os.path.expanduser("~"), "processing", "tempdata", "grassdata")
        output.write("GISDBASE: " + gisdbase + "\n");
        output.write("LOCATION_NAME: " + location + "\n");
        output.write("MAPSET: PERMANENT \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=PERMANENT\"\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();
Beispiel #10
0
    def prepareGrassExecution(commands):
        if ProcessingUtils.isWindows():
            GrassUtils.createGrassScript(commands)
            command = ["cmd.exe", "/C ", GrassUtils.grassScriptFilename()]
        else:
            gisrc =  ProcessingUtils.userFolder() + os.sep + "processing.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 ProcessingUtils.isMac():
                command = GrassUtils.grassPath() + os.sep + "grass.sh " + GrassUtils.grassMapsetFolder() + "/PERMANENT"
            else:
                command = "grass64 " + GrassUtils.grassMapsetFolder() + "/PERMANENT"

        return command
Beispiel #11
0
    def prepareGrassExecution(commands):
        if ProcessingUtils.isWindows():
            GrassUtils.createGrassScript(commands)
            command = ["cmd.exe", "/C ", GrassUtils.grassScriptFilename()]
        else:
            gisrc = ProcessingUtils.userFolder() + os.sep + "processing.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 ProcessingUtils.isMac():
                command = GrassUtils.grassPath(
                ) + os.sep + "grass.sh " + GrassUtils.grassMapsetFolder(
                ) + "/PERMANENT"
            else:
                command = "grass64 " + GrassUtils.grassMapsetFolder(
                ) + "/PERMANENT"

        return command
Beispiel #12
0
 def tempFileListFilepath():
     filename = "fusion_files_list.txt";
     filepath = ProcessingUtils.userFolder() + os.sep + filename
     return filepath
Beispiel #13
0
 def grassScriptFilename():
     '''this is used in windows. We create a script that initializes
     GRASS and then uses grass commands'''
     filename = "grass_script.bat"
     filename = ProcessingUtils.userFolder() + os.sep + filename
     return filename
Beispiel #14
0
 def getRScriptFilename():
     return ProcessingUtils.userFolder() + os.sep + "processing_script.r"
Beispiel #15
0
 def logFilename():
     batchfile = ProcessingUtils.userFolder() + os.sep + "processing_qgis.log"
     return batchfile
Beispiel #16
0
 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 = ProcessingUtils.userFolder() + os.sep + filename
     return batchfile
Beispiel #17
0
 def getRScriptFilename():
     return ProcessingUtils.userFolder() + os.sep + "processing_script.r"
 def WpsDescriptionFolder():
     folder = ProcessingConfig.getSetting(WpsAlgorithmProvider.WPS_DESCRIPTIONS)
     if folder == None:
         folder = unicode(os.path.join(ProcessingUtils.userFolder(), "wps"))
     mkdir(folder)
     return os.path.abspath(folder)
Beispiel #19
0
 def commandsFolder(self):
     folder = unicode(os.path.join(ProcessingUtils.userFolder(), "commander"))
     mkdir(folder)
     return os.path.abspath(folder)
Beispiel #20
0
 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 = ProcessingUtils.userFolder() + os.sep + filename
     return batchfile
Beispiel #21
0
 def configFile():
     return os.path.join(ProcessingUtils.userFolder(),
                         "processing_qgis_styles.conf")
Beispiel #22
0
 def grassScriptFilename():
     '''this is used in windows. We create a script that initializes
     GRASS and then uses grass commands'''
     filename = "grass_script.bat"
     filename = ProcessingUtils.userFolder() + os.sep + filename
     return filename
Beispiel #23
0
 def configFile():
     return os.path.join(ProcessingUtils.userFolder(), "processing_qgis.conf")
Beispiel #24
0
 def logFilename():
     batchfile = ProcessingUtils.userFolder(
     ) + os.sep + "processing_qgis.log"
     return batchfile