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 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 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 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 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 createBaseHelpFile(alg, folder): folder = os.path.join(folder, alg.provider.getName().lower()) mkdir(folder) cmdLineName = alg.commandLineName()[alg.commandLineName().find(":") + 1:].lower() validChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" safeFilename = ''.join(c for c in cmdLineName if c in validChars) filepath = os.path.join(folder, safeFilename + ".rst") file = open(filepath, "w") file.write(alg.name.upper()) file.write("\n") file.write("=" * len(alg.name)) file.write("\n\n") file.write("Description\n") file.write("-----------\n\n") file.write("Parameters\n") file.write("----------\n\n") for param in alg.parameters: file.write("- ``" + param.description + "[" + param.parameterName()[9:] + "]``:\n") file.write("\nOutputs\n") file.write("-------\n\n") for out in alg.outputs: file.write("- ``" + out.description + "[" + out.outputTypeName()[6:] + "]``:\n") file.write("\nSee also\n") file.write("---------\n\n") file.write("\nConsole usage\n") file.write("-------------\n\n") file.write("\n::\n\n") s = "\tprocessing.runalg('" + alg.commandLineName() + "', " for param in alg.parameters: s+= str(param.name.lower().strip()) + ", " for out in alg.outputs: if not out.hidden: s+=str(out.name.lower().strip()) + ", " s = s[:-2] +")\n" file.write(s) s ="" hasSelection = False for param in alg.parameters: if isinstance(param, ParameterSelection): hasSelection = True s+="\n\t" + param.name.lower() + "(" + param.description + ")\n" i=0 for option in param.options: s+= "\t\t" + str(i) + " - " + str(option) + "\n" i+=1 if hasSelection: file.write("\n\tAvailable options for selection parameters:\n") file.write(s) file.close()
def createTempMapset(): '''Creates a temporary location and mapset(s) for GRASS data processing. A minimal set of folders and files is created in the system's default temporary directory. The settings files are written with sane defaults, so GRASS can do its work. The mapset projection will be set later, based on the projection of the first input image or vector''' folder = GrassUtils.grassMapsetFolder() mkdir(os.path.join(folder, "PERMANENT")) mkdir(os.path.join(folder, "PERMANENT", ".tmp")) GrassUtils.writeGrassWindow(os.path.join(folder, "PERMANENT", "DEFAULT_WIND")); outfile = open(os.path.join(folder, "PERMANENT", "MYNAME"), "w") outfile.write("QGIS GRASS interface: temporary data processing location.\n"); outfile.close(); GrassUtils.writeGrassWindow(os.path.join(folder, "PERMANENT", "WIND")) mkdir(os.path.join(folder, "PERMANENT", "dbf")) outfile = open(os.path.join(folder, "PERMANENT", "VAR"), "w") outfile.write("DB_DRIVER: dbf\n") outfile.write("DB_DATABASE: $GISDBASE/$LOCATION_NAME/$MAPSET/dbf/\n") outfile.close()
def createTempMapset(): '''Creates a temporary location and mapset(s) for GRASS data processing. A minimal set of folders and files is created in the system's default temporary directory. The settings files are written with sane defaults, so GRASS can do its work. The mapset projection will be set later, based on the projection of the first input image or vector''' folder = GrassUtils.grassMapsetFolder() mkdir(os.path.join(folder, "PERMANENT")) mkdir(os.path.join(folder, "PERMANENT", ".tmp")) GrassUtils.writeGrassWindow( os.path.join(folder, "PERMANENT", "DEFAULT_WIND")) outfile = open(os.path.join(folder, "PERMANENT", "MYNAME"), "w") outfile.write( "QGIS GRASS interface: temporary data processing location.\n") outfile.close() GrassUtils.writeGrassWindow(os.path.join(folder, "PERMANENT", "WIND")) mkdir(os.path.join(folder, "PERMANENT", "dbf")) outfile = open(os.path.join(folder, "PERMANENT", "VAR"), "w") outfile.write("DB_DRIVER: dbf\n") outfile.write("DB_DATABASE: $GISDBASE/$LOCATION_NAME/$MAPSET/dbf/\n") outfile.close()
def commandsFolder(self): folder = unicode(os.path.join(ProcessingUtils.userFolder(), "commander")) mkdir(folder) return os.path.abspath(folder)
def grassDataFolder(): tempfolder = os.path.join(ProcessingUtils.tempFolder(), "grassdata") mkdir(tempfolder) return tempfolder
def grassMapsetFolder(): folder = os.path.join(GrassUtils.grassDataFolder(), "temp_location") mkdir(folder) return folder
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)