Commit 358ba3ac authored by Rashad Kanavath's avatar Rashad Kanavath

upgdate to same code in qgis pr

parent dc71c82c
This diff is collapsed.
This diff is collapsed.
......@@ -29,9 +29,10 @@ from qgis.PyQt.QtWidgets import QComboBox
from qgis.core import (QgsProcessingParameterString,
QgsProcessingOutputString)
from processing.gui.wrappers import (WidgetWrapper,
DIALOG_STANDARD,
DIALOG_BATCH,
DIALOG_MODELER)
DIALOG_STANDARD,
DIALOG_BATCH,
DIALOG_MODELER)
class OtbChoiceWidgetWrapper(WidgetWrapper):
def createWidget(self):
......@@ -83,7 +84,7 @@ class OtbChoiceWidgetWrapper(WidgetWrapper):
def valueChanged(self, value):
for parameter in self.get_algorithm().parameterDefinitions():
if not 'group_key' in parameter.metadata() or parameter.metadata()['group_key'] != self.param.name():
continue
continue
name = parameter.name()
v = self.value() == parameter.metadata()['group_value']
self.setWrapperVisible(name, v)
......@@ -123,8 +124,10 @@ class OtbChoiceWidgetWrapper(WidgetWrapper):
if wrapper.wrappedLabel():
wrapper.wrappedLabel().setVisible(v)
from qgis.core import QgsProcessingParameterDefinition
class OtbParameterChoice(QgsProcessingParameterDefinition):
def __init__(self, name='', description='', options=[], default=None, isSource=False,
......@@ -150,8 +153,7 @@ class OtbParameterChoice(QgsProcessingParameterDefinition):
else:
self.value = int(value)
return True
def type(self):
#This value is written by otbQgisDescriptor.
return 'OTBParameterChoice'
......@@ -18,6 +18,7 @@ __copyright__ = '(C) CNES 2019'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'
class OtbSettings(object):
"""
OtbSetting's key names
......@@ -46,7 +47,7 @@ class OtbSettings(object):
# ``OTB_LOGGER_LEVEL``: Default level of logging for OTB. Should be one of ``DEBUG``, ``INFO``, ``WARNING``, ``CRITICAL`` or ``FATAL``, by increasing order of priority. Only messages with a higher priority than the level of logging will be displayed. If not set, default level is ``INFO``.
LOGGER_LEVEL = 'OTB_LOGGER_LEVEL'
@staticmethod
def keys():
return [
......@@ -55,6 +56,5 @@ class OtbSettings(object):
OtbSettings.SRTM_FOLDER,
OtbSettings.GEOID_FILE,
OtbSettings.LOGGER_LEVEL,
OtbSettings.MAX_RAM_HINT
]
OtbSettings.MAX_RAM_HINT
]
......@@ -39,49 +39,58 @@ from qgis.core import (Qgis, QgsApplication, QgsMessageLog)
from qgis.PyQt.QtCore import QCoreApplication
from otb.OtbSettings import OtbSettings
def cliPath():
cli_ext = '.bat' if os.name == 'nt' else ''
return os.path.normpath(os.path.join(QgsApplication.qgisSettingsDirPath(),
'processing', 'qgis_otb_cli' + cli_ext))
'processing', 'qgis_otb_cli' + cli_ext))
def version():
return ProcessingConfig.getSetting(OtbSettings.VERSION) or '0.0.0'
def loggerLevel():
return ProcessingConfig.getSetting(OtbSettings.LOGGER_LEVEL) or 'INFO'
def maxRAMHint():
return ProcessingConfig.getSetting(OtbSettings.MAX_RAM_HINT) or ''
def otbFolder():
if ProcessingConfig.getSetting(OtbSettings.FOLDER):
return os.path.normpath(os.sep.join(re.split(r'\\|/', ProcessingConfig.getSetting(OtbSettings.FOLDER))))
else:
return None
def appFolder():
app_folder = ProcessingConfig.getSetting(OtbSettings.APP_FOLDER)
if app_folder:
return os.pathsep.join(app_folder.split(';'))
return os.pathsep.join(app_folder.split(';'))
else:
return None
return None
def srtmFolder():
return ProcessingConfig.getSetting(OtbSettings.SRTM_FOLDER) or ''
def geoidFile():
return ProcessingConfig.getSetting(OtbSettings.GEOID_FILE) or ''
def executeOtb(commands, feedback, addToLog=True):
loglines = []
def executeOtb(command, feedback, addToLog=True):
loglines = []
with subprocess.Popen(
commands,
[command],
shell=True,
stdout=subprocess.PIPE,
stdin=subprocess.DEVNULL,
stderr=subprocess.STDOUT,
universal_newlines=True
) as proc:
) as proc:
try:
for line in iter(proc.stdout.readline, ''):
line = line.strip()
......@@ -115,6 +124,7 @@ def executeOtb(commands, feedback, addToLog=True):
# else:
# feedback.pushConsoleInfo(logline)
def tr(string, context=''):
if context == '':
context = 'OtbUtils'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment