Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Scripting already working Started with modeler added saga descriptions to saga folder added configuration dialog git-svn-id: http://sextante.googlecode.com/svn/trunk/soft/bindings/qgis-plugin@23 881b9c09-3ef8-f3c2-ec3d-21d735c97f4d
- Loading branch information
volayaf@gmail.com
committed
Feb 12, 2012
1 parent
c3dd363
commit 6ab1f52
Showing
453 changed files
with
18,921 additions
and
359 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
# Form implementation generated from reading ui file 'D:\projects\sextante\workspaces\qgis-plugin\sextante\src\sextante\SextantePlugin.py' | ||
# | ||
# Created: Thu Feb 09 09:36:35 2012 | ||
# by: PyQt4 UI code generator 4.9 | ||
# | ||
# WARNING! All changes made in this file will be lost! | ||
|
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from sextante.core.GeoAlgorithm import GeoAlgorithm | ||
|
||
class ModelerAlgorithm(GeoAlgorithm): | ||
|
||
algs = [] | ||
algParameters = [] | ||
paramValues = {} | ||
|
||
def __init__(self): | ||
GeoAlgorithm.__init__(self) | ||
self.providerName = "model:" | ||
|
||
def openModel(self, filename): | ||
pass | ||
|
||
def addAlgorithm(self, algName, parametersMap): | ||
self.algs.append(algName) | ||
self.parameters.append(parametersMap) | ||
|
||
def addParameterValue(self, value): | ||
name = "HARD_CODE_PARAM_VALUE" + str(len(self.paramValues)) | ||
self.paramValues[name] = value | ||
return name | ||
|
||
def __str__(self): | ||
s="" | ||
for i in range(len(self.algs)): | ||
s+="ALGORITHM:" + self.algs[i]+"\n" | ||
for param in self.algParameters[i]: | ||
s+=str(param.value) | ||
for param in self.parameters: | ||
s += "PARAMETER:" + param.serialize() + "\n" | ||
for key in self.paramValues.keys(): | ||
s += "VALUE:" + key + "=" + str(self.paramValues[key]) + "\n" | ||
|
||
return s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
from sextante.core.SextanteUtils import SextanteUtils | ||
import os.path | ||
|
||
class SextanteConfig(): | ||
|
||
OUTPUT_FOLDER = "OUTPUT_FOLDER" | ||
|
||
settings = {} | ||
|
||
@staticmethod | ||
def initialize(): | ||
SextanteConfig.addSetting(Setting("General", SextanteConfig.OUTPUT_FOLDER, | ||
"Output folder", os.path.join(SextanteUtils.userFolder(),"outputs" ))) | ||
|
||
|
||
@staticmethod | ||
def addSetting(setting): | ||
SextanteConfig.settings[setting.name] = setting | ||
|
||
@staticmethod | ||
def getSettings(): | ||
settings={} | ||
for setting in SextanteConfig.settings.values(): | ||
if not setting.group in settings: | ||
group = [] | ||
settings[setting.group] = group | ||
else: | ||
group = settings[setting.group] | ||
group.append(setting) | ||
return settings | ||
|
||
@staticmethod | ||
def configFile(): | ||
return os.path.join(SextanteUtils.userFolder(), "sextante_qgis.conf") | ||
|
||
@staticmethod | ||
def loadSettings(): | ||
lines = open(SextanteConfig.configFile()) | ||
line = lines.readline().strip("\n") | ||
while line != "": | ||
tokens = line.split("=") | ||
if tokens[0] in SextanteConfig.settings.keys(): | ||
setting = SextanteConfig.settings[tokens[0]] | ||
if isinstance(setting.value, bool): | ||
setting.value = bool(tokens[1]) | ||
else: | ||
setting.value = tokens[1] | ||
SextanteConfig.addSetting(setting) | ||
line = lines.readline().strip("\n") | ||
lines.close() | ||
|
||
@staticmethod | ||
def saveSettings(): | ||
fout = open(SextanteConfig.configFile(), "w") | ||
for setting in SextanteConfig.settings.values(): | ||
fout.write(str(setting) + "\n") | ||
fout.close() | ||
|
||
@staticmethod | ||
def getSetting(name): | ||
if name in SextanteConfig.settings.keys(): | ||
return SextanteConfig.settings[name].value | ||
else: | ||
return None | ||
|
||
|
||
|
||
class Setting(): | ||
|
||
def __init__(self, group, name, description, default): | ||
self.group=group | ||
self.name = name | ||
self.description = description | ||
self.default = default | ||
self.value = default | ||
|
||
def __str__(self): | ||
return self.name + "=" + str(self.value) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import datetime | ||
import os | ||
from sextante.core.SextanteUtils import SextanteUtils | ||
class SextanteLog(): | ||
|
||
LOG_ERROR = "ERROR" | ||
LOG_INFO = "INFO" | ||
LOG_WARNING = "WARNING" | ||
LOG_ALGORITHM = "ALGORITHM" | ||
|
||
@staticmethod | ||
def startLogging(): | ||
logfile = open(SextanteLog.logFilename(), "w") | ||
logfile.write("Started logging at " + datetime.datetime.now().strftime("%a %b %d %Y %H:%M:%S")) | ||
logfile.close() | ||
|
||
@staticmethod | ||
def logFilename(): | ||
batchfile = SextanteUtils.userFolder() + os.sep + "sextante_qgis.log" | ||
return batchfile | ||
|
||
|
||
@staticmethod | ||
def addToLog(msgtype, msg): | ||
if isinstance(msg, list): | ||
text="" | ||
for i in range(0, len(msg)): | ||
text+=msg[i] + "|" | ||
text = text[:-1] | ||
else: | ||
text = str(msg) | ||
line = msgtype + "|" + datetime.datetime.now().strftime("%a %b %d %Y %H:%M:%S") + "|" + text + "\n" | ||
logfile = open(SextanteLog.logFilename(), "a") | ||
logfile.write(line) | ||
logfile.close() | ||
|
||
@staticmethod | ||
def getLogEntries(): | ||
entries={} | ||
errors=[] | ||
algorithms=[] | ||
warnings=[] | ||
info=[] | ||
lines = open(SextanteLog.logFilename()) | ||
line = lines.readline() | ||
while line != "": | ||
line = line.strip("\n").strip() | ||
tokens = line.split("|") | ||
text="" | ||
for i in range(2, len(tokens)): | ||
text+=tokens[i] + "|" | ||
if line.startswith(SextanteLog.LOG_ERROR): | ||
errors.append(LogEntry(tokens[1], text)) | ||
elif line.startswith(SextanteLog.LOG_ALGORITHM): | ||
algorithms.append(LogEntry(tokens[1], tokens[2])) | ||
elif line.startswith(SextanteLog.LOG_WARNING): | ||
warnings.append(LogEntry(tokens[1], text)) | ||
elif line.startswith(SextanteLog.LOG_INFO): | ||
info.append(LogEntry(tokens[1], text)) | ||
line = lines.readline() | ||
lines.close() | ||
entries[SextanteLog.LOG_ERROR] = errors | ||
entries[SextanteLog.LOG_ALGORITHM] = algorithms | ||
entries[SextanteLog.LOG_INFO] = info | ||
entries[SextanteLog.LOG_WARNING] = warnings | ||
return entries | ||
|
||
class LogEntry(): | ||
def __init__(self, date, text): | ||
self.date = date | ||
self.text = text |
Oops, something went wrong.