[GRASS-SVN] r64887 - grass-addons/grass7/gui/wxpython/wx.mwprecip

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Mar 20 05:18:23 PDT 2015


Author: krejcmat
Date: 2015-03-20 05:18:23 -0700 (Fri, 20 Mar 2015)
New Revision: 64887

Removed:
   grass-addons/grass7/gui/wxpython/wx.mwprecip/wx.mwprecip.py
Modified:
   grass-addons/grass7/gui/wxpython/wx.mwprecip/g.gui.mwprecip.py
   grass-addons/grass7/gui/wxpython/wx.mwprecip/mw3.py
   grass-addons/grass7/gui/wxpython/wx.mwprecip/mw_util.py
   grass-addons/grass7/gui/wxpython/wx.mwprecip/pgwrapper.py
Log:
save-load fix

Modified: grass-addons/grass7/gui/wxpython/wx.mwprecip/g.gui.mwprecip.py
===================================================================
--- grass-addons/grass7/gui/wxpython/wx.mwprecip/g.gui.mwprecip.py	2015-03-19 18:24:26 UTC (rev 64886)
+++ grass-addons/grass7/gui/wxpython/wx.mwprecip/g.gui.mwprecip.py	2015-03-20 12:18:23 UTC (rev 64887)
@@ -2,15 +2,13 @@
 
 import os
 import sys
-
-from grass.script import core as grass
-
-sys.path.insert(1, os.path.join(os.path.dirname(sys.path[0]), 'etc', 'g.gui.mwprecip'))
 from mw_util import *
+from mw3 import *
+sys.path.insert(1, os.path.join(os.path.dirname(sys.path[0]), 'etc', 'g.gui.mwprecip'))
 from core.gcmd import GMessage, GError
-
 from gui_core import gselect
 
+
 class DBconn(wx.Panel):
     def __init__(self, parent, settings={}):
         wx.Panel.__init__(self, parent=parent, id=wx.ID_ANY)
@@ -47,31 +45,18 @@
         if sett:
             self.settings = sett
 
-        try:
+        if 'database' in self.settings:
             self.database.SetValue(self.settings['database'])
-        except:
-            print 'err'
-            pass
-        try:
+        if 'schema' in self.settings:
             self.schema.SetValue(self.settings['schema'])
-        except:
-            pass
-        try:
+        if 'host' in self.settings:
             self.host.SetValue(self.settings['host'])
-        except:
-            pass
-        try:
+        if 'user' in self.settings:
             self.user.SetValue(self.settings['user'])
-        except:
-            pass
-        try:
+        if 'port' in self.settings:
             self.port.SetValue(self.settings['port'])
-        except:
-            pass
-        try:
+        if 'passwd' in self.settings:
             self.passwd.SetValue(self.settings['passwd'])
-        except:
-            pass
 
     def saveSettings(self, settings=None):
         if settings is not None:
@@ -119,14 +104,10 @@
     def loadSettings(self, sett=None):
         if sett:
             self.settings = sett
-        try:
+        if 'pitypeDist' in self.settings:
             self.rb1.SetValue(self.settings['pitypeDist'])
-        except:
-            pass
-        try:
+        if 'pivalue' in self.settings:
             self.val.SetValue(self.settings['pivalue'])
-        except:
-            pass
 
     def saveSettings(self, settings=None):
         if settings is not None:
@@ -164,39 +145,22 @@
     def loadSettings(self, sett=None):
         if sett is not None:
             self.settings = sett
-        try:
+        if 'fromFile' in self.settings:
             self.fromFile.SetValue(self.settings['fromFile'])
-        except:
-            pass
-        try:
+        if 'dryWin' in self.settings:
             self.dryWin.SetValue(self.settings['dryWin'])
-        except:
-            pass
-        try:
+        if 'quantile' in self.settings:
             self.quantile.SetValue(self.settings['quantile'])
-        except:
-            pass
-
-        try:
+        if 'baselType' in self.settings:
             self.baselType.SetValue(self.settings['baselType'])
-        except:
-            pass
-        try:
+        if 'round' in self.settings:
             self.round.SetValue(self.settings['round'])
-        except:
-            pass
-        try:
+        if 'aw' in self.settings:
             self.aw.SetValue(self.settings['aw'])
-        except:
-            pass
-        try:
+        if 'dryInterval' in self.settings:
             self.dryInterval.SetPath(self.settings['dryInterval'])
-        except:
-            pass
-        try:
+        if 'fromFileVal' in self.settings:
             self.fromFileVal.SetPath(self.settings['fromFileVal'])
-        except:
-            pass
         self.onChangeMethod()
 
     def saveSettings(self, evt=None, sett=None):
@@ -269,13 +233,13 @@
         self.linksAll.Bind(wx.EVT_RADIOBUTTON, self.refreshLinkSet)
         self.linksIngnore.Bind(wx.EVT_RADIOBUTTON, self.refreshLinkSet)
         self.linksOnly.Bind(wx.EVT_RADIOBUTTON, self.refreshLinkSet)
-        self.vectorMap = wx.RadioButton(self,label='Vector map')
-        self.vectorMap.Bind(wx.EVT_RADIOBUTTON,self.refreshLinkSet)
+        self.vectorMap = wx.RadioButton(self, label='Vector map')
+        self.vectorMap.Bind(wx.EVT_RADIOBUTTON, self.refreshLinkSet)
 
         # self.links = BaseInput(self,'Set links according to radio above',True)
         self.links = BaseInput(self, 'Set links according to radio above')
-        self.mapLabel=wx.StaticText(self,label='Select vector map')
-        self.map = gselect.Select(self, type='vector',multiple=False)
+        self.mapLabel = wx.StaticText(self, label='Select vector map')
+        self.map = gselect.Select(self, type='vector', multiple=False)
 
         self.start = BaseInput(self, label='Start time')
         self.end = BaseInput(self, label='End time')
@@ -285,14 +249,14 @@
 
         self.stBoxGauge = wx.StaticBox(self, wx.ID_ANY, 'Rain gauge')
         self.inpRainGauge = FileInput(self, 'Select folder with raingauges data')
-        self.inpRainGauge.pathInput.Bind(wx.EVT_TEXT,self.disableLinksInp)
+        self.inpRainGauge.pathInput.Bind(wx.EVT_TEXT, self.disableLinksInp)
         # self.sb1 = wx.StaticBox(self, wx.ID_ANY, 'Baseline')
         # self.type = self.rb1 = wx.RadioButton(self, label='Number of points', style=wx.RB_GROUP)
         if len(settings) > 0:
             self.loadSettings()
         self._layout()
 
-    def disableLinksInp(self,evt=None):
+    def disableLinksInp(self, evt=None):
         if self.inpRainGauge.GetPath() is not None:
             self.linksAll.Disable()
             self.linksOnly.Disable()
@@ -344,39 +308,24 @@
     def loadSettings(self, sett=None):
         if sett:
             self.settings = sett
-        try:
-            self.map.SetValue(eval(self.settings['linksMap']))
-        except:
-            pass
-        try:
-            self.linksOnly.SetValue(eval(self.settings['linksOnly']))
-        except:
-            pass
-        try:
-            self.linksIngnore.SetValue(eval(self.settings['linksIngnore']))
-        except:
-            pass
-        try:
+        if 'linksMap' in self.settings:
+            self.map.SetValue(self.settings['linksMap'])
+        if 'linksOnly' in self.settings:
+            self.linksOnly.SetValue(self.settings['linksOnly'])
+        if 'linksIgnore' in self.settings:
+            self.linksIngnore.SetValue(self.settings['linksIngnore'])
+        if 'links' in self.settings:
             self.links.SetValue(self.settings['links'])
-        except:
-            pass
-        try:
+        if 'start' in self.settings:
             self.start.SetValue(self.settings['start'])
-        except:
-            pass
-        try:
+        if 'end' in self.settings:
             self.end.SetValue(self.settings['end'])
-        except:
-            pass
-        try:
+        if 'sumStep' in self.settings:
             self.sumStep.SetValue(self.settings['sumStep'])
-        except:
-            pass
-        try:
+        if 'inpRainGauge' in self.settings:
             self.inpRainGauge.SetPath(self.settings['inpRainGauge'])
-        except:
-            pass
 
+
     def _layout(self):
         panelSizer = wx.BoxSizer(wx.VERTICAL)
         self.SetSizerAndFit(panelSizer)
@@ -417,26 +366,22 @@
         self.SetSizerAndFit(panelSizer)
         self.refreshLinkSet()
 
+
 class GrassLayers(wx.Panel):
     def __init__(self, parent, settings={}):
         wx.Panel.__init__(self, parent=parent, id=wx.ID_ANY)
         self.settings = settings
-        self.colorRules = TextInput(self,label='Color table')
-        self.colorsName = BaseInput(self,label='Name of color table')
+        self.colorRules = TextInput(self, label='Color table')
+        self.colorsName = BaseInput(self, label='Name of color table')
         self.layout()
 
     def loadSettings(self, sett=None):
         if sett:
             self.settings = sett
-        try:
+        if 'colorRules' in self.settings:
             self.colorRules.SetValue(self.settings['colorRules'])
-        except:
-            pass
-
-        try:
+        if 'colorName' in self.settings:
             self.colorsName.SetValue(self.settings['colorsName'])
-        except:
-            pass
 
     def saveSettings(self, evt=None, sett=None):
         if sett:
@@ -447,73 +392,76 @@
 
     def layout(self):
         panelSizer = wx.BoxSizer(wx.VERTICAL)
-        panelSizer.Add(self.colorsName,flag= wx.EXPAND )
-        panelSizer.Add(self.colorRules, flag=wx.EXPAND )
+        panelSizer.Add(self.colorsName, flag=wx.EXPAND)
+        panelSizer.Add(self.colorRules, flag=wx.EXPAND)
         self.SetSizerAndFit(panelSizer)
 
+
 class GeometryPanel(wx.Panel):
     def __init__(self, parent, settings={}):
         wx.Panel.__init__(self, parent=parent, id=wx.ID_ANY)
         self.settings = settings
-        self.label=wx.StaticText(self,label='Create vector geometry map')
+        self.label = wx.StaticText(self, label='Create vector geometry map')
         self.linksExp = wx.RadioButton(self, label='Links', style=wx.RB_GROUP)
         self.nodesExp = wx.RadioButton(self, label='Nodes')
-        self.mapName=BaseInput(self,'Map name')
-        self.bttExport=wx.Button(self,label='Export')
+        self.mapName = BaseInput(self, 'Map name')
+        self.bttExport = wx.Button(self, label='Export')
 
         self.layout()
 
     def layout(self):
         panelSizer = wx.BoxSizer(wx.VERTICAL)
 
-        panelSizer.Add(self.label,flag=wx.EXPAND)
-        panelSizer.Add(self.linksExp,flag=wx.EXPAND)
-        panelSizer.Add(self.nodesExp,flag=wx.EXPAND)
-        panelSizer.Add(self.mapName,flag=wx.EXPAND)
-        panelSizer.Add(self.bttExport,flag=wx.EXPAND)
+        panelSizer.Add(self.label, flag=wx.EXPAND)
+        panelSizer.Add(self.linksExp, flag=wx.EXPAND)
+        panelSizer.Add(self.nodesExp, flag=wx.EXPAND)
+        panelSizer.Add(self.mapName, flag=wx.EXPAND)
+        panelSizer.Add(self.bttExport, flag=wx.EXPAND)
         self.SetSizerAndFit(panelSizer)
 
     def GetOptions(self):
         if self.linksExp.GetValue():
-            type='links'
+            type = 'links'
         else:
-            type='nodes'
-        return type,self.mapName.GetValue()
+            type = 'nodes'
+        return type, self.mapName.GetValue()
 
+
 class ExportData(wx.Panel):
     def __init__(self, parent):
         wx.Panel.__init__(self, parent=parent, id=wx.ID_ANY)
 
-        self.chkid=wx.CheckBox(self,label='linkid')
+        self.chkid = wx.CheckBox(self, label='linkid')
         self.chkid.SetValue(True)
         self.chkid.Disable()
-        self.chktime=wx.CheckBox(self,label='time')
+        self.chktime = wx.CheckBox(self, label='time')
         self.chktime.SetValue(True)
         self.chktime.Disable()
 
-        self.chkprecip=wx.CheckBox(self,label='precipitation')
-        self.chkrx=wx.CheckBox(self,label='rx')
-        self.chktx=wx.CheckBox(self,label='tx')
-        self.chkfreq=wx.CheckBox(self,label='frequency')
-        self.chkpol=wx.CheckBox(self,label='polarization')
-        self.okBtt=wx.Button(self,label='export')
+        self.chkprecip = wx.CheckBox(self, label='precipitation')
+        self.chkrx = wx.CheckBox(self, label='rx')
+        self.chktx = wx.CheckBox(self, label='tx')
+        self.chkfreq = wx.CheckBox(self, label='frequency')
+        self.chkpol = wx.CheckBox(self, label='polarization')
+        self.okBtt = wx.Button(self, label='export')
         self.layout()
