本文整理汇总了Python中sextante.core.SextanteConfig.SextanteConfig类的典型用法代码示例。如果您正苦于以下问题:Python SextanteConfig类的具体用法?Python SextanteConfig怎么用?Python SextanteConfig使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SextanteConfig类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: fillTree
def fillTree(self):
useCategories = SextanteConfig.getSetting(SextanteConfig.USE_CATEGORIES)
if useCategories:
self.fillTreeUsingCategories()
else:
self.fillTreeUsingProviders()
self.algorithmTree.sortItems(0, Qt.AscendingOrder)
showRecent = SextanteConfig.getSetting(SextanteConfig.SHOW_RECENT_ALGORITHMS)
if showRecent:
recent = SextanteLog.getRecentAlgorithms()
if len(recent) != 0:
found = False
recentItem = QTreeWidgetItem()
recentItem.setText(0, self.tr("Recently used algorithms"))
for algname in recent:
alg = Sextante.getAlgorithm(algname)
if alg is not None:
algItem = TreeAlgorithmItem(alg)
recentItem.addChild(algItem)
found = True
if found:
self.algorithmTree.insertTopLevelItem(0, recentItem)
recentItem.setExpanded(True)
self.algorithmTree.setWordWrap(True)
示例2: initializeSettings
def initializeSettings(self):
'''this is the place where you should add config parameters to SEXTANTE using the SextanteConfig class.
this method is called when a provider is added to SEXTANTE.
By default it just adds a setting to activate or deactivate algorithms from the provider'''
SextanteConfig.settingIcons[self.getDescription()] = self.getIcon()
name = "ACTIVATE_" + self.getName().upper().replace(" ", "_")
SextanteConfig.addSetting(Setting(self.getDescription(), name, "Activate", self.activate))
示例3: initializeSettings
def initializeSettings(self):
'''In this method we add settings needed to configure our provider.
Do not forget to call the parent method, since it takes care or
automatically adding a setting for activating or deactivating the
algorithms in the provider'''
AlgorithmProvider.initializeSettings(self)
SextanteConfig.addSetting(Setting("Example algorithms", ExampleAlgorithmProvider.MY_DUMMY_SETTING, "Example setting", "Default value"))
'''To get the parameter of a setting parameter, use SextanteConfig.getSetting(name_of_parameter)'''
示例4: unload
def unload(self):
AlgorithmProvider.unload(self)
if SextanteUtils.isWindows() or SextanteUtils.isMac():
SextanteConfig.removeSetting(GrassUtils.GRASS_FOLDER)
SextanteConfig.removeSetting(GrassUtils.GRASS_WIN_SHELL)
SextanteConfig.removeSetting(GrassUtils.GRASS_HELP_FOLDER)
SextanteConfig.removeSetting(GrassUtils.GRASS_LOG_COMMANDS)
SextanteConfig.removeSetting(GrassUtils.GRASS_LOG_CONSOLE)
示例5: initializeSettings
def initializeSettings(self):
AlgorithmProvider.initializeSettings(self)
if SextanteUtils.isWindows() or SextanteUtils.isMac():
SextanteConfig.addSetting(Setting(self.getDescription(), GrassUtils.GRASS_FOLDER, "GRASS folder", GrassUtils.grassPath()))
SextanteConfig.addSetting(Setting(self.getDescription(), GrassUtils.GRASS_WIN_SHELL, "Msys folder", GrassUtils.grassWinShell()))
SextanteConfig.addSetting(Setting(self.getDescription(), GrassUtils.GRASS_LOG_COMMANDS, "Log execution commands", False))
SextanteConfig.addSetting(Setting(self.getDescription(), GrassUtils.GRASS_LOG_CONSOLE, "Log console output", False))
SextanteConfig.addSetting(Setting(self.getDescription(), GrassUtils.GRASS_HELP_FOLDER, "GRASS help folder", GrassUtils.grassHelpPath()))
示例6: setUp
def setUp(self):
SextanteConfig.setSettingValue(SextanteConfig.USE_THREADS, self.threaded)
print
print bcolors.INFO, self.msg, bcolors.ENDC,
print "Parameters: ", self.alg.parameters,
print "Outputs: ", [out for out in self.alg.outputs if not out.hidden],
self.args = list(self.gen_test_parameters(self.alg, True))
print ' => ', self.args, bcolors.WARNING,
示例7: initializeSettings
def initializeSettings(self):
'''add settings needed to configure our provider.'''
# call the parent method which takes care of adding a setting for
# activating or deactivating the algorithms in the provider
AlgorithmProvider.initializeSettings(self)
# add settings
SextanteConfig.addSetting(Setting("LWGEOM algorithms", LwgeomAlgorithmProvider.LWGEOM_PATH_SETTING, "Path to liblwgeom", ""))
示例8: addProvider
def addProvider(provider):
'''use this method to add algorithms from external providers'''
'''Adding a new provider automatically initializes it, so there is no need to do it in advance'''
#Note: this might slow down the initialization process if there are many new providers added.
#Should think of a different solution
provider.initializeSettings()
Sextante.providers.append(provider)
SextanteConfig.loadSettings()
Sextante.updateAlgsList()
示例9: removeProvider
def removeProvider(provider):
'''Use this method to remove a provider.
This method should be called when unloading a plugin that contributes a provider to SEXTANTE'''
try:
provider.unload()
Sextante.providers.remove(provider)
SextanteConfig.loadSettings()
Sextante.updateAlgsList()
except:
pass #This try catch block is here to avoid problems if the plugin with a provider is unloaded
示例10: fillCoords
def fillCoords(self):
r = self.tool.rectangle()
SextanteConfig.setSettingValue(GrassUtils.GRASS_REGION_XMIN, r.xMinimum())
SextanteConfig.setSettingValue(GrassUtils.GRASS_REGION_YMIN, r.yMinimum())
SextanteConfig.setSettingValue(GrassUtils.GRASS_REGION_XMAX, r.xMaximum())
SextanteConfig.setSettingValue(GrassUtils.GRASS_REGION_YMAX, r.yMaximum())
SextanteConfig.setSettingValue(GrassUtils.GRASS_AUTO_REGION, False)
s = str(r.xMinimum()) + "," + str(r.xMaximum()) + "," + str(r.yMinimum()) + "," + str(r.yMaximum())
self.tool.reset()
canvas = QGisLayers.iface.mapCanvas()
canvas.setMapTool(self.prevMapTool)
QtGui.QMessageBox.information(None, "GRASS Region", "GRASS region set to:\n" + s + \
"\nTo set the cellsize or set back the autoregion option,\ngo to the SEXTANTE configuration.")
示例11: execute
def execute(self):
layers = QGisLayers.getAllLayers();
layersMap = dict([(layer.name(), layer) for layer in layers])
layerNames = [layer.name() for layer in layers]
item, ok = QtGui.QInputDialog.getItem(None, "Select a layer", "Layer selection", layerNames, editable=False)
if ok:
layer = layersMap[item]
SextanteConfig.setSettingValue(GrassUtils.GRASS_REGION_XMIN, layer.extent().xMinimum())
SextanteConfig.setSettingValue(GrassUtils.GRASS_REGION_YMIN, layer.extent().yMinimum())
SextanteConfig.setSettingValue(GrassUtils.GRASS_REGION_XMAX, layer.extent().xMaximum())
SextanteConfig.setSettingValue(GrassUtils.GRASS_REGION_YMAX, layer.extent().yMaximum())
SextanteConfig.setSettingValue(GrassUtils.GRASS_AUTO_REGION, False)
s = str(layer.extent().xMinimum()) + "," + str(layer.extent().xMaximum()) + "," + str(layer.extent().yMinimum()) + "," + str(layer.extent().yMaximum())
QtGui.QMessageBox.information(None, "GRASS Region", "GRASS region set to:\n" + s + \
"\nTo set the cellsize or set back the autoregion option,\ngo to the SEXTANTE configuration.")
示例12: handleAlgorithmResults
def handleAlgorithmResults(alg, progress, showResults = True):
wrongLayers = []
htmlResults = False;
progress.setText("Loading resulting layers")
i = 0
for out in alg.outputs:
progress.setPercentage(100 * i / float(len(alg.outputs)))
if out.hidden or not out.open:
continue
if isinstance(out, (OutputRaster, OutputVector, OutputTable)):
try:
if out.value.startswith("memory:"):
layer = out.memoryLayer
QgsMapLayerRegistry.instance().addMapLayers([layer])
else:
if SextanteConfig.getSetting(SextanteConfig.USE_FILENAME_AS_LAYER_NAME):
name = os.path.basename(out.value)
else:
name = out.description
QGisLayers.load(out.value, name, alg.crs, RenderingStyles.getStyle(alg.commandLineName(),out.name))
except Exception, e:
wrongLayers.append(out)
#QMessageBox.critical(None, "Error", str(e))
elif isinstance(out, OutputHTML):
SextanteResults.addResult(out.description, out.value)
htmlResults = True
示例13: processAlgorithm
def processAlgorithm(self, progress):
commands = []
commands.append(os.path.join(TauDEMUtils.mpiexecPath(), "mpiexec"))
processNum = SextanteConfig.getSetting(TauDEMUtils.MPI_PROCESSES)
if processNum <= 0:
raise GeoAlgorithmExecutionException("Wrong number of MPI processes used.\nPlease set correct number before running TauDEM algorithms.")
commands.append("-n")
commands.append(str(processNum))
commands.append(os.path.join(TauDEMUtils.taudemPath(), self.cmdName))
commands.append("-ang")
commands.append(self.getParameterValue(self.DINF_FLOW_DIR_GRID))
commands.append("-fel")
commands.append(self.getParameterValue(self.PIT_FILLED_GRID))
commands.append("-m")
commands.append(str(self.STAT_DICT[self.getParameterValue(self.STAT_METHOD)]))
commands.append(str(self.DIST_DICT[self.getParameterValue(self.DIST_METHOD)]))
commands.append("-thresh")
commands.append(str(self.getParameterValue(self.THRESHOLD)))
if str(self.getParameterValue(self.EDGE_CONTAM)).lower() == "false":
commands.append("-nc")
commands.append("-du")
commands.append(self.getOutputValue(self.DIST_UP_GRID))
loglines = []
loglines.append("TauDEM execution command")
for line in commands:
loglines.append(line)
SextanteLog.addToLog(SextanteLog.LOG_INFO, loglines)
TauDEMUtils.executeTauDEM(commands, progress)
示例14: executeGrass
def executeGrass(commands, progress, outputCommands = None):
loglines = []
loglines.append("GRASS execution console output")
grassOutDone = False
command = GrassUtils.prepareGrassExecution(commands)
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:
if "r.out" in line or "v.out" in line:
grassOutDone = True
loglines.append(line)
progress.setConsoleInfo(line)
# Some GRASS scripts, like r.mapcalculator or r.fillnulls, call other GRASS scripts during execution. This may override any commands that are
# still to be executed by the subprocess, which are usually the output ones. If that is the case runs the output commands again.
if not grassOutDone and outputCommands:
command = GrassUtils.prepareGrassExecution(outputCommands)
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)
return loglines;
示例15: addRecentAlgorithms
def addRecentAlgorithms(self, updating):
showRecent = SextanteConfig.getSetting(SextanteConfig.SHOW_RECENT_ALGORITHMS)
if showRecent:
recent = SextanteLog.getRecentAlgorithms()
if len(recent) != 0:
found = False
if updating:
recentItem = self.algorithmTree.topLevelItem(0)
treeWidget = recentItem.treeWidget()
treeWidget.takeTopLevelItem(treeWidget.indexOfTopLevelItem(recentItem))
#self.algorithmTree.removeItemWidget(first, 0)
recentItem = QTreeWidgetItem()
recentItem.setText(0, self.tr("Recently used algorithms"))
for algname in recent:
alg = Sextante.getAlgorithm(algname)
if alg is not None:
algItem = TreeAlgorithmItem(alg)
recentItem.addChild(algItem)
found = True
if found:
self.algorithmTree.insertTopLevelItem(0, recentItem)
recentItem.setExpanded(True)
self.algorithmTree.setWordWrap(True)