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)
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()
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)
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)
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)
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)
def sagaBatchJobFilename(): if ProcessingUtils.isWindows(): filename = "saga_batch_job.bat"; else: filename = "saga_batch_job.sh"; batchfile = ProcessingUtils.userFolder() + os.sep + filename return batchfile
def sagaBatchJobFilename(): if ProcessingUtils.isWindows(): filename = "saga_batch_job.bat" else: filename = "saga_batch_job.sh" batchfile = ProcessingUtils.userFolder() + os.sep + filename return batchfile
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();
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
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
def tempFileListFilepath(): filename = "fusion_files_list.txt"; filepath = ProcessingUtils.userFolder() + os.sep + filename return filepath
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
def getRScriptFilename(): return ProcessingUtils.userFolder() + os.sep + "processing_script.r"
def logFilename(): batchfile = ProcessingUtils.userFolder() + os.sep + "processing_qgis.log" return batchfile
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
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)
def commandsFolder(self): folder = unicode(os.path.join(ProcessingUtils.userFolder(), "commander")) mkdir(folder) return os.path.abspath(folder)
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
def configFile(): return os.path.join(ProcessingUtils.userFolder(), "processing_qgis_styles.conf")
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
def configFile(): return os.path.join(ProcessingUtils.userFolder(), "processing_qgis.conf")
def logFilename(): batchfile = ProcessingUtils.userFolder( ) + os.sep + "processing_qgis.log" return batchfile