-        #self.chkprecip.Bind(wx.EVT_CHECKBOX,self.onChckPrec)
+        # self.chkprecip.Bind(wx.EVT_CHECKBOX,self.onChckPrec)
 
     def layout(self):
-        mainSizer=wx.BoxSizer(wx.VERTICAL)
+        mainSizer = wx.BoxSizer(wx.VERTICAL)
 
-        mainSizer.Add(self.chkid,wx.EXPAND)
-        mainSizer.Add(self.chktime,wx.EXPAND)
-        mainSizer.Add(self.chkprecip,wx.EXPAND)
-        mainSizer.Add(self.chkrx,wx.EXPAND)
-        mainSizer.Add(self.chktx,wx.EXPAND)
-        mainSizer.Add(self.chkfreq,wx.EXPAND)
-        mainSizer.Add(self.chkpol,wx.EXPAND)
-        mainSizer.Add(self.okBtt,wx.EXPAND)
+        mainSizer.Add(self.chkid, wx.EXPAND)
+        mainSizer.Add(self.chktime, wx.EXPAND)
+        mainSizer.Add(self.chkprecip, wx.EXPAND)
+        mainSizer.Add(self.chkrx, wx.EXPAND)
+        mainSizer.Add(self.chktx, wx.EXPAND)
+        mainSizer.Add(self.chkfreq, wx.EXPAND)
+        mainSizer.Add(self.chkpol, wx.EXPAND)
+        mainSizer.Add(self.okBtt, wx.EXPAND)
 
         self.SetSizerAndFit(mainSizer)
 
+
 class MyFrame(wx.Frame):
     def __init__(self, parent, id, title):
         wx.Frame.__init__(self, parent, id, title, size=(480, 640))
@@ -528,11 +476,11 @@
         fileMenu = wx.Menu()
         databaseItem = settMenu.Append(wx.ID_ANY, 'Database', 'Set database')
         baselineItem = settMenu.Append(wx.ID_ANY, 'Baseline', 'Set baseline methods')
-        geometry = settMenu.Append(wx.ID_ANY,'Geometry', 'Create vector geometry')
+        geometry = settMenu.Append(wx.ID_ANY, 'Geometry', 'Create vector geometry')
         quitItem = settMenu.Append(wx.ID_EXIT, 'Quit', 'Quit application')
         menubar.Append(settMenu, '&Options')
 
-        #geoMenu = wx.Menu()
+        # geoMenu = wx.Menu()
 
         #menubar.Append(geoMenu, '&Settings')
 
@@ -582,7 +530,6 @@
         self.OnSaveSettings(toFile=False)
         interface = Gui2Model(self, self.settings)  # TODO optimalize init
         if interface.connStatus:
-
             self.dataMgrMW.start.SetValue(interface.dbConn.minTimestamp())
 
     def getMaxTime(self, evt=None):
@@ -595,7 +542,7 @@
         self.OnSaveSettings(toFile=False)
         interface = Gui2Model(self, self.settings)
         if interface.connStatus:
-             return interface.dbConn
+            return interface.dbConn
 
     def OnSchemeTxtChange(self, evt=None):
         if self.schema.GetValue() is not None:
@@ -626,7 +573,6 @@
             self.grassLayers.loadSettings(self.settings)
         except:
             pass
-
     def OnSaveSettings(self, evt=None, toFile=True):
         try:
             self.settings = self.dataMgrMW.saveSettings(sett=self.settings)
@@ -648,12 +594,7 @@
             self.settings = self.grassLayers.saveSettings(sett=self.settings)
         except:
             pass
-
-        try:
-            self.settings['workSchema'] = self.profilSelection.GetValue()
-        except:
-            pass
-
+        self.settings['workSchema'] = self.profilSelection.GetValue()
         if self.schema.GetValue() is not None:
             self.settings['workSchema'] = self.schema.GetValue()
 
@@ -663,11 +604,11 @@
             self.findProject()
 
     def initWorkingFoldrs(self):
-        savePath=os.path.join(self.workPath,'save')
+        savePath = os.path.join(self.workPath, 'save')
         if not os.path.exists(savePath):
             os.makedirs(savePath)
 
-        tmpPath=os.path.join(self.workPath,'temp')
+        tmpPath = os.path.join(self.workPath, 'temp')
         if not os.path.exists(tmpPath):
             os.makedirs(tmpPath)
 
@@ -688,7 +629,7 @@
         else:
             return
 
