本文整理汇总了Python中processing.core.SilentProgress.SilentProgress.error方法的典型用法代码示例。如果您正苦于以下问题:Python SilentProgress.error方法的具体用法?Python SilentProgress.error怎么用?Python SilentProgress.error使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类processing.core.SilentProgress.SilentProgress
的用法示例。
在下文中一共展示了SilentProgress.error方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: handleAlgorithmResults
# 需要导入模块: from processing.core.SilentProgress import SilentProgress [as 别名]
# 或者: from processing.core.SilentProgress.SilentProgress import error [as 别名]
def handleAlgorithmResults(alg, progress=None, showResults=True):
wrongLayers = []
htmlResults = False
if progress is None:
progress = SilentProgress()
progress.setText(QCoreApplication.translate('Postprocessing', '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 hasattr(out, "layer") and out.layer is not None:
out.layer.setLayerName(out.description)
QgsMapLayerRegistry.instance().addMapLayers([out.layer])
else:
if ProcessingConfig.getSetting(
ProcessingConfig.USE_FILENAME_AS_LAYER_NAME):
name = os.path.basename(out.value)
else:
name = out.description
isRaster = True if isinstance(out, OutputRaster) else False
dataobjects.load(out.value, name, alg.crs,
RenderingStyles.getStyle(alg.commandLineName(), out.name),
isRaster)
except Exception:
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
"Error loading result layer:\n" + traceback.format_exc())
wrongLayers.append(out.description)
elif isinstance(out, OutputHTML):
ProcessingResults.addResult(out.description, out.value)
htmlResults = True
i += 1
QApplication.restoreOverrideCursor()
if wrongLayers:
msg = "The following layers were not correctly generated.<ul>"
msg += "".join(["<li>%s</li>" % lay for lay in wrongLayers]) + "</ul>"
msg += "You can check the log messages to find more information about the execution of the algorithm"
progress.error(msg)
if showResults and htmlResults and not wrongLayers:
dlg = ResultsDialog()
dlg.exec_()
return len(wrongLayers) == 0
示例2: runalg
# 需要导入模块: from processing.core.SilentProgress import SilentProgress [as 别名]
# 或者: from processing.core.SilentProgress.SilentProgress import error [as 别名]
def runalg(alg, progress=None):
"""Executes a given algorithm, showing its progress in the
progress object passed along.
Return true if everything went OK, false if the algorithm
could not be completed.
"""
if progress is None:
progress = SilentProgress()
try:
alg.execute(progress)
return True
except GeoAlgorithmExecutionException as e:
ProcessingLog.addToLog(sys.exc_info()[0], ProcessingLog.LOG_ERROR)
progress.error(e.msg)
return False