-    def onSetGeometry(self,evt):
+    def onSetGeometry(self, evt):
         self.geDialog = wx.Dialog(self, id=wx.ID_ANY,
                                   title='Geometry creator',
                                   style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER,
@@ -711,15 +652,15 @@
         self.geDialog.Destroy()
 
     def _onSetGeomDLG(self, evt):
-        type,name=self.geometryPnl.GetOptions()
+        type, name = self.geometryPnl.GetOptions()
         if name == '':
             GMessage('Please set name of map')
         else:
-            self.createGeometry(type,name)
-            #self.addMapToLay()#TODO giface
+            self.createGeometry(type, name)
+            # self.addMapToLay()#TODO giface
 
-    def addMapToLay(self,map):
-        #TODO giface
+    def addMapToLay(self, map):
+        # TODO giface
         '''
 
         tree = self._giface.GetLayerTree()
@@ -737,7 +678,7 @@
                                   size=wx.DefaultSize,
                                   pos=wx.DefaultPosition)
 
-        #self.bsDialog.SetSize((500, 500))
+        # self.bsDialog.SetSize((500, 500))
 
         if self.settings:
             self.baselinePnl = BaselinePanel(self.bsDialog, self.settings)
@@ -785,17 +726,17 @@
         print self.settings
         self.dbDialog.Destroy()
 
-    def createGeometry(self,type, name):
+    def createGeometry(self, type, name):
         interface = Gui2Model(self, self.settings)
-        interface.initVectorGrass(type=type,name=name)
+        interface.initVectorGrass(type=type, name=name)
 
     def exportData(self, evt):
 
         self.exportDialog = wx.Dialog(self, id=wx.ID_ANY,
-                                  title='Database connection settings',
-                                  style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER,
-                                  size=wx.DefaultSize,
-                                  pos=wx.DefaultPosition)
+                                      title='Database connection settings',
+                                      style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER,
+                                      size=wx.DefaultSize,
+                                      pos=wx.DefaultPosition)
 
         self.exportDialog.SetSize((500, 500))
         self.exportDMgr = ExportData(self.exportDialog)
@@ -808,15 +749,15 @@
         self.exportDialog.ShowModal()
         self.exportDialog.Destroy()
 
-    def _onExport(self,evt=None):
-        path=OnSaveAs(self)
+    def _onExport(self, evt=None):
+        path = OnSaveAs(self)
         self.OnSaveSettings(toFile=False)
         if not self.exportDMgr.chkprecip.GetValue():
-            attrTmp1=[]
+            attrTmp1 = []
             attrTmp1.append('link.linkid')
-            attrTmp2=[]
-            attrTmp3=[]
-            #attrTmp2.append('public.linkid')
+            attrTmp2 = []
+            attrTmp3 = []
+            # attrTmp2.append('public.linkid')
             if self.exportDMgr.chkfreq.GetValue():
                 attrTmp1.append('link.frequency')
             if self.exportDMgr.chkpol.GetValue():
@@ -828,85 +769,85 @@
             if self.exportDMgr.chktx.GetValue():
                 attrTmp2.append('record.txpower')
 
-            attrTmp4='WHERE'
+            attrTmp4 = 'WHERE'
             if len(attrTmp1) > 0:
                 attrTmp3.append('link')
             if len(attrTmp2) > 0:
                 attrTmp3.append('record')
 
             if len(attrTmp1) > 0 and len(attrTmp2) > 0:
-                attrTmp4='WHERE link.linkid=record.linkid AND'
-                attrTmp0=attrTmp1+attrTmp2
+                attrTmp4 = 'WHERE link.linkid=record.linkid AND'
+                attrTmp0 = attrTmp1 + attrTmp2
                 attrTmp0 = ",".join(attrTmp0)
             elif len(attrTmp1) > 0:
                 attrTmp0 = ",".join(attrTmp1)
             elif len(attrTmp2) > 0:
                 attrTmp0 = ",".join(attrTmp2)
 
-            if len(attrTmp3)>1:
+            if len(attrTmp3) > 1:
                 attrTmp3 = ",".join(attrTmp3)
             else:
-                attrTmp3=attrTmp3[0]
+                attrTmp3 = attrTmp3[0]
 
-            sql="SELECT %s FROM %s %s record.time>'%s' and record.time< '%s'  "%(attrTmp0,
-                                                                                attrTmp3,
-                                                                                attrTmp4,
-                                                                                self.dataMgrMW.start.GetValue(),
-                                                                                self.dataMgrMW.end.GetValue())
-            conn=self.GetConnection()
-            res=conn.connection.executeSql(sql, True, True)
-            lines=''
+            sql = "SELECT %s FROM %s %s record.time>'%s' and record.time< '%s'  " % (attrTmp0,
+                                                                                     attrTmp3,
+                                                                                     attrTmp4,
+                                                                                     self.dataMgrMW.start.GetValue(),
+                                                                                     self.dataMgrMW.end.GetValue())
+            conn = self.GetConnection()
+            res = conn.connection.executeSql(sql, True, True)
+            lines = ''
             for r in res:
-                lines+=str(r)[1:][:-1].replace('datetime.datetime','').replace("'","") +'\n'
+                lines += str(r)[1:][:-1].replace('datetime.datetime', '').replace("'", "") + '\n'
             print conn.pathworkSchemaDir
             #path=os.path.join(conn.pathworkSchemaDir, "export")
             io0 = open(path, "wr")
             io0.writelines(lines)
             io0.close()
-            GMessage('Data exported<%s>'%path)
+            GMessage('Data exported<%s>' % path)
 
         else:
-            exportData = {'getData':True,'dataOnly':False}
+            exportData = {'getData': True, 'dataOnly': False}
             if YesNo(self, 'Export data only?'):
                 exportData['dataOnly'] = True
             self.settings['dataExport'] = exportData
 
-            #if rain gauges
+            # if rain gauges
             if self.dataMgrMW.inpRainGauge.GetPath() is not None:
-                self.settings['IDtype']='gaugeid'
+                self.settings['IDtype'] = 'gaugeid'
             else:
-                self.settings['IDtype']='linkid'
+                self.settings['IDtype'] = 'linkid'
 
             interface = Gui2Model(self, self.settings)
             interface.initVectorGrass()
             interface.initTimeWinMW()
             interface.initBaseline()
             interface.doCompute()
-            conn=self.GetConnection()
-            sql='SELECT * FROM %s.%s'%(interface.dbConn.schema,interface.dbConn.computedPrecip)
-            res=conn.connection.executeSql(sql, True, True)
-            lines=''
+            conn = self.GetConnection()
+            sql = 'SELECT * FROM %s.%s' % (interface.dbConn.schema, interface.dbConn.computedPrecip)
+            res = conn.connection.executeSql(sql, True, True)
+            lines = ''
             for r in res:
-                lines+=str(r)[1:][:-1] +'\n'
+                lines += str(r)[1:][:-1] + '\n'
             print conn.pathworkSchemaDir
             #path=os.path.join(conn.pathworkSchemaDir, "export")
             io0 = open(path, "wr")
             io0.writelines(lines)
             io0.close()
-            GMessage('Data exported<%s>'%path)
+            GMessage('Data exported<%s>' % path)
 
         self.exportDialog.Destroy()
 
     def runCompute(self, evt):
         self.OnSaveSettings(toFile=False)
-        exportData = {'getData':False,'dataOnly':False}
+        exportData = {'getData': False, 'dataOnly': False}
         self.settings['dataExport'] = exportData
 
-        #if rain gauges
+        # if rain gauges
         if self.dataMgrMW.inpRainGauge.GetPath() is not None:
-            self.settings['IDtype']='gaugeid'
+            self.settings['IDtype'] = 'gaugeid'
         else:
-            self.settings['IDtype']='linkid'
+            self.settings['IDtype'] = 'linkid'
 
         interface = Gui2Model(self, self.settings)
         interface.initVectorGrass()
@@ -938,55 +879,43 @@
     def onQuit(self, e):
         self.Close()
 
+
 class Gui2Model():
     def __init__(self, wxParent, settings):
         parent = wxParent
         self.settings = settings
         self.dbConn = None
-        self.connStatus=False
+        self.connStatus = False
         self.initConnection()
 
     def initConnection(self, info=False):
-        conninfo=None
+        conninfo = None
         try:
             conninfo = {'name': self.settings['database']}
         except:
             GMessage('name of database is missing')
             return
-        try:
+        if 'workSchema' in self.settings:
             conninfo['workSchema'] = self.settings['workSchema']
-        except:
-            pass
-        try:
+        if 'schema' in self.settings:
             conninfo['dataSchema'] = self.settings['schema']
-        except:
-            pass
-        try:
+        if 'host' in self.settings:
             conninfo['host'] = self.settings['host']
-        except:
-            pass
-        try:
+        if 'user' in self.settings:
             conninfo['user'] = self.settings['user']
-        except:
-            pass
-        try:
+        if 'port' in self.settings:
             conninfo['port'] = self.settings['port']
-        except:
-            pass
-        try:
+        if 'passwd' in self.settings:
             conninfo['password'] = self.settings['passwd']
-        except:
-            pass
 
         if conninfo is None:
-            self.connStatus=False
+            self.connStatus = False
             GMessage('Database connection failed')
             return
 
-
         if not info:  # prepare for computing
             self.dbConn = Database(**conninfo)
-            self.connStatus=True
+            self.connStatus = True
             self.dbConn.firstPreparation()
             self.dbConn.prepareDB()
             self.dbConn.prepareDir()
@@ -994,78 +923,68 @@
             return self.dbConn
         else:  # just get info about curr database state
             self.dbConn = Database(**conninfo)
-            self.connStatus=True
+            self.connStatus = True
             return self.dbConn
 
-    def initVectorGrass(self,type=None,name=None):
+    def initVectorGrass(self, type=None, name=None):
         convertor = VectorLoader(self.dbConn)
         if name:
-            self.dbConn.nodeVecMapName=name
-            self.dbConn.linkVecMapName=name
+            self.dbConn.nodeVecMapName = name
+            self.dbConn.linkVecMapName = name
 
-        if type=='nodes' or type is None:
+        if type == 'nodes' or type is None:
             # create native vector map(nodes)
             pointsSQL = convertor.selectNodes()
             # print pointsSQL
             pointsASCII = convertor.getASCIInodes(pointsSQL)
             convertor.grass_vinASCII(pointsASCII, self.dbConn.nodeVecMapName)
         # create native vector map(links)
-        if type=='links'or type is None:
+        if type == 'links' or type is None:
             linksSQL = convertor.selectLinks()
             linksASCII = convertor.getASCIIlinks(linksSQL)
             convertor.grass_vinASCII(linksASCII, self.dbConn.linkVecMapName)
 
     def initPInterpolation(self):
-        try:
+        if 'pitypeDist' in self.settings:
             pitypeDist = self.settings['pitypeDist']
-        except:
-            pass
-        try:
+        if 'pivalue' in self.settings:
             pivalue = self.settings['pivalue']
-        except:
+        else:
             self.errMsg('Missing value for interpolating points along lines')
 
         PointInterpolation(self.dbConn, pivalue, pitypeDist)
 
     def initBaseline(self):
         baselInit = {}
-        try:
+        if 'baselType' in self.settings:
             baselInit['statFce'] = self.settings['baselType']
-        except:
-            pass
-        try:
+
+        if 'quantile' in self.settings:
             baselInit['quantile'] = self.settings['quantile']
-        except:
-            pass
-        try:
+        if 'round' in self.settings:
             baselInit['roundMode'] = self.settings['round']
-        except:
-            pass
-        try:
+        if 'aw' in self.settings:
             baselInit['aw'] = self.settings['aw']
-        except:
-            pass
+
         methodSel = False
-        try:
+
+        if 'fromFile' in self.settings:
             if self.settings['fromFile']:
                 baselInit['type'] = 'values'
-                try:
+                if 'fromFileVal' in self.settings:
                     baselInit['pathToFile'] = self.settings['fromFileVal']
-                except:
+                else:
                     self.errMsg('Path to file with baseline values is not defined')
                 methodSel = True
-        except:
-            pass
-        try:
+
+        if 'dryWin' in self.settings:
             if self.settings['dryWin']:
                 baselInit['type'] = 'fromDryWin'
-                try:
+                if 'dryInterval' in self.settings:
                     baselInit['pathToFile'] = self.settings['dryInterval']
-                except:
+                else:
                     self.errMsg('Dry interval is not defined')
                 methodSel = True
-        except:
-            pass
 
         if not methodSel:
             self.errMsg('Baseline method is not selected')
@@ -1074,38 +993,24 @@
 
     def initTimeWinMW(self):
         winInit = {}
-        try:
-            winInit['linksOnly'] = eval(self.settings['linksOnly'])
-        except:
-            pass
-        try:
-            winInit['linksOnly'] = eval(self.settings['linksMap'])
-        except:
-            pass
-        try:
-            winInit['linksIngnore'] = eval(self.settings['linksIngnore'])
-        except:
-            pass
-        try:
+        if 'linksOnly' in self.settings:
+            winInit['linksOnly'] = self.settings['linksOnly']
+
+        if 'linksMap' in self.settings:
+            winInit['linksOnly'] = self.settings['linksMap']
+        if 'linksIngnore' in self.settings:
+            winInit['linksIgnored'] = self.settings['linksIngnore']
+        if 'links' in self.settings:
             winInit['links'] = self.settings['links']
-        except:
-            pass
-        try:
+        if 'start' in self.settings:
             winInit['startTime'] = self.settings['start']
-        except:
-            pass
-        try:
+        if 'end' in self.settings:
             winInit['endTime'] = self.settings['end']
-        except:
-            pass
-        try:
+        if 'sumStep' in self.settings:
             winInit['sumStep'] = self.settings['sumStep']
-        except:
-            pass
-        try:
+        if 'IDtype' in self.settings:
             winInit['IDtype'] = self.settings['IDtype']
-        except:
-            pass
+
         winInit['database'] = self.dbConn
 
         self.twin = TimeWindows(**winInit)
@@ -1113,26 +1018,22 @@
     def doCompute(self):
 
         # GMessage('OK')
-        # sys.exit()
-        comp=Computor(self.baseline, self.twin, self.dbConn, self.settings['dataExport'])
-        bool,msg=comp.GetStatus()
+        comp = Computor(self.baseline, self.twin, self.dbConn, self.settings['dataExport'])
+        bool, msg = comp.GetStatus()
         if bool:
             self.initGrassLayerMgr()
             self.initTemporalMgr()
 
         GMessage(msg)
-        #elf.initgrassManagement()
+        self.initgrassManagement()
 
     def initGrassLayerMgr(self):
         grassLayerMgr = {}
-        try:
+        if 'colorRules' in self.settings:
             grassLayerMgr['rules'] = self.settings['colorRules']
-        except:
-            pass
-        try:
+
+        if 'colorName' in self.settings:
             grassLayerMgr['color'] = self.settings['colorName']
-        except:
-            pass
 
         grassLayerMgr['database'] = self.dbConn
         GrassLayerMgr(**grassLayerMgr)
@@ -1146,9 +1047,10 @@
         print label
         GError(label)
 
+
 class MyApp(wx.App):
     def OnInit(self):
-        frame = MyFrame(None, -1, "MW worker")
+        frame = MyFrame(None, -1, "MW manager")
         frame.Show(True)
         self.SetTopWindow(frame)
         return True
@@ -1163,5 +1065,3 @@
 
 if __name__ == "__main__":
     main()
-
-

Modified: grass-addons/grass7/gui/wxpython/wx.mwprecip/mw3.py
===================================================================
--- grass-addons/grass7/gui/wxpython/wx.mwprecip/mw3.py	2015-03-19 18:24:26 UTC (rev 64886)
+++ grass-addons/grass7/gui/wxpython/wx.mwprecip/mw3.py	2015-03-20 12:18:23 UTC (rev 64887)
@@ -2,18 +2,16 @@
 # -*- coding: utf-8
 # __author__ = 'matt'
 
-from pgwrapper import pgwrapper as pg
-from math import sin, cos, atan2, degrees, radians, tan, sqrt, fabs
-import sys, os, shutil
+from math import sin, cos, atan2, degrees, tan, sqrt
+import  shutil
 import psycopg2
 import time
-from datetime import datetime, timedelta
 import math
+from subprocess import PIPE
 
+from pgwrapper import pgwrapper as pg
 from core.gcmd import RunCommand
 from grass.pygrass.modules import Module
-from subprocess import PIPE
-from core.gcmd import GMessage, GError, GWarning
 
 
 try:
@@ -230,6 +228,7 @@
                           overwrite=True)
         os.remove(tmpFile)
 
+
 class RainGauge():
     def __init__(self, database, pathfile):
         self.db = database
@@ -273,7 +272,7 @@
         except IOError as (errno, strerror):
             print "I/O error({0}): {1}".format(errno, strerror)
 
-        #write list of string to database
+        # write list of string to database
         try:
             with open(os.path.join(self.schemaPath, gaugeTMPfile), 'wr') as io:
                 io.writelines(tmp)
@@ -309,6 +308,7 @@
             io.close()
             os.remove(os.path.join(self.schemaPath, gaugeTMPfile))
 
+
 class Baseline():
     def __init__(self, type, pathToFile, statFce='mode', quantile=97, roundMode=3, aw=0):
         self.quantile = quantile
@@ -333,6 +333,7 @@
 
         print self.pathToFile
 
+
 class TimeWindows():
     def __init__(self, database, IDtype, sumStep, startTime=None,
                  endTime=None, linksIgnored=False, linksOnly=False, links=None, linksMap=None):
@@ -492,7 +493,7 @@
 
             # sql = "SELECT (timestamp'%s')+ %s* interval '1 second'" % (cur_timestamp, self.intervalStr)
             # cur_timestamp = self.database.connection.executeSql(sql)[0][0]
-            #rint cur_timestamp
+            # rint cur_timestamp
             #print  timedelta(seconds=1)
             #print self.intervalStr
             cur_timestamp = cur_timestamp + self.intervalStr * timedelta(seconds=1)
@@ -526,6 +527,7 @@
             # sql = "DROP TABLE %s.%s" % (self.schema, self.database.recordTableName)
         grass.message('creating time windows-done')
 
+
 class Computor():
     def __init__(self, baseline, timeWin, database, exportData):
         self.awConst = baseline.aw
@@ -547,7 +549,7 @@
         return self.status.get('bool'), self.status.get('msg')
 
     def ExportData(self):
-            pass
+        pass
 
     def cleanDatabase(self):
         sql = "DROP schema IF EXISTS %s CASCADE" % self.database.schema
@@ -561,8 +563,8 @@
         '''@note  returns disct - key:linkid'''
         baseline = self.baseline
         database = self.database
-        tMin=self.timeWin.timestamp_min
-        tMax=self.timeWin.timestamp_max
+        tMin = self.timeWin.timestamp_min
+        tMax = self.timeWin.timestamp_max
 
         def computeBaselinFromMode(recordTable):
             sql = "SELECT linkid from %s group by 1" % recordTable
@@ -594,10 +596,10 @@
 
         def computeBaselineFromTime():
             def chckTimeValidity(tIn):
-                #print tIn
-                tIn=str(tIn).replace("\n", "")
+                # print tIn
+                tIn = str(tIn).replace("\n", "")
 
-                tIn=datetime.strptime(tIn, "%Y-%m-%d %H:%M:%S")
+                tIn = datetime.strptime(tIn, "%Y-%m-%d %H:%M:%S")
                 if tIn > tMax or tIn < tMin:
                     return False
                 return True
@@ -613,7 +615,7 @@
             # 2013-09-11 04:00:00
             # 2013-09-11 04:00:00
             # ###############################
-            #@typestr choose statistical method for baseline computing.
+            # @typestr choose statistical method for baseline computing.
             # typestr='avg'
             # typestr='mode'
             # typestr='quantile'
@@ -634,11 +636,11 @@
                     st += line.replace("\n", "")
                     if 'i' in line.split("\n")[0]:  #get baseline form interval
                         fromt = f.next()
-                        if not chckTimeValidity( fromt):
+                        if not chckTimeValidity(fromt):
                             return False
                         st += fromt.replace("\n", "")
                         tot = f.next()
-                        if not chckTimeValidity( tot):
+                        if not chckTimeValidity(tot):
                             return False
                         #validate input data
                         if not isTimeValid(fromt) or not isTimeValid(tot):
@@ -690,7 +692,7 @@
                 length = len(tmp)
                 links = len(tmp[0])
                 i = 0
-               # print mydict1
+                # print mydict1
                 #compute avg(divide sum by num of datasets)
                 for dataset in tmp:
                     for link in dataset:
@@ -818,8 +820,8 @@
                         limit 1" % (baseline.quantile, recordTable, linkid)
 
                 resu = database.connection.executeSql(sql, True, True)
-                #print resu
-                resu=resu[0][0]
+                # print resu
+                resu = resu[0][0]
                 tmp.append(str(linkid) + ',' + str(resu) + '\n')
 
             io0 = open(os.path.join(database.pathworkSchemaDir, "baseline"), "wr")
@@ -837,7 +839,7 @@
             return mydict
 
         if self.baseline.type == 'values':
-            #print 'valuesDirectly'
+            # print 'valuesDirectly'
             self.baselineDict = readBaselineFromText(self.baseline.pathTofile)
 
         elif self.baseline.type == 'fromDryWin':
@@ -851,7 +853,7 @@
 
     def logMsg(self, msg):
         if self.status.get('msg') == 'Done':
-            self.status['msg']=''
+            self.status['msg'] = ''
         self.status['msg'] += msg + '\n'
         grass.warning(msg)
 
@@ -924,7 +926,7 @@
         self.database.connection.executeSql(sql, False, True)
 
         # optimalization of commits
-        self.database.connection.setIsoLvl(0)  #TODO dont know what is that
+        # self.database.connection.setIsoLvl(0)  #TODO dont know what is that
 
         # choose baseline source (quantile, user values, ) get dict linkid, baseline
         grass.message("Computing baseline")
@@ -949,7 +951,7 @@
 
         temp = []
         grass.message("Computing precipitation")
-        skippedList=[]
+        skippedList = []
         for record in resu:
             curLinkData = linksDict[record[0]]  # record[0] is linkid
 
@@ -960,7 +962,7 @@
                     #skippedList.append(record[0])
                 continue
             # if missing baseline. Link will be skip
-            if record[0] in self.baselineDict and (curLinkData[2] / 1000000) > 10: #TODO
+            if record[0] in self.baselineDict and (curLinkData[2] / 1000000) > 10:  #TODO
                 # coef_a_k[alpha, k]
                 coef_a_k = self.computeAlphaK(curLinkData[2], curLinkData[1])
 
@@ -1080,6 +1082,7 @@
 
             return av, kv
 
+
 class GrassLayerMgr():
     def __init__(self, database, color=None, rules=None):
         self.color = color
@@ -1094,7 +1097,7 @@
         # print map
         # print self.database.linkVecMapName
         # print self.database.precipColName
-        #print self.color
+        # print self.color
 
         if self.color is not None:
             for lay in range(1, self.getNumLayer(self.database.linkVecMapName), 1):
@@ -1244,7 +1247,7 @@
                    temporaltype=temporalType,
                    semantictype=semanticType,
                    overwrite=True)
-        #getErrorMsg=True)
+        # getErrorMsg=True)
         #print ret
         #print err
 
@@ -1287,7 +1290,7 @@
         self.host = host
         if workSchema is None:
             workSchema = 'tmp_' + randomWord(3)
-        self.schema  = workSchema
+        self.schema = workSchema
         if dataSchema is None:
             dataSchema = 'public'
         self.dataSchema = dataSchema
@@ -1342,7 +1345,7 @@
                                  driver='pg',
                                  database=conninfo) != 0:
                 grass.warning("Unable to connect to the database by temporal grass driver.")
-                return False #TODO
+                return False  # TODO
         if db == 'sql':
             grass.run_command('t.connect',
                               flags='d')
@@ -1439,7 +1442,7 @@
             # grass.message("Optimalization of frequency attribute")
             # sql = "UPDATE link\
             # SET frequency = record.frequency\
-            #        FROM record\
+            # FROM record\
             #        WHERE record.linkid = link.linkid;"
             #self.connection.executeSql(sql, False, True)
 
@@ -1525,6 +1528,7 @@
             if not os.path.isdir(self.pathworkSchemaDir):
                 raise
 
+
 '''
 def main():
     db = Database(name='tyden')

Modified: grass-addons/grass7/gui/wxpython/wx.mwprecip/mw_util.py
===================================================================
--- grass-addons/grass7/gui/wxpython/wx.mwprecip/mw_util.py	2015-03-19 18:24:26 UTC (rev 64886)
+++ grass-addons/grass7/gui/wxpython/wx.mwprecip/mw_util.py	2015-03-20 12:18:23 UTC (rev 64887)
@@ -1,11 +1,16 @@
 #!/usr/bin/env python
-import re, os, sys
+__author__ = 'matt'
+import re
+import os
+import sys
 import random
 import string
 import wx
 import csv
-from datetime import datetime, timedelta
-from gui_core import gselect
+from datetime import timedelta
+import wx.lib.filebrowsebutton as filebrowse
+import codecs
+from core.gcmd import GMessage, GError
 
 
 class SaveLoad(wx.Panel):
@@ -21,7 +26,7 @@
 
 
 class BaseInput(wx.Panel):
-    #def __init__(self, parent, label,key, cats=False):
+    # def __init__(self, parent, label,key, cats=False):
     def __init__(self, parent, label):
         wx.Panel.__init__(self, parent=parent, id=wx.ID_ANY)
         statText = wx.StaticText(self, id=wx.ID_ANY, label=label)
@@ -39,15 +44,206 @@
         return self.key
 
     def GetValue(self):
-        value=self.text.GetValue()
-        if value=='':
+        value = self.text.GetValue()
+        if value == '':
             return None
         else:
             return value
 
     def SetValue(self, value):
         self.text.SetValue((str(value)))
+'''
+class TextInput1(wx.Panel):
+    def __init__(self, parent, label, tmpPath=None):
+        wx.Panel.__init__(self, parent=parent, id=wx.ID_ANY)
+        self.sizer=wx.BoxSizer(wx.VERTICAL)
+        fExt = None
+        if not fExt:
+            fMask = '*'
+        else:
+            fMask = '%s files (*%s)|*%s|Files (*)|*' % (fExt[1:].upper(), fExt, fExt)
+        fbb = filebrowse.FileBrowseButton(parent = self, id = wx.ID_ANY, fileMask = fMask,
+                                           labelText = '',
+                                          dialogTitle = 'Choose file',
+                                          buttonText = 'Browse',
+                                          startDirectory = os.getcwd(), fileMode = 'file',
+                                          changeCallback = self.OnSetValue)
 
+        self.sizer.Add(item = fbb, proportion = 0,
+                        flag = wx.EXPAND | wx.RIGHT, border = 5)
+
+        # A file browse button is a combobox with two children:
+        # a textctl and a button;
+        # we have to target the button here
+            # widget for interactive input
+        ifbb = wx.TextCtrl(parent = self, id = wx.ID_ANY,
+                           style = wx.TE_MULTILINE,
+                           size = (-1, 75))
+        #if p.get('value', '') and os.path.isfile(p['value']):
+        #    f = open(p['value'])
+         #   ifbb.SetValue(''.join(f.readlines()))
+         #   f.close()
+
+        ifbb.Bind(wx.EVT_TEXT, self.OnFileText)
+
+        btnLoad = wx.Button(parent = self, id = wx.ID_ANY, label = _("&Load"))
+        btnLoad.SetToolTipString(_("Load and edit content of a file"))
+        btnLoad.Bind(wx.EVT_BUTTON, self.OnFileLoad)
+        btnSave = wx.Button(parent = self, id = wx.ID_ANY, label = _("&Save as"))
+        btnSave.SetToolTipString(_("Save content to a file for further use"))
+        btnSave.Bind(wx.EVT_BUTTON, self.OnFileSave)
+
+        fileContentLabel = wx.StaticText(parent=self,
+            id=wx.ID_ANY,
+            label=_('or enter values directly:'))
+        fileContentLabel.SetToolTipString(
+            _("Enter file content directly instead of specifying"
+              " a file."
+              " Temporary file will be automatically created."))
+        self.sizer.Add(item=fileContentLabel,
+                        proportion = 0,
+                        flag = wx.EXPAND | wx.RIGHT | wx.LEFT | wx.BOTTOM, border = 5)
+        self.sizer.Add(item = ifbb, proportion = 1,
+                        flag = wx.EXPAND | wx.RIGHT | wx.LEFT, border = 5)
+        btnSizer = wx.BoxSizer(wx.HORIZONTAL)
+        btnSizer.Add(item = btnLoad, proportion = 0,
+                     flag = wx.ALIGN_RIGHT | wx.RIGHT, border = 10)
+        btnSizer.Add(item = btnSave, proportion = 0,
+                     flag = wx.ALIGN_RIGHT)
+        self.sizer.Add(item = btnSizer, proportion = 0,
+                        flag = wx.ALIGN_RIGHT | wx.RIGHT | wx.TOP, border = 5)
+
+    def OnFileText(self, event):
+        """File input interactively entered"""
+        text = event.GetString()
+        #p = self.task.get_param(value = event.GetId(), element = 'wxId', raiseError = False)
+        #if not p:
+        #    return # should not happen
+        #win = self.FindWindowById(p['wxId'][0])
+        if text:
+        #    filename = win.GetValue()
+            if not filename :  # m.proj has - as default
+        #        filename = grass.tempfile()
+        #        win.SetValue(filename)
+
+        #    enc = locale.getdefaultlocale()[1]
+            f = codecs.open(filename, encoding = enc, mode = 'w', errors='replace')
+            try:
+                f.write(text)
+                if text[-1] != os.linesep:
+                    f.write(os.linesep)
+            finally:
+                f.close()
+        else:
+        #    win.SetValue('')
+
+    def OnFileSave(self, event):
+        """Save interactive input to the file"""
+        wId = event.GetId()
+        win = {}
+        for p in self.task.params:
+            if wId in p.get('wxId', []):
+                win['file'] = self.FindWindowById(p['wxId'][0])
+                win['text'] = self.FindWindowById(p['wxId'][1])
+                break
+
+        if not win:
+            return
+
+        text = win['text'].GetValue()
+        if not text:
+            GMessage(parent = self,
+                          message = _("Nothing to save."))
+            return
+
+        dlg = wx.FileDialog(parent = self,
+                            message = "Save input as...",
+                            defaultDir = os.getcwd(),
+                            style = wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT)
+
+        if dlg.ShowModal() == wx.ID_OK:
+            path = dlg.GetPath()
+            #enc = locale.getdefaultlocale()[1]
+            f = codecs.open(path, mode = 'w', errors='replace')
+            try:
+                f.write(text + os.linesep)
+            finally:
+                f.close()
+
+            win['file'].SetValue(path)
+
+        dlg.Destroy()
+
+    def OnFileLoad(self, event):
+        """Load file to interactive input"""
+        me = event.GetId()
+        win = dict()
+        for p in self.task.params:
+            if 'wxId' in p and me in p['wxId']:
+                win['file'] = self.FindWindowById(p['wxId'][0])
+                win['text'] = self.FindWindowById(p['wxId'][1])
+                break
+
+        if not win:
+            return
+
+        path = win['file'].GetValue()
+        if not path:
+            gcmd.GMessage(parent = self,
+                          message = _("Nothing to load."))
+            return
+
+        data = ''
+        try:
+            f = open(path, "r")
+        except IOError as e:
+            gcmd.GError(parent = self, showTraceback = False,
+                        message = _("Unable to load file.\n\nReason: %s") % e)
+            return
+
+        try:
+            data = f.read()
+        finally:
+            f.close()
+
+        win['text'].SetValue(data)
+
+    def OnSetValue(self, event):
+        """Retrieve the widget value and set the task value field
+        accordingly.
+
+        Use for widgets that have a proper GetValue() method, i.e. not
+        for selectors.
+        """
+        myId = event.GetId()
+        me = wx.FindWindowById(myId)
+        name = me.GetName()
+
+        found = False
+        for porf in self.task.params + self.task.flags:
+            if 'wxId' not in porf:
+                continue
+            if myId in porf['wxId']:
+                found = True
+                break
+
+        if not found:
+            return
+
+        if name == 'GdalSelect':
+            porf['value'] = event.dsn
+        elif name == 'ModelParam':
+            porf['parameterized'] = me.IsChecked()
+        else:
+            if isinstance(me, wx.SpinCtrl):
+                porf['value'] = str(me.GetValue())
+            else:
+                porf['value'] = me.GetValue()
+
+        self.OnUpdateValues(event)
+
+        event.Skip()
+'''
 class TextInput(wx.Panel):
     def __init__(self, parent, label, tmpPath=None):
         wx.Panel.__init__(self, parent=parent, id=wx.ID_ANY)
@@ -82,13 +278,11 @@
             self.firstDirInp = True
             if self.tmpPath is None:
                 self.tmpPath=os.path.join(os.path.dirname(os.path.realpath(__file__)), 'tmp%s' % randomWord(3))
-                print self.tmpPath
-            self.pathInput.SetValue(str(self.tmpPath))
+                self.pathInput.SetValue(str(self.tmpPath))
 
         io=open(self.tmpPath,'w')
         io.writelines(self.directInp.GetValue())
         io.close()
-        print self.directInp.GetValue()
 
     def onBrowse(self, event):
         openFileDialog = wx.FileDialog(self, "Open text file", style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST)
@@ -105,6 +299,8 @@
         return self.directInp.GetValue()
 
     def SetValue(self):
+        if not os.path.isfile(self.pathInput.GetValue()):
+            return -1
         io = open(self.pathInput.GetValue(), 'r')
         str = io.read()
         try:
@@ -119,6 +315,8 @@
         except:
             print "Unexpected error:", sys.exc_info()[0]
             raise
+            return -1
+
         io.close()
 
     def GetPath(self):
@@ -129,6 +327,8 @@
             return path
 
     def SetPath(self, value):
+        if value is None:
+            return
         self.firstDirInpActive = True
         self.pathInput.SetValue(value)
         if self.SetValue() == -1:
@@ -164,8 +364,6 @@
                 return  # the user changed idea...
             path = openFileDialog.GetPath()
             self.pathInput.SetValue(path)
-
-
         else:
             openFileDialog = wx.FileDialog(self, "Choose a file:", style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST)
             if openFileDialog.ShowModal() == wx.ID_CANCEL:
@@ -185,6 +383,57 @@
         self.pathInput.SetValue(value)
 
 
+
+class FileInput(wx.Panel):
+    def __init__(self, parent, label, dir=False, tmpPath=None):
+        wx.Panel.__init__(self, parent=parent, id=wx.ID_ANY)
+        self.dir = dir
+        self.tmpPath = tmpPath
+        statText = wx.StaticText(self, id=wx.ID_ANY, label=label)
+
+        self.pathInput = wx.TextCtrl(self, id=wx.ID_ANY)
+        self.browseBtt = wx.Button(self, id=wx.ID_ANY, label='Browse')
+
+        sizer = wx.BoxSizer(wx.VERTICAL)
+        sizer2 = wx.BoxSizer(wx.HORIZONTAL)
+        sizer2.Add(self.pathInput, flag=wx.EXPAND, proportion=1)
+        sizer2.Add(self.browseBtt, flag=wx.EXPAND)
+
+        sizer.Add(statText, flag=wx.EXPAND)
+        sizer.Add(sizer2, flag=wx.EXPAND)
+
+        self.SetSizer(sizer)
+        self.browseBtt.Bind(wx.EVT_BUTTON, self.onBrowse)
+
+    def onBrowse(self, event):
+        if self.dir:
+            openFileDialog = wx.DirDialog(self, "Choose a directory:",
+                                          style=wx.DD_DEFAULT_STYLE | wx.DD_DIR_MUST_EXIST | wx.DD_CHANGE_DIR)
+            if openFileDialog.ShowModal() == wx.ID_CANCEL:
+                return  # the user changed idea...
+            path = openFileDialog.GetPath()
+            self.pathInput.SetValue(path)
+
+
+        else:
+            openFileDialog = wx.FileDialog(self, "Choose a file:", style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST)
+            if openFileDialog.ShowModal() == wx.ID_CANCEL:
+                return  # the user changed idea...
+            path = openFileDialog.GetPath()
+            self.pathInput.SetValue(path)
+
+
+    def GetPath(self):
+        path = self.pathInput.GetValue()
+        if len(path) != 0:
+            return path
+        else:
+            return None
+
+    def SetPath(self, value):
+        self.pathInput.SetValue(value)
+
+
 def YesNo(parent, question, caption='Yes or no?'):
     dlg = wx.MessageDialog(parent, question, caption, wx.YES_NO | wx.ICON_QUESTION)
     result = dlg.ShowModal() == wx.ID_YES
@@ -196,7 +445,7 @@
     try:
         lis = os.listdir(fpath)
     except:
-        #GError('canot find folder%s'%fpath)
+        # GError('canot find folder%s'%fpath)
         return 0
     tmp = []
     for path in lis:
@@ -234,18 +483,20 @@
     temp_list[len(temp_list):] = data_list[end:len(data_list)]
     open(new_file, 'wr').writelines(temp_list)
 
+
 def OnSaveAs(parent):
-    saveFileDialog = wx.FileDialog(parent, "Save file","", "",
-                                       "files (*.*)|*.*", wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT)
+    saveFileDialog = wx.FileDialog(parent, "Save file", "", "",
+                                   "files (*.*)|*.*", wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT)
 
     if saveFileDialog.ShowModal() == wx.ID_CANCEL:
-        return     # the user changed idea...
+        return  # the user changed idea...
 
     # save the current contents in the file
     # this can be done with e.g. wxPython output streams:
     output_stream = (saveFileDialog.GetPath())
     return output_stream
 
+
 def saveDict(fn, dict_rap):
     f = open(fn, "wb")
     w = csv.writer(f)

Modified: grass-addons/grass7/gui/wxpython/wx.mwprecip/pgwrapper.py
===================================================================
--- grass-addons/grass7/gui/wxpython/wx.mwprecip/pgwrapper.py	2015-03-19 18:24:26 UTC (rev 64886)
+++ grass-addons/grass7/gui/wxpython/wx.mwprecip/pgwrapper.py	2015-03-20 12:18:23 UTC (rev 64887)
@@ -6,11 +6,11 @@
 # import psycopg2.extensions
 
 class pgwrapper:
-    def __init__(self, dbname, host='', user='', passwd='',port=''):
+    def __init__(self, dbname, host='', user='', passwd='', port=''):
         self.dbname = dbname  # Database name which connect to.
         self.host = host  # Host name (default is "localhost")
         self.user = user  # User name for login to the database.
-        self.port=port
+        self.port = port
         self.password = passwd  # Password for login to the database.
         self.connection = self.setConnect()  # Set a connection to the database
         self.cursor = self.setCursor()  # Generate cursor.
@@ -38,13 +38,14 @@
         except:
             print 'cannot set cursor'
 
+    '''
     def setIsoLvl(self, lvl='0'):
         if lvl == 0:
             self.connection.set_session('read committed')
         elif lvl == 1:
             self.connection.set_session(readonly=True, autocommit=False)
+    '''
 
-
     def copyfrom(self, afile, table, sep='|'):
         try:
             self.cursor.copy_from(afile, table, sep=sep)
@@ -81,17 +82,16 @@
         # Excute the SQL statement.
         # self.print_message (sql)
 
-        print '*'*50
+        print '*' * 50
         print sql
-        print '*'*50
+        print '*' * 50
 
         try:
             self.cursor.execute(sql)
         except Exception, e:
             self.connection.rollback()
-            self.print_message( e.pgerror)
+            self.print_message(e.pgerror)
 
-
         if commit:
             self.connection.commit()
 

Deleted: grass-addons/grass7/gui/wxpython/wx.mwprecip/wx.mwprecip.py
===================================================================
--- grass-addons/grass7/gui/wxpython/wx.mwprecip/wx.mwprecip.py	2015-03-19 18:24:26 UTC (rev 64886)
+++ grass-addons/grass7/gui/wxpython/wx.mwprecip/wx.mwprecip.py	2015-03-20 12:18:23 UTC (rev 64887)
@@ -1,1157 +0,0 @@
-#!/usr/bin/env python
-
-
-from mw_util import *
-from core.gcmd import GMessage, GError
-
-from gui_core import gselect
-
-class DBconn(wx.Panel):
-    def __init__(self, parent, settings={}):
-        wx.Panel.__init__(self, parent=parent, id=wx.ID_ANY)
-        self.settings = settings
-        self.database = BaseInput(self, label='Name of database')
-        self.schema = BaseInput(self, label='Name of schema')
-        self.host = BaseInput(self, label='Host name')
-        self.user = BaseInput(self, label='User name')
-        self.port = BaseInput(self, label='Port')
-        self.passwd = BaseInput(self, label='Password')
-        # self.saveLoad = SaveLoad(self)
-        self.okBtt = wx.Button(self, wx.ID_OK, label='ok and close')
-        self.okBtt.Bind(wx.EVT_BUTTON, self.saveSettings)
-        if len(settings) > 0:
-            self.loadSettings()
-        self._layout()
-
-    def _layout(self):
-        panelSizer = wx.BoxSizer(wx.VERTICAL)
-
-        panelSizer.Add(self.database, flag=wx.EXPAND)
-        panelSizer.Add(self.schema, flag=wx.EXPAND)
-        panelSizer.Add(self.host, flag=wx.EXPAND)
-        panelSizer.Add(self.user, flag=wx.EXPAND)
-        panelSizer.Add(self.port, flag=wx.EXPAND)
-        panelSizer.Add(self.passwd, flag=wx.EXPAND)
-        panelSizer.AddSpacer(10, 0, wx.EXPAND)
-        # panelSizer.Add(self.saveLoad, flag=wx.EXPAND)
-        panelSizer.Add(self.okBtt, flag=wx.EXPAND)
-
-        self.SetSizerAndFit(panelSizer)
-
-    def loadSettings(self, sett=None):
-        if sett:
-            self.settings = sett
-
-        try:
-            self.database.SetValue(self.settings['database'])
-        except:
-            print 'err'
-            pass
-        try:
-            self.schema.SetValue(self.settings['schema'])
-        except:
-            pass
-        try:
-            self.host.SetValue(self.settings['host'])
-        except:
-            pass
-        try:
-            self.user.SetValue(self.settings['user'])
-        except:
-            pass
-        try:
-            self.port.SetValue(self.settings['port'])
-        except:
-            pass
-        try:
-            self.passwd.SetValue(self.settings['passwd'])
-        except:
-            pass
-
-    def saveSettings(self, settings=None):
-        if settings is not None:
-            self.settings = settings
-        self.settings['database'] = self.database.GetValue()
-        self.settings['schema'] = self.schema.GetValue()
-        self.settings['host'] = self.host.GetValue()
-        self.settings['user'] = self.user.GetValue()
-        self.settings['port'] = self.port.GetValue()
-        self.settings['passwd'] = self.passwd.GetValue()
-
-        return self.settings
-
-
-class PointInterpolationPanel(wx.Panel):
-    def __init__(self, parent, settings=None):
-        wx.Panel.__init__(self, parent=parent, id=wx.ID_ANY)
-        self.settings = settings
-        self.interpolState = wx.CheckBox(self, label='interpolate points along links')
-        self.interpolState.Bind(wx.EVT_CHECKBOX, self.onCheckInterpol)
-        self.interpolState.SetValue(False)
-        self.rb1 = wx.RadioButton(self, label='Number of points', style=wx.RB_GROUP)
-        self.rb2 = wx.RadioButton(self, label='Distance')
-        self.val = BaseInput(self, label='Value')
-
-        panelSizer = wx.BoxSizer(wx.VERTICAL)
-
-        panelSizer.Add(self.interpolState, flag=wx.EXPAND)
-        panelSizer.Add(self.rb1, flag=wx.EXPAND)
-        panelSizer.Add(self.rb2, flag=wx.EXPAND)
-        panelSizer.Add(self.val, flag=wx.EXPAND)
-        self.SetSizerAndFit(panelSizer)
-        self.onCheckInterpol()
-
-    def onCheckInterpol(self, evt=None):
-        if self.interpolState.GetValue():
-            self.rb1.Enable()
-            self.rb2.Enable()
-            self.val.Enable()
-        else:
-            self.rb1.Disable()
-            self.rb2.Disable()
-            self.val.Disable()
-
-    def loadSettings(self, sett=None):
-        if sett:
-            self.settings = sett
-        try:
-            self.rb1.SetValue(self.settings['pitypeDist'])
-        except:
-            pass
-        try:
-            self.val.SetValue(self.settings['pivalue'])
-        except:
-            pass
-
-    def saveSettings(self, settings=None):
-        if settings is not None:
-            self.settings = settings
-        self.settings['pitypeDist'] = self.rb1.GetValue()
-        self.settings['pivalue'] = self.val.GetValue()
-        return self.settings
-
-
-class BaselinePanel(wx.Panel):
-    def __init__(self, parent, settings={}):
-        wx.Panel.__init__(self, parent=parent, id=wx.ID_ANY)
-        self.settings = settings
-
-        self.dryWin = wx.RadioButton(self, label='Compute from dry windows', style=wx.RB_GROUP)
-        self.fromFile = wx.RadioButton(self, label='Direct text input')
-        self.baselTypeTxt = wx.StaticText(self, label='Select statistic method')
-        self.baselType = wx.ComboBox(self, id=wx.ID_ANY, value="quantile", choices=['avg', 'mode', 'quantile'])
-        self.round = BaseInput(self, 'Round data to "n" of decimal places')  # TODO MODE disable
-        self.quantile = BaseInput(self, 'Set quantile in %')  # TODO quantile disable
-        self.aw = BaseInput(self, 'Antena wetting value')
-        self.dryInterval = TextInput(self, 'Set interval of dry period')
-        self.fromFileVal = TextInput(self, 'Set baseline values in csv format')
-        # self.SLpanel = SaveLoad(self)
-        self.okBtt = wx.Button(self, wx.ID_OK, label='ok and close')
-        self.onChangeMethod(None)
-        self.fromFile.Bind(wx.EVT_RADIOBUTTON, self.onChangeMethod)
-        self.dryWin.Bind(wx.EVT_RADIOBUTTON, self.onChangeMethod)
-        self.okBtt.Bind(wx.EVT_BUTTON, self.saveSettings)
-        if len(settings) > 0:
-            self.loadSettings(None)
-
-        self._layout()
-
-    def loadSettings(self, sett=None):
-        if sett is not None:
-            self.settings = sett
-        try:
-            self.fromFile.SetValue(self.settings['fromFile'])
-        except:
-            pass
-        try:
-            self.dryWin.SetValue(self.settings['dryWin'])
-        except:
-            pass
-        try:
-            self.quantile.SetValue(self.settings['quantile'])
-        except:
-            pass
-
-        try:
-            self.baselType.SetValue(self.settings['baselType'])
-        except:
-            pass
-        try:
-            self.round.SetValue(self.settings['round'])
-        except:
-            pass
-        try:
-            self.aw.SetValue(self.settings['aw'])
-        except:
-            pass
-        try:
-            self.dryInterval.SetPath(self.settings['dryInterval'])
-        except:
-            pass
-        try:
-            self.fromFileVal.SetPath(self.settings['fromFileVal'])
-        except:
-            pass
-        self.onChangeMethod()
-
-    def saveSettings(self, evt=None, sett=None):
-        if sett:
-            self.settings = sett
-        self.settings['fromFile'] = self.fromFile.GetValue()
-        self.settings['dryWin'] = self.dryWin.GetValue()
-
-        self.settings['baselType'] = self.baselType.GetValue()
-        self.settings['round'] = self.round.GetValue()
-        self.settings['quantile'] = self.quantile.GetValue()
-        self.settings['aw'] = self.aw.GetValue()
-        self.settings['dryInterval'] = self.dryInterval.GetPath()
-        self.settings['fromFileVal'] = self.fromFileVal.GetPath()
-        return self.settings
-
-    def onChangeMethod(self, evt=None):
-        if self.dryWin.GetValue() is False:
-            self.baselType.Disable()
-            self.round.Disable()
-            self.aw.Disable()
-            self.dryInterval.Disable()
-            self.quantile.Disable()
-            self.fromFileVal.Enable()
-        else:
-            self.baselType.Enable()
-            self.round.Enable()
-            self.aw.Enable()
-            self.quantile.Enable()
-            self.dryInterval.Enable()
-            self.fromFileVal.Disable()
-
-    def _layout(self):
-        sizer = wx.BoxSizer(wx.VERTICAL)
-        sizer.Add(self.dryWin, flag=wx.EXPAND)
-        sizer.Add(self.fromFile, flag=wx.EXPAND)
-        sizer.Add(self.baselTypeTxt, flag=wx.EXPAND)
-        sizer.Add(self.baselType, flag=wx.EXPAND)
-        sizer.Add(self.round, flag=wx.EXPAND)
-        sizer.Add(self.quantile, flag=wx.EXPAND)
-        sizer.Add(self.aw, flag=wx.EXPAND)
-        sizer.Add(self.dryInterval, flag=wx.EXPAND)
-        sizer.AddSpacer(10, 0, wx.EXPAND)
-        sizer.Add(self.fromFileVal, flag=wx.EXPAND)
-        sizer.AddSpacer(10, 0, wx.EXPAND)
-        # sizer.Add(self.SLpanel, flag=wx.EXPAND)
-        sizer.Add(self.okBtt, flag=wx.EXPAND)
-        self.SetSizerAndFit(sizer)
-
-
-'''
-class DataMgrRG(wx.Panel):
-    def __init__(self, parent, settings=None):
-        wx.Panel.__init__(self, parent=parent, id=wx.ID_ANY)
-        self.sett = settings
-'''
-
-
-class DataMgrMW(wx.Panel):
-    def __init__(self, parent, settings={}):
-        wx.Panel.__init__(self, parent=parent, id=wx.ID_ANY)
-        self.settings = settings
-
-        self.stBoxTWIN = wx.StaticBox(self, wx.ID_ANY, 'Time windows MW')
-
-        # =================DATA=========================
-        self.linksAll = wx.RadioButton(self, label='All', style=wx.RB_GROUP)
-        self.linksOnly = wx.RadioButton(self, label='Use links')
-        self.linksIngnore = wx.RadioButton(self, label='Ignore links')
-        self.linksAll.Bind(wx.EVT_RADIOBUTTON, self.refreshLinkSet)
-        self.linksIngnore.Bind(wx.EVT_RADIOBUTTON, self.refreshLinkSet)
-        self.linksOnly.Bind(wx.EVT_RADIOBUTTON, self.refreshLinkSet)
-        self.vectorMap = wx.RadioButton(self,label='Vector map')
-        self.vectorMap.Bind(wx.EVT_RADIOBUTTON,self.refreshLinkSet)
-
-        # self.links = BaseInput(self,'Set links according to radio above',True)
-        self.links = BaseInput(self, 'Set links according to radio above')
-        self.mapLabel=wx.StaticText(self,label='Select vector map')
-        self.map = gselect.Select(self, type='vector',multiple=False)
-
-        self.start = BaseInput(self, label='Start time')
-        self.end = BaseInput(self, label='End time')
-        self.getStartBtt = wx.Button(self, label='Get min')
-        self.getEndBtt = wx.Button(self, label='Get max')
-        self.sumStep = wx.ComboBox(self, id=wx.ID_ANY, value="minute", choices=['minute', 'hour', 'day'])
-
-        self.stBoxGauge = wx.StaticBox(self, wx.ID_ANY, 'Rain gauge')
-        self.inpRainGauge = FileInput(self, 'Select folder with raingauges data')
-        self.inpRainGauge.pathInput.Bind(wx.EVT_TEXT,self.disableLinksInp)
-        # self.sb1 = wx.StaticBox(self, wx.ID_ANY, 'Baseline')
-        # self.type = self.rb1 = wx.RadioButton(self, label='Number of points', style=wx.RB_GROUP)
-        if len(settings) > 0:
-            self.loadSettings()
-        self._layout()
-
-    def disableLinksInp(self,evt=None):
-        if self.inpRainGauge.GetPath() is not None:
-            self.linksAll.Disable()
-            self.linksOnly.Disable()
-            self.linksIngnore.Disable()
-            self.links.Disable()
-            self.vectorMap.Disable()
-            self.mapLabel.Disable()
-            self.map.Disable()
-        else:
-            self.linksAll.Enable()
-            self.linksOnly.Enable()
-            self.linksIngnore.Enable()
-            self.vectorMap.Enable()
-            self.mapLabel.Enable()
-            self.map.Enable()
-
-            if not self.linksAll.GetValue():
-                self.links.Enable()
-
-    def refreshLinkSet(self, evt=None):
-        if self.linksAll.GetValue():
-            self.links.Disable()
-        else:
-            self.links.Enable()
-
-        if self.vectorMap.GetValue():
-            self.links.Hide()
-            self.mapLabel.Show()
-            self.map.Show()
-        else:
-            self.links.Show()
-            self.mapLabel.Hide()
-            self.map.Hide()
-        self.Fit()
-
-    def saveSettings(self, evt=None, sett=None):
-        if sett:
-            self.settings = sett
-        self.settings['linksOnly'] = self.linksOnly.GetValue()
-        self.settings['linksIngnore'] = self.linksIngnore.GetValue()
-        self.settings['linksMap'] = self.map.GetValue()
-        self.settings['links'] = self.links.GetValue()
-        self.settings['start'] = self.start.GetValue()
-        self.settings['end'] = self.end.GetValue()
-        self.settings['sumStep'] = self.sumStep.GetValue()
-        self.settings['inpRainGauge'] = self.inpRainGauge.GetPath()
-        return self.settings
-
-    def loadSettings(self, sett=None):
-        if sett:
-            self.settings = sett
-        try:
-            self.map.SetValue(eval(self.settings['linksMap']))
-        except:
-            pass
-        try:
-            self.linksOnly.SetValue(eval(self.settings['linksOnly']))
-        except:
-            pass
-        try:
-            self.linksIngnore.SetValue(eval(self.settings['linksIngnore']))
-        except:
-            pass
-        try:
-            self.links.SetValue(self.settings['links'])
-        except:
-            pass
-        try:
-            self.start.SetValue(self.settings['start'])
-        except:
-            pass
-        try:
-            self.end.SetValue(self.settings['end'])
-        except:
-            pass
-        try:
-            self.sumStep.SetValue(self.settings['sumStep'])
-        except:
-            pass
-        try:
-            self.inpRainGauge.SetPath(self.settings['inpRainGauge'])
-        except:
-            pass
-
-    def _layout(self):
-        panelSizer = wx.BoxSizer(wx.VERTICAL)
-        self.SetSizerAndFit(panelSizer)
-
-        linksSizer = wx.BoxSizer(wx.HORIZONTAL)
-        linksSizer.Add(self.linksAll, flag=wx.EXPAND, proportion=1)
-        linksSizer.Add(self.linksOnly, flag=wx.EXPAND, proportion=1)
-        linksSizer.Add(self.linksIngnore, flag=wx.EXPAND, proportion=1)
-        linksSizer.Add(self.vectorMap, flag=wx.EXPAND, proportion=1)
-
-        stBoxSizerTWIN = wx.StaticBoxSizer(self.stBoxTWIN, orient=wx.VERTICAL)
-        stBoxSizerTWIN.Add(linksSizer, flag=wx.EXPAND, proportion=1)
-        stBoxSizerTWIN.Add(self.links, flag=wx.EXPAND, proportion=1)
-        stBoxSizerTWIN.Add(self.mapLabel, flag=wx.EXPAND)
-        stBoxSizerTWIN.Add(self.map, flag=wx.EXPAND)
-        stBoxSizerTWIN.AddSpacer(5, 5, 1, wx.EXPAND)
-        stBoxSizerTWIN.AddSpacer(5, 5, 1, wx.EXPAND)
-        stBoxSizerTWIN.Add(self.start, flag=wx.EXPAND, proportion=1)
-        stBoxSizerTWIN.Add(self.getStartBtt)
-        stBoxSizerTWIN.AddSpacer(5, 5, 1, wx.EXPAND)
-        stBoxSizerTWIN.Add(self.end, flag=wx.EXPAND, proportion=1)
-        stBoxSizerTWIN.Add(self.getEndBtt)
-        stBoxSizerTWIN.AddSpacer(5, 5, 1, wx.EXPAND)
-        stBoxSizerTWIN.Add(wx.StaticText(self, id=wx.ID_ANY, label='Time increment'))
-        stBoxSizerTWIN.Add(self.sumStep, flag=wx.EXPAND)
-
-        gaugeSizer = wx.BoxSizer(wx.HORIZONTAL)
-        gaugeSizer.Add(self.inpRainGauge, flag=wx.EXPAND, proportion=1)
-
-        stBoxSizerRGAUGE = wx.StaticBoxSizer(self.stBoxGauge, orient=wx.VERTICAL)
-        stBoxSizerRGAUGE.Add(gaugeSizer, flag=wx.EXPAND, proportion=1)
-
-        panelSizer.Add(stBoxSizerTWIN, flag=wx.EXPAND)
-        panelSizer.Add(stBoxSizerRGAUGE, flag=wx.EXPAND)
-
-        # panelSizer.Add(self.exportDataBtt, flag=wx.EXPAND)
-        # panelSizer.Add(self.computeBtt, flag=wx.EXPAND)
-        self.SetSizerAndFit(panelSizer)
-        self.refreshLinkSet()
-
-class GrassLayers(wx.Panel):
-    def __init__(self, parent, settings={}):
-        wx.Panel.__init__(self, parent=parent, id=wx.ID_ANY)
-        self.settings = settings
-        self.colorRules = TextInput(self,label='Color table')
-        self.colorsName = BaseInput(self,label='Name of color table')
-        self.layout()
-
-    def loadSettings(self, sett=None):
-        if sett:
-            self.settings = sett
-        try:
-            self.colorRules.SetValue(self.settings['colorRules'])
-        except:
-            pass
-
-        try:
-            self.colorsName.SetValue(self.settings['colorsName'])
-        except:
-            pass
-
-    def saveSettings(self, evt=None, sett=None):
-        if sett:
-            self.settings = sett
-        self.settings['colorName'] = self.colorsName.GetValue()
-        self.settings['colorRules'] = self.colorRules.GetPath()
-        return self.settings
-
-    def layout(self):
-        panelSizer = wx.BoxSizer(wx.VERTICAL)
-        panelSizer.Add(self.colorsName,flag= wx.EXPAND )
-        panelSizer.Add(self.colorRules, flag=wx.EXPAND )
-        self.SetSizerAndFit(panelSizer)
-
-class GeometryPanel(wx.Panel):
-    def __init__(self, parent, settings={}):
-        wx.Panel.__init__(self, parent=parent, id=wx.ID_ANY)
-        self.settings = settings
-        self.label=wx.StaticText(self,label='Create vector geometry map')
-        self.linksExp = wx.RadioButton(self, label='Links', style=wx.RB_GROUP)
-        self.nodesExp = wx.RadioButton(self, label='Nodes')
-        self.mapName=BaseInput(self,'Map name')
-        self.bttExport=wx.Button(self,label='Export')
-
-        self.layout()
-
-    def layout(self):
-        panelSizer = wx.BoxSizer(wx.VERTICAL)
-
-        panelSizer.Add(self.label,flag=wx.EXPAND)
-        panelSizer.Add(self.linksExp,flag=wx.EXPAND)
-        panelSizer.Add(self.nodesExp,flag=wx.EXPAND)
-        panelSizer.Add(self.mapName,flag=wx.EXPAND)
-        panelSizer.Add(self.bttExport,flag=wx.EXPAND)
-        self.SetSizerAndFit(panelSizer)
-
-    def GetOptions(self):
-        if self.linksExp.GetValue():
-            type='links'
-        else:
-            type='nodes'
-        return type,self.mapName.GetValue()
-
-class ExportData(wx.Panel):
-    def __init__(self, parent):
-        wx.Panel.__init__(self, parent=parent, id=wx.ID_ANY)
-
-        self.chkid=wx.CheckBox(self,label='linkid')
-        self.chkid.SetValue(True)
-        self.chkid.Disable()
-        self.chktime=wx.CheckBox(self,label='time')
-        self.chktime.SetValue(True)
-        self.chktime.Disable()
-
-        self.chkprecip=wx.CheckBox(self,label='precipitation')
-        self.chkrx=wx.CheckBox(self,label='rx')
-        self.chktx=wx.CheckBox(self,label='tx')
-        self.chkfreq=wx.CheckBox(self,label='frequency')
-        self.chkpol=wx.CheckBox(self,label='polarization')
-        self.okBtt=wx.Button(self,label='export')
-        self.layout()
-        #self.chkprecip.Bind(wx.EVT_CHECKBOX,self.onChckPrec)
-
-    def layout(self):
-        mainSizer=wx.BoxSizer(wx.VERTICAL)
-
-        mainSizer.Add(self.chkid,wx.EXPAND)
-        mainSizer.Add(self.chktime,wx.EXPAND)
-        mainSizer.Add(self.chkprecip,wx.EXPAND)
-        mainSizer.Add(self.chkrx,wx.EXPAND)
-        mainSizer.Add(self.chktx,wx.EXPAND)
-        mainSizer.Add(self.chkfreq,wx.EXPAND)
-        mainSizer.Add(self.chkpol,wx.EXPAND)
-        mainSizer.Add(self.okBtt,wx.EXPAND)
-
-        self.SetSizerAndFit(mainSizer)
-
-class MyFrame(wx.Frame):
-    def __init__(self, parent, id, title):
-        wx.Frame.__init__(self, parent, id, title, size=(480, 640))
-        self.workPath = os.path.dirname(os.path.realpath(__file__))
-        self.initWorkingFoldrs()
-        self.settings = {}
-        self.settingsLst = []
-        self.mainSizer = wx.BoxSizer(wx.VERTICAL)
-
-        menubar = wx.MenuBar()
-        settMenu = wx.Menu()
-        fileMenu = wx.Menu()
-        databaseItem = settMenu.Append(wx.ID_ANY, 'Database', 'Set database')
-        baselineItem = settMenu.Append(wx.ID_ANY, 'Baseline', 'Set baseline methods')
-        geometry = settMenu.Append(wx.ID_ANY,'Geometry', 'Create vector geometry')
-        quitItem = settMenu.Append(wx.ID_EXIT, 'Quit', 'Quit application')
-        menubar.Append(settMenu, '&Options')
-
-        #geoMenu = wx.Menu()
-
-        #menubar.Append(geoMenu, '&Settings')
-
-
-        self.SetMenuBar(menubar)
-        self.Bind(wx.EVT_MENU, self.onQuit, quitItem)
-        self.Bind(wx.EVT_MENU, self.onSetDatabase, databaseItem)
-        self.Bind(wx.EVT_MENU, self.onSetBaseline, baselineItem)
-        self.Bind(wx.EVT_MENU, self.onSetGeometry, geometry)
-
-        #def initNotebook(self):
-
-        self.ntb = wx.Notebook(self, id=wx.ID_ANY)
-        self.dataMgrMW = DataMgrMW(self.ntb)
-        self.dataMgrMW.getEndBtt.Bind(wx.EVT_BUTTON, self.getMaxTime)
-        self.dataMgrMW.getStartBtt.Bind(wx.EVT_BUTTON, self.getMinTime)
-
-        #self.dataMgrRG = DataMgrMW(self.ntb )
-        self.pointInter = PointInterpolationPanel(self.ntb)
-        self.ntb.AddPage(page=self.dataMgrMW, text='MW data')
-        #self.ntb.AddPage(page=self.dataMgrRG, text='RG data')
-        self.ntb.AddPage(page=self.pointInter, text='Points Interpolation')
-
-        self.grassLayers = GrassLayers(self.ntb, self.settings)
-        self.ntb.AddPage(page=self.grassLayers, text='Layers')
-
-        #def initProfileSett(self):
-        self.loadScheme = wx.StaticText(self, label='Load settings', id=wx.ID_ANY)
-        self.profilSelection = wx.ComboBox(self)
-        self.schema = BaseInput(self, 'Name of new working profile')
-        self.schema.text.Bind(wx.EVT_TEXT, self.OnSchemeTxtChange)
-        self.newScheme = wx.Button(self, label='Save new profile')
-        self.newScheme.Bind(wx.EVT_BUTTON, self.OnSaveSettings)
-        self.newScheme.Disable()
-        self.profilSelection.Bind(wx.EVT_COMBOBOX, self.OnLoadSettings)
-
-        #def initRunBtt(self):
-        self.computeBtt = wx.Button(self, label='Compute')
-        self.exportDataBtt = wx.Button(self, label='Export data')
-        self.computeBtt.Bind(wx.EVT_BUTTON, self.runCompute)
-        self.exportDataBtt.Bind(wx.EVT_BUTTON, self.exportData)
-
-        self.findProject()
-        self.layout()
-
-    def getMinTime(self, evt=None):
-        self.OnSaveSettings(toFile=False)
-        interface = Gui2Model(self, self.settings)  # TODO optimalize init
-        if interface.connStatus:
-
-            self.dataMgrMW.start.SetValue(interface.dbConn.minTimestamp())
-
-    def getMaxTime(self, evt=None):
-        self.OnSaveSettings(toFile=False)
-        interface = Gui2Model(self, self.settings)
-        if interface.connStatus:
-            self.dataMgrMW.end.SetValue(interface.dbConn.maxTimestamp())
-
-    def GetConnection(self):
-        self.OnSaveSettings(toFile=False)
-        interface = Gui2Model(self, self.settings)
-        if interface.connStatus:
-             return interface.dbConn
-
-    def OnSchemeTxtChange(self, evt=None):
-        if self.schema.GetValue() is not None:
-            self.newScheme.Enable()
-        else:
-            self.newScheme.Disable()
-
-    def OnLoadSettings(self, evt=None):
-        currSelId = self.profilSelection.GetSelection()
-        self.settings = self.settingsLst[currSelId]
-        try:
-            self.dataMgrMW.loadSettings(self.settings)
-        except:
-            pass
-        try:
-            self.dataMgrRG.loadSettings(self.settings)
-        except:
-            pass
-        try:
-            self.databasePnl.loadSettings(self.settings)
-        except:
-            pass
-        try:
-            self.baselinePnl.loadSettings(self.settings)
-        except:
-            pass
-        try:
-            self.grassLayers.loadSettings(self.settings)
-        except:
-            pass
-
-    def OnSaveSettings(self, evt=None, toFile=True):
-        try:
-            self.settings = self.dataMgrMW.saveSettings(sett=self.settings)
-        except:
-            pass
-            # try:
-            # self.settings=self.dataMgrRG.saveSettings(sett=self.settings)
-            # except:
-        # pass
-        try:
-            self.settings = self.databasePnl.saveSettings(sett=self.settings)
-        except:
-            pass
-        try:
-            self.settings = self.baselinePnl.saveSettings(sett=self.settings)
-        except:
-            pass
-        try:
-            self.settings = self.grassLayers.saveSettings(sett=self.settings)
-        except:
-            pass
-
-        try:
-            self.settings['workSchema'] = self.profilSelection.GetValue()
-        except:
-            pass
-
-        if self.schema.GetValue() is not None:
-            self.settings['workSchema'] = self.schema.GetValue()
-
-        if toFile:
-            tmpPath = os.path.join(self.workPath, "save", self.settings['workSchema'])
-            saveDict(tmpPath, self.settings)
-            self.findProject()
-
-    def initWorkingFoldrs(self):
-        savePath=os.path.join(self.workPath,'save')
-        if not os.path.exists(savePath):
-            os.makedirs(savePath)
-
-        tmpPath=os.path.join(self.workPath,'temp')
-        if not os.path.exists(tmpPath):
-            os.makedirs(tmpPath)
-
-    def findProject(self):
-        try:
-            projectDir = os.path.join(self.workPath, "save")
-        except:
-            GMessage('Cannot find "save" folder')
-            return
-        filePathList = getFilesInFoldr(projectDir, True)
-        # print 'filePathList',filePathList
-        if filePathList != 0:
-            self.profilSelection.Clear()
-            for n, path in enumerate(filePathList):
-                tmpDict = readDict(path)
-                self.settingsLst.append(tmpDict)
-                self.profilSelection.Append(str(tmpDict['workSchema']))
-        else:
-            return
-
-    def onSetGeometry(self,evt):
-        self.geDialog = wx.Dialog(self, id=wx.ID_ANY,
-                                  title='Geometry creator',
-                                  style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER,
-                                  size=wx.DefaultSize,
-                                  pos=wx.DefaultPosition)
-
-        self.geDialog.SetSize((500, 500))
-
-        if self.settings:
-            self.geometryPnl = GeometryPanel(self.geDialog, self.settings)
-        else:
-            self.geometryPnl = GeometryPanel(self.geDialog)
-
-        self.geometryPnl.bttExport.Bind(wx.EVT_BUTTON, self._onSetGeomDLG)
-        dbSizer = wx.BoxSizer(wx.VERTICAL)
-        dbSizer.Add(self.geometryPnl, flag=wx.EXPAND)
-        self.geDialog.SetSizer(dbSizer)
-        self.geDialog.SetBestFittingSize()
-        self.geDialog.ShowModal()
-        self.geDialog.Destroy()
-
-    def _onSetGeomDLG(self, evt):
-        type,name=self.geometryPnl.GetOptions()
-        if name == '':
-            GMessage('Please set name of map')
-        else:
-            self.createGeometry(type,name)
-            #self.addMapToLay()#TODO giface
-
-    def addMapToLay(self,map):
-        #TODO giface
-        '''
-
-        tree = self._giface.GetLayerTree()
-        if tree:
-            tree.AddLayer(ltype='vector', lname=map,
-                          lcmd=['d.vect', 'map=%s' % map],
-                          lchecked=True)
-        '''
-        pass
-
-    def onSetBaseline(self, evt):
-        self.bsDialog = wx.Dialog(self, id=wx.ID_ANY,
-                                  title='Baseline settings',
-                                  style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER,
-                                  size=wx.DefaultSize,
-                                  pos=wx.DefaultPosition)
-
-        #self.bsDialog.SetSize((500, 500))
-
-        if self.settings:
-            self.baselinePnl = BaselinePanel(self.bsDialog, self.settings)
-        else:
-            self.baselinePnl = BaselinePanel(self.bsDialog)
-
-        self.baselinePnl.okBtt.Bind(wx.EVT_BUTTON, self._onSetBaselineDLG)
-        dbSizer = wx.BoxSizer(wx.VERTICAL)
-        dbSizer.Add(self.baselinePnl, flag=wx.EXPAND)
-
-        self.bsDialog.SetSizer(dbSizer)
-        self.bsDialog.SetBestFittingSize()
-        self.bsDialog.ShowModal()
-        self.bsDialog.Destroy()
-
-    def _onSetBaselineDLG(self, evt):
-        self.settings = self.baselinePnl.saveSettings()
-        print self.settings
-        self.bsDialog.Destroy()
-
-    def onSetDatabase(self, evt):
-        self.dbDialog = wx.Dialog(self, id=wx.ID_ANY,
-                                  title='Database connection settings',
-                                  style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER,
-                                  size=wx.DefaultSize,
-                                  pos=wx.DefaultPosition)
-
-        self.dbDialog.SetSize((500, 500))
-
-        if self.settings:
-            self.databasePnl = DBconn(self.dbDialog, self.settings)
-        else:
-            self.databasePnl = DBconn(self.dbDialog)
-
-        self.databasePnl.okBtt.Bind(wx.EVT_BUTTON, self._onSetDatabaseDLG)
-        dbSizer = wx.BoxSizer(wx.VERTICAL)
-        dbSizer.Add(self.databasePnl, flag=wx.EXPAND)
-        self.dbDialog.SetSizer(dbSizer)
-        self.dbDialog.SetBestFittingSize()
-        self.dbDialog.ShowModal()
-        self.dbDialog.Destroy()
-
-    def _onSetDatabaseDLG(self, evt):
-        self.settings = self.databasePnl.saveSettings()
-        print self.settings
-        self.dbDialog.Destroy()
-
-    def createGeometry(self,type, name):
-        interface = Gui2Model(self, self.settings)
-        interface.initVectorGrass(type=type,name=name)
-
-    def exportData(self, evt):
-
-        self.exportDialog = wx.Dialog(self, id=wx.ID_ANY,
-                                  title='Database connection settings',
-                                  style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER,
-                                  size=wx.DefaultSize,
-                                  pos=wx.DefaultPosition)
-
-        self.exportDialog.SetSize((500, 500))
-        self.exportDMgr = ExportData(self.exportDialog)
-
-        self.exportDMgr.okBtt.Bind(wx.EVT_BUTTON, self._onExport)
-        dbSizer = wx.BoxSizer(wx.VERTICAL)
-        dbSizer.Add(self.exportDMgr, flag=wx.EXPAND)
-        self.exportDialog.SetSizer(dbSizer)
-        self.exportDialog.SetBestFittingSize()
-        self.exportDialog.ShowModal()
-        self.exportDialog.Destroy()
-
-    def _onExport(self,evt=None):
-        path=OnSaveAs(self)
-        self.OnSaveSettings(toFile=False)
-        if not self.exportDMgr.chkprecip.GetValue():
-            attrTmp1=[]
-            attrTmp1.append('link.linkid')
-            attrTmp2=[]
-            attrTmp3=[]
-            #attrTmp2.append('public.linkid')
-            if self.exportDMgr.chkfreq.GetValue():
-                attrTmp1.append('link.frequency')
-            if self.exportDMgr.chkpol.GetValue():
-                attrTmp1.append('link.polarization')
-
-            attrTmp2.append('record.time')
-            if self.exportDMgr.chkrx.GetValue():
-                attrTmp2.append('record.rxpower')
-            if self.exportDMgr.chktx.GetValue():
-                attrTmp2.append('record.txpower')
-
-            attrTmp4='WHERE'
-            if len(attrTmp1) > 0:
-                attrTmp3.append('link')
-            if len(attrTmp2) > 0:
-                attrTmp3.append('record')
-
-            if len(attrTmp1) > 0 and len(attrTmp2) > 0:
-                attrTmp4='WHERE link.linkid=record.linkid AND'
-                attrTmp0=attrTmp1+attrTmp2
-                attrTmp0 = ",".join(attrTmp0)
-            elif len(attrTmp1) > 0:
-                attrTmp0 = ",".join(attrTmp1)
-            elif len(attrTmp2) > 0:
-                attrTmp0 = ",".join(attrTmp2)
-
-            if len(attrTmp3)>1:
-                attrTmp3 = ",".join(attrTmp3)
-            else:
-                attrTmp3=attrTmp3[0]
-
-            sql="SELECT %s FROM %s %s record.time>'%s' and record.time< '%s'  "%(attrTmp0,
-                                                                                attrTmp3,
-                                                                                attrTmp4,
-                                                                                self.dataMgrMW.start.GetValue(),
-                                                                                self.dataMgrMW.end.GetValue())
-            conn=self.GetConnection()
-            res=conn.connection.executeSql(sql, True, True)
-            lines=''
-            for r in res:
-                lines+=str(r)[1:][:-1].replace('datetime.datetime','').replace("'","") +'\n'
-            print conn.pathworkSchemaDir
-            #path=os.path.join(conn.pathworkSchemaDir, "export")
-            io0 = open(path, "wr")
-            io0.writelines(lines)
-            io0.close()
-            GMessage('Data exported<%s>'%path)
-
-        else:
-            exportData = {'getData':True,'dataOnly':False}
-            if YesNo(self, 'Export data only?'):
-                exportData['dataOnly'] = True
-            self.settings['dataExport'] = exportData
-
-            #if rain gauges
-            if self.dataMgrMW.inpRainGauge.GetPath() is not None:
-                self.settings['IDtype']='gaugeid'
-            else:
-                self.settings['IDtype']='linkid'
-
-            interface = Gui2Model(self, self.settings)
-            interface.initVectorGrass()
-            interface.initTimeWinMW()
-            interface.initBaseline()
-            interface.doCompute()
-            conn=self.GetConnection()
-            sql='SELECT * FROM %s.%s'%(interface.dbConn.schema,interface.dbConn.computedPrecip)
-            res=conn.connection.executeSql(sql, True, True)
-            lines=''
-            for r in res:
-                lines+=str(r)[1:][:-1] +'\n'
-            print conn.pathworkSchemaDir
-            #path=os.path.join(conn.pathworkSchemaDir, "export")
-            io0 = open(path, "wr")
-            io0.writelines(lines)
-            io0.close()
-            GMessage('Data exported<%s>'%path)
-
-        self.exportDialog.Destroy()
-
-    def runCompute(self, evt):
-        self.OnSaveSettings(toFile=False)
-        exportData = {'getData':False,'dataOnly':False}
-        self.settings['dataExport'] = exportData
-
-        #if rain gauges
-        if self.dataMgrMW.inpRainGauge.GetPath() is not None:
-            self.settings['IDtype']='gaugeid'
-        else:
-            self.settings['IDtype']='linkid'
-
-        interface = Gui2Model(self, self.settings)
-        interface.initVectorGrass()
-
-        #if interpolate points along lines
-        if self.pointInter.interpolState.GetValue():
-            interface.initPInterpolation()
-
-        interface.initTimeWinMW()
-        interface.initBaseline()
-        interface.doCompute()
-
-    def layout(self):
-        self.mainSizer.Add(self.loadScheme, flag=wx.EXPAND)
-        self.mainSizer.Add(self.profilSelection, flag=wx.EXPAND)
-        self.mainSizer.Add(self.schema, flag=wx.EXPAND)
-        self.mainSizer.Add(self.newScheme, flag=wx.EXPAND)
-
-        self.mainSizer.AddSpacer(10, 0, wx.EXPAND)
-        self.mainSizer.Add(self.ntb, flag=wx.EXPAND)
-
-        self.mainSizer.AddSpacer(10, 0, wx.EXPAND)
-        self.mainSizer.Add(self.computeBtt, flag=wx.EXPAND)
-        self.mainSizer.Add(self.exportDataBtt, flag=wx.EXPAND)
-
-        self.SetSizer(self.mainSizer)
-        # self.Fit()
-
-    def onQuit(self, e):
-        self.Close()
-
-class Gui2Model():
-    def __init__(self, wxParent, settings):
-        parent = wxParent
-        self.settings = settings
-        self.dbConn = None
-        self.connStatus=False
-        self.initConnection()
-
-    def initConnection(self, info=False):
-        conninfo=None
-        try:
-            conninfo = {'name': self.settings['database']}
-        except:
-            GMessage('name of database is missing')
-            return
-        try:
-            conninfo['workSchema'] = self.settings['workSchema']
-        except:
-            pass
-        try:
-            conninfo['dataSchema'] = self.settings['schema']
-        except:
-            pass
-        try:
-            conninfo['host'] = self.settings['host']
-        except:
-            pass
-        try:
-            conninfo['user'] = self.settings['user']
-        except:
-            pass
-        try:
-            conninfo['port'] = self.settings['port']
-        except:
-            pass
-        try:
-            conninfo['password'] = self.settings['passwd']
-        except:
-            pass
-
-        if conninfo is None:
-            self.connStatus=False
-            GMessage('Database connection failed')
-            return
-
-
-        if not info:  # prepare for computing
-            self.dbConn = Database(**conninfo)
-            self.connStatus=True
-            self.dbConn.firstPreparation()
-            self.dbConn.prepareDB()
-            self.dbConn.prepareDir()
-
-            return self.dbConn
-        else:  # just get info about curr database state
-            self.dbConn = Database(**conninfo)
-            self.connStatus=True
-            return self.dbConn
-
-    def initVectorGrass(self,type=None,name=None):
-        convertor = VectorLoader(self.dbConn)
-        if name:
-            self.dbConn.nodeVecMapName=name
-            self.dbConn.linkVecMapName=name
-
-        if type=='nodes' or type is None:
-            # create native vector map(nodes)
-            pointsSQL = convertor.selectNodes()
-            # print pointsSQL
-            pointsASCII = convertor.getASCIInodes(pointsSQL)
-            convertor.grass_vinASCII(pointsASCII, self.dbConn.nodeVecMapName)
-        # create native vector map(links)
-        if type=='links'or type is None:
-            linksSQL = convertor.selectLinks()
-            linksASCII = convertor.getASCIIlinks(linksSQL)
-            convertor.grass_vinASCII(linksASCII, self.dbConn.linkVecMapName)
-
-    def initPInterpolation(self):
-        try:
-            pitypeDist = self.settings['pitypeDist']
-        except:
-            pass
-        try:
-            pivalue = self.settings['pivalue']
-        except:
-            self.errMsg('Missing value for interpolating points along lines')
-
-        PointInterpolation(self.dbConn, pivalue, pitypeDist)
-
-    def initBaseline(self):
-        baselInit = {}
-        try:
-            baselInit['statFce'] = self.settings['baselType']
-        except:
-            pass
-        try:
-            baselInit['quantile'] = self.settings['quantile']
-        except:
-            pass
-        try:
-            baselInit['roundMode'] = self.settings['round']
-        except:
-            pass
-        try:
-            baselInit['aw'] = self.settings['aw']
-        except:
-            pass
-        methodSel = False
-        try:
-            if self.settings['fromFile']:
-                baselInit['type'] = 'values'
-                try:
-                    baselInit['pathToFile'] = self.settings['fromFileVal']
-                except:
-                    self.errMsg('Path to file with baseline values is not defined')
-                methodSel = True
-        except:
-            pass
-        try:
-            if self.settings['dryWin']:
-                baselInit['type'] = 'fromDryWin'
-                try:
-                    baselInit['pathToFile'] = self.settings['dryInterval']
-                except:
-                    self.errMsg('Dry interval is not defined')
-                methodSel = True
-        except:
-            pass
-
-        if not methodSel:
-            self.errMsg('Baseline method is not selected')
-        print baselInit
-        self.baseline = Baseline(**baselInit)
-
-    def initTimeWinMW(self):
-        winInit = {}
-        try:
-            winInit['linksOnly'] = eval(self.settings['linksOnly'])
-        except:
-            pass
-        try:
-            winInit['linksOnly'] = eval(self.settings['linksMap'])
-        except:
-            pass
-        try:
-            winInit['linksIngnore'] = eval(self.settings['linksIngnore'])
-        except:
-            pass
-        try:
-            winInit['links'] = self.settings['links']
-        except:
-            pass
-        try:
-            winInit['startTime'] = self.settings['start']
-        except:
-            pass
-        try:
-            winInit['endTime'] = self.settings['end']
-        except:
-            pass
-        try:
-            winInit['sumStep'] = self.settings['sumStep']
-        except:
-            pass
-        try:
-            winInit['IDtype'] = self.settings['IDtype']
-        except:
-            pass
-        winInit['database'] = self.dbConn
-
-        self.twin = TimeWindows(**winInit)
-
-    def doCompute(self):
-
-        # GMessage('OK')
-        # sys.exit()
-        comp=Computor(self.baseline, self.twin, self.dbConn, self.settings['dataExport'])
-        bool,msg=comp.GetStatus()
-        if bool:
-            self.initGrassLayerMgr()
-            self.initTemporalMgr()
-
-        GMessage(msg)
-        #elf.initgrassManagement()
-
-    def initGrassLayerMgr(self):
-        grassLayerMgr = {}
-        try:
-            grassLayerMgr['rules'] = self.settings['colorRules']
-        except:
-            pass
-        try:
-            grassLayerMgr['color'] = self.settings['colorName']
-        except:
-            pass
-
-        grassLayerMgr['database'] = self.dbConn
-        GrassLayerMgr(**grassLayerMgr)
-
-
-    def initTemporalMgr(self):
-        GrassTemporalMgr(self.dbConn, self.twin)
-        GMessage('Finish')
-
-    def errMsg(self, label):
-        print label
-        GError(label)
-
-class MyApp(wx.App):
-    def OnInit(self):
-        frame = MyFrame(None, -1, "MW worker")
-        frame.Show(True)
-        self.SetTopWindow(frame)
-        return True
-
-
-app = MyApp(0)  # Create an instance of the application class
-app.MainLoop()  # Tell it to start processing events
-
-
-
-



More information about the grass-commit mailing list