[GRASS-SVN] r67546 - grass-addons/grass7/gui/wxpython/wx.mwprecip
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Jan 11 02:19:04 PST 2016
Author: krejcmat
Date: 2016-01-11 02:19:04 -0800 (Mon, 11 Jan 2016)
New Revision: 67546
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:
addons g.gui.mwprecip: add logger, measuring elapsed time
Modified: grass-addons/grass7/gui/wxpython/wx.mwprecip/g.gui.mwprecip.py
===================================================================
--- grass-addons/grass7/gui/wxpython/wx.mwprecip/g.gui.mwprecip.py 2016-01-11 09:44:55 UTC (rev 67545)
+++ grass-addons/grass7/gui/wxpython/wx.mwprecip/g.gui.mwprecip.py 2016-01-11 10:19:04 UTC (rev 67546)
@@ -1,5 +1,5 @@
#!/usr/bin/env python
-VERSION = 1.2
+VERSION = 1.3
import sys
import os
import tempfile
@@ -20,7 +20,11 @@
from gui_core.widgets import ColorTablesComboBox,PictureComboBox
from core import globalvar
from core.utils import GetColorTables
+import wx.lib.scrolledpanel as scrolled
+import tempfile
+import logging
+
class DBconn(wx.ScrolledWindow):
def __init__(self, parent, settings={}):
wx.ScrolledWindow.__init__(self, parent, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.HSCROLL|wx.VSCROLL)
@@ -169,6 +173,10 @@
self.loadSettings()
self._layout()
+ def onChangeStatistic(self,evt=None):
+ if self.baselType.GetValue() == 'avg':
+ self.round.Disable()
+ self.quantile.Disable()
def onChangeStatistic(self,evt=None):
if self.baselType.GetValue() == 'avg':
@@ -546,8 +554,11 @@
class MWMainFrame(wx.Frame):
def __init__(self, parent, id, title):
wx.Frame.__init__(self, parent, id, title,style=wx.DEFAULT_FRAME_STYLE )
+
+ self.logger=None
context=StaticContext()
self.workPath = context.getTmpPath()
+ self.initLogger()
self.initWorkingFoldrs()
self.settings = {}
self.settingsLst = []
@@ -615,6 +626,26 @@
self.findProject()
self.layout()
+ def initLogger(self):
+ logging.basicConfig(filename=os.path.join(self.workPath,'mwprecip.log'),
+ level=logging.INFO,
+ format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s',
+ datefmt='%m-%d %H:%M',
+ filemode='w')
+
+
+ console = logging.StreamHandler()
+ console.setLevel(logging.INFO)
+ # set a format which is simpler for console use
+ formatter = logging.Formatter('%(name)-12s: %(levelname)-8s %(message)s')
+ # tell the handler to use this format
+ console.setFormatter(formatter)
+ # add the handler to the root logger
+ logging.getLogger('').addHandler(console)
+
+ self.logger=logging.getLogger('mwprecip.GUI')
+
+
def onAbout(self,evt):
dir=os.path.dirname(os.path.realpath(__file__))
GMessage( "ver: %s \n %s"%(VERSION,dir),self)
@@ -652,7 +683,7 @@
def OnLoadSettings(self, evt=None):
currSelId = self.profilSelection.GetSelection()
self.schema.SetValue(self.profilSelection.GetValue())
- print self.settingsLst[currSelId]
+ #print self.settingsLst[currSelId]
self.settings = self.settingsLst[currSelId]
try:
@@ -695,15 +726,17 @@
pass
self.settings['workSchema'] = self.profilSelection.GetValue()
+
if self.schema.GetValue() is not None:
self.settings['workSchema'] = self.schema.GetValue()
- print self.settings
+ #print self.settings
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)
@@ -719,7 +752,7 @@
GMessage('Cannot find "save" folder',self)
return
filePathList = getFilesInFoldr(projectDir, True)
- print filePathList
+ #print filePathList
# print 'filePathList',filePathList
if filePathList != 0:
self.profilSelection.Clear()
@@ -813,7 +846,7 @@
def _onSetDatabaseDLG(self, evt):
self.settings = self.databasePnl.saveSettings()
- print self.settings
+ #print self.settings
self.dbDialog.Destroy()
def createGeometry(self, type, name):
@@ -888,7 +921,7 @@
lines = ''
for r in res:
lines += str(r)[1:][:-1].replace('datetime.datetime', '').replace("'", "") + '\n'
- print conn.pathworkSchemaDir
+ #print conn.pathworkSchemaDir
#path=os.path.join(conn.pathworkSchemaDir, "export")
io0 = open(path, "w+")
io0.writelines(lines)
@@ -1023,7 +1056,6 @@
conninfo['workPath'] = self.workPath
-
if not info: # prepare for computing
self.dbConn = Database(**conninfo)
self.connStatus = True
@@ -1180,3 +1212,4 @@
if __name__ == "__main__":
main()
+
Modified: grass-addons/grass7/gui/wxpython/wx.mwprecip/mw3.py
===================================================================
--- grass-addons/grass7/gui/wxpython/wx.mwprecip/mw3.py 2016-01-11 09:44:55 UTC (rev 67545)
+++ grass-addons/grass7/gui/wxpython/wx.mwprecip/mw3.py 2016-01-11 10:19:04 UTC (rev 67546)
@@ -3,6 +3,7 @@
from math import sin, cos, atan2, degrees, tan, sqrt
from datetime import datetime
+from datetime import timedelta
import shutil
import psycopg2
import time
@@ -17,9 +18,13 @@
import numpy as np
from mw_util import *
+timeMes=MeasureTime()
+import logging
+logger = logging.getLogger('mwprecip.Computing')
+
class PointInterpolation():
def __init__(self, database, step, methodDist=False):
- grass.message("Interpolating points along lines...")
+ timeMes.timeMsg("Interpolating points along lines...")
self.step = float(step)
self.database = database
self.method = methodDist # 'p' - points, else distance
@@ -89,6 +94,7 @@
sql = "alter table %s.%s drop column long" % (
self.database.schema, nametable) # remove longtitude column from table
self.database.connection.executeSql(sql, False, True)
+ timeMes.timeMsg("Interpolating points along lines-done")
def destinationPointWGS(self, lat1, lon1, brng, s):
a = 6378137
@@ -248,7 +254,7 @@
self.lon = float(f.next())
f.close()
except IOError as (errno, strerror):
- grass.message( "I/O error({0}): {1}".format(errno, strerror))
+ grass.error( "I/O error({0}): {1}".format(errno, strerror))
gaugeTMPfile = "gauge_tmp"
removeLines(old_file=path,
@@ -265,7 +271,7 @@
tmp.append(stri)
f.close()
except IOError as (errno, strerror):
- grass.message( "I/O error({0}): {1}".format(errno, strerror))
+ grass.error( "I/O error({0}): {1}".format(errno, strerror))
# write list of string to database
try:
@@ -273,7 +279,7 @@
io.writelines(tmp)
io.close()
except IOError as (errno, strerror):
- grass.message( "I/O error({0}): {1}".format(errno, strerror))
+ grass.error( "I/O error({0}): {1}".format(errno, strerror))
if not isTableExist(self.db.connection, self.schema, self.db.rgaugeTableName):
# #create table for raingauge stations
@@ -308,15 +314,15 @@
def __init__(self, type='noDryWin', pathToFile=None, statFce='quantile', quantile=97, roundMode=3, aw=0):
if quantile is None:
quantile=97
- grass.message('Quantile is not defined. Default is 97')
+ logger.info('Quantile is not defined. Default is 97')
self.quantile = quantile
if roundMode is None:
roundMode=3
- grass.message('Round is not defined. Default is 3 decimal places')
+ logger.info('Round is not defined. Default is 3 decimal places')
self.roundMode = roundMode
if aw is None:
aw=0
- grass.message('Antena wetting value is not defined. Default is 0')
+ logger.info('Antena wetting value is not defined. Default is 0')
self.aw = aw
self.pathToFile = pathToFile
self.type = type
@@ -448,7 +454,8 @@
self.database.connection.executeSql(sql, False, True)
def crateTimeWin(self):
- grass.message('creating time windows')
+ timeMes.timeMsg('creating time windows')
+ #timeMes.timeMsg()
time_const = 0
nameList = []
tgrass_vector = []
@@ -457,7 +464,7 @@
if self.typeID == 'gaugeid':
prefix = 'g'
- grass.message("from " + str(self.timestamp_min) + " to " + str(self.timestamp_max) + " per " + self.sumStep)
+ timeMes.timeMsg("from " + str(self.timestamp_min) + " to " + str(self.timestamp_max) + " per " + self.sumStep)
# make timewindows from time interval
while cur_timestamp < self.timestamp_max:
self.numWindows += 1
@@ -489,8 +496,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
- #print timedelta(seconds=1)
- #print self.intervalStr
+
cur_timestamp = cur_timestamp + self.intervalStr * timedelta(seconds=1)
# go to next time interval
@@ -507,7 +513,7 @@
except IOError as (errno, strerror):
grass.warning('Cannot write temporal registration file %s' % os.path.join(self.path, TMPname))
- grass.message('creating time windows-done')
+ timeMes.timeMsg('creating time windows-done')
def logMsg(self, msg):
if self.status.get('msg') == 'Done':
@@ -583,6 +589,7 @@
# io1.write('mode|' + str(baseline.aw))
# io1.close
+
def computeBaselineFromTime():
def chckTimeValidity(tIn):
@@ -591,7 +598,7 @@
try:
tIn = datetime.strptime(tIn, "%Y-%m-%d %H:%M:%S")
except ValueError:
- grass.message('Wrong datetime format')
+ logger.info('Wrong datetime format')
return False
if tIn > tMax or tIn < tMin:
return False
@@ -664,7 +671,7 @@
try:
time = datetime.strptime(time, "%Y-%m-%d %H:%M:%S")
except ValueError:
- grass.message('Wrong datetime format')
+ logger.info('Wrong datetime format')
return False
st += str(time).replace("\n", "")
fromt = time + timedelta(seconds=-60)
@@ -758,7 +765,7 @@
try:
time = datetime.strptime(time, "%Y-%m-%d %H:%M:%S")
except ValueError:
- grass.message('Wrong datetime format')
+ logger.info('Wrong datetime format')
return False
st += str(time).replace("\n", "")
fromt = time + timedelta(seconds=-60)
@@ -883,7 +890,7 @@
self.baselineDict = readBaselineFromText(self.baseline.pathTofile)
elif self.baseline.type == 'fromDryWin' :
- grass.message('Computing baselines "dry window" "%s"...' % self.baseline.statFce)
+ logger.info('Computing baselines "dry window" "%s"...' % self.baseline.statFce)
if computeBaselineFromTime():
self.baselineDict = readBaselineFromText(os.path.join(database.pathworkSchemaDir, 'baseline'))
return True
@@ -891,7 +898,7 @@
return False
elif self.baseline.type == 'noDryWin':
- grass.message('Computing baselines "no dry window" "%s"...' % self.baseline.statFce)
+ logger.info('Computing baselines "no dry window" "%s"...' % self.baseline.statFce)
if computeBaselineFromTime():
self.baselineDict = readBaselineFromText(os.path.join(database.pathworkSchemaDir, 'baseline'))
return True
@@ -926,7 +933,7 @@
if not self.timeWin.setTimestamp():
self.logMsg("Out of available time interval",1)
return False
- grass.message("Quering data")
+ timeMes.timeMsg("Quering data")
sql = "SELECT linkid,lenght,polarization,frequency \
FROM %s.link" % self.database.dataSchema
@@ -966,7 +973,7 @@
sql = "SELECT * from %s.record" % self.database.schema
resu = self.database.connection.executeSql(sql, True, True)
- grass.message("Quering data-done")
+ timeMes.timeMsg("Quering data-done")
'''
sql = "SELECT n2.time, n2.txpower-n2.rxpower as a,n1.lenght,n1.polarization,n1.frequency,n1.linkid\
FROM %s.link AS n1 \
@@ -990,29 +997,29 @@
# 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")
+ timeMes.timeMsg("Computing baseline")
if not self.getBaselDict():
self.logMsg('Dry interval is out of defined time interval(from,to)',1)
return False
if len(self.baselineDict) == 0:
self.logMsg('Baselines coputation faild. Check dry windows',1)
return False
- grass.message("Computing baseline-done")
+ timeMes.timeMsg("Computing baseline-done")
# check if baseline from text is correct
if len(self.baselineDict) < link_num:
sql = "SELECT linkid FROM link"
links = self.database.connection.executeSql(sql, True, True)
for link in links:
- # grass.message(type(link))
+ # logger.info(type(link))
if not link[0] in self.baselineDict:
- grass.message("Linkid= %s is missing in txtfile" % str(link[0]))
- grass.message(
+ logger.info("Linkid= %s is missing in txtfile" % str(link[0]))
+ logger.info(
'Missing values "linkid,baseline," in text file. Data are not available in dry interval(baseline) .')
temp = []
errLinkList=[]
- grass.message("Computing precipitation")
+ timeMes.timeMsg("Computing precipitation")
skippedList = []
for record in resu:
curLinkData = linksDict[record[0]] # record[0] is linkid
@@ -1056,18 +1063,18 @@
out = str(record[0]) + "|" + str(record[1]) + "|" + str(R1) + "\n"
temp.append(out)
- grass.message("Computing precipitation-done")
+ timeMes.timeMsg("Computing precipitation-done")
pathExp = os.path.join(self.database.pathworkSchemaDir, "precip")
io = open(pathExp, 'w+')
io.writelines(temp)
io.close()
#if getData:
- grass.message("Computed data has been saved to <%s>" % pathExp)
- grass.message("File structure is <linkid> <time> <precipitation>")
+ logger.info("Computed data has been saved to <%s>" % pathExp)
+ logger.info("File structure is <linkid> <time> <precipitation>")
- grass.message("Writing computed precipitation to database...")
+ logger.info("Writing computed precipitation to database...")
io1 = open(os.path.join(self.database.pathworkSchemaDir, "precip"), "r")
self.database.connection.copyfrom(io1, compPrecTab)
@@ -1162,7 +1169,7 @@
self.makeRGB(map)
def makeRGB(self, map):
- grass.message('Creating RGB column in database')
+ timeMes.timeMsg('Creating RGB column in database')
try:
if self.rules not in [None,""]:
for lay in range(1, self.getNumLayer(self.database.linkVecMapName), 1):
@@ -1186,7 +1193,7 @@
quiet=True,
layer=lay)
- grass.message('Creating RGB column in database-done')
+ timeMes.timeMsg('Creating RGB column in database-done')
except Exception, e:
grass.warning("v.color error < %s>"%e)
@@ -1225,7 +1232,7 @@
quiet=True)
def connectDBaLayers(self):
- grass.message('Connecting tables to maps')
+ timeMes.timeMsg('Connecting tables to maps')
inputMap = self.database.linkVecMapName
if '@' in self.database.linkVecMapName:
self.database.linkVecMapName=self.database.linkVecMapName.split('@')[0]
@@ -1265,7 +1272,7 @@
for win in f.read().splitlines():
layerNum += 1
win = self.database.schema + '.' + win
- grass.message( win)
+ logger.info( win)
RunCommand('v.db.connect',
driver='pg',
map=self.database.linkVecMapName,
@@ -1275,7 +1282,7 @@
overwrite=True,
quiet=True)
f.close()
- grass.message('Connecting tables to maps-done')
+ timeMes.timeMsg('Connecting tables to maps-done')
return self.database.linkVecMapName
@@ -1320,7 +1327,7 @@
#print err
def registerMaps(self):
- grass.message('Registring maps to temporal database')
+ timeMes.timeMsg('Registring maps to temporal database')
gisenv_grass = grass.gisenv()
timeOfLay = self.timeWinConf.timestamp_min
regTMP = ""
@@ -1336,8 +1343,8 @@
io1 = open(regFilePath, 'w+')
io1.writelines(regTMP), io1.close
io1.close()
- grass.message( 'datasetName %s'% self.datasetName)
- grass.message(regFilePath)
+ logger.info( 'datasetName %s'% self.datasetName)
+ logger.info(regFilePath)
RunCommand('t.register',
input=self.datasetName,
@@ -1345,7 +1352,7 @@
file=regFilePath,
overwrite=True)
- grass.message('Registring maps to temporal database-done')
+ timeMes.timeMsg('Registring maps to temporal database-done')
class Database():
def __init__(self, name=None, user=None, password=None,
@@ -1493,15 +1500,15 @@
def firstPreparation(self):
if not isAttributExist(self.connection, 'public', 'link', 'lenght'):
- grass.message("Add colum lenght")
+ logger.info("Add colum lenght")
sql = "ALTER TABLE link ADD COLUMN lenght real; "
self.connection.executeSql(sql, False, True)
- # grass.message("Add colum frequency")
+ # logger.info("Add colum frequency")
# sql = "ALTER TABLE link ADD COLUMN frequency real; "
# self.connection.executeSql(sql, False, True)
- # grass.message("Optimalization of frequency attribute")
+ # logger.info("Optimalization of frequency attribute")
# sql = "UPDATE link\
# SET frequency = record.frequency\
# FROM record\
@@ -1511,7 +1518,7 @@
#sql = "ALTER TABLE record DROP COLUMN frequency;"
#self.connection.executeSql(sql, False, True)
- grass.message("Add function for computing distance ")
+ logger.info("Add function for computing distance ")
'''
sql=r"CREATE OR REPLACE FUNCTION get_earth_distance1
(lon1 Float, lat1 Float, lon2 Float, lat2 Float, Radius Float DEFAULT 6387.7)
@@ -1530,7 +1537,7 @@
sql = r"CREATE OR REPLACE FUNCTION get_earth_distance1 (lon1 Float, lat1 Float, lon2 Float, lat2 Float, Radius Float DEFAULT 6387.7) RETURNS FLOAT AS ' DECLARE K FLOAT := 57.29577951; v_dist FLOAT; BEGIN v_dist := (Radius * ACOS((SIN(Lat1 / K) * SIN(Lat2 / K)) + (COS(Lat1 / K) * COS(Lat2 / K) * COS(Lon2 / K - Lon1 / K)))); RETURN round(CAST (v_dist AS Numeric),3); END; ' LANGUAGE 'plpgsql';"
self.connection.executeSql(sql, False, True)
- grass.message("Computing column lenght")
+ logger.info("Computing column lenght")
sql = "UPDATE link SET lenght = get_earth_distance1(n1.long,n1.lat,n2.long,n2.lat) \
FROM node AS n1 JOIN \
link AS l ON n1.nodeid = fromnodeid \
@@ -1538,26 +1545,26 @@
WHERE link.linkid = l.linkid; "
self.connection.executeSql(sql, False, True)
- #grass.message("Add column precip")
+ #logger.info("Add column precip")
#sql = "ALTER TABLE record ADD COLUMN precip real; "
#self.connection.executeSql(sql, False, True)
- grass.message("Create sequence")
+ logger.info("Create sequence")
sql = "CREATE SEQUENCE serial START 1; "
self.connection.executeSql(sql, False, True)
- grass.message("Add column recordid")
+ logger.info("Add column recordid")
sql = "ALTER TABLE record add column recordid integer default nextval('serial'); "
self.connection.executeSql(sql, False, True)
- grass.message("Create index on recordid")
+ logger.info("Create index on recordid")
sql = "CREATE INDEX idindex ON record USING btree(recordid); "
self.connection.executeSql(sql, False, True)
sql = "CREATE INDEX timeindex ON record USING btree (time); "
self.connection.executeSql(sql, False, True)
- grass.message("Add mode function")
+ logger.info("Add mode function")
sql = "CREATE OR REPLACE FUNCTION _final_mode(anyarray)\
RETURNS anyelement AS $BODY$ SELECT a FROM unnest($1)\
a GROUP BY 1 ORDER BY COUNT(1) DESC, 1 LIMIT 1;\
Modified: grass-addons/grass7/gui/wxpython/wx.mwprecip/mw_util.py
===================================================================
--- grass-addons/grass7/gui/wxpython/wx.mwprecip/mw_util.py 2016-01-11 09:44:55 UTC (rev 67545)
+++ grass-addons/grass7/gui/wxpython/wx.mwprecip/mw_util.py 2016-01-11 10:19:04 UTC (rev 67546)
@@ -11,7 +11,13 @@
import codecs
from core.gcmd import GMessage, GError
from grass.script import core as grass
+import grass.script as grass
+import time
+from datetime import datetime
+import logging
+
+
class StaticContext():
def __init__(self):
gisenvDict = grass.gisenv()
@@ -418,7 +424,38 @@
return tmp
+class MeasureTime():
+ def __init__(self):
+ self.startLast=None
+ self.end=None
+ self.start=None
+ self.logger = logging.getLogger('mwprecip.MeasureTime')
+ def timeMsg(self,msg,end=False):
+ if self.start is None:
+ self.start = time.time()
+ self.startLast= self.start
+ #grass.message("Measuring time - start: %s "%self.start)
+ self.logger.info("Measuring time - START: %s "%str(datetime.now()))
+ else:
+ self.end = time.time()
+ elapsedTotal=self.end - self.start
+ elapsedLast=self.end-self.startLast
+ self.startLast=self.end
+
+ #grass.message("Elapsed time from start < %s > : %s"%(msg,elapsed))
+ #grass.message("Elapsed time for last part < %s > : %s"%(msg,elapsedLast))
+
+ self.logger.info("TOTAL TIME < %s > : %s"%(msg,elapsedTotal))
+ self.logger.info("LAST PART TIME< %s > : %s"%(msg,elapsedLast))
+
+ if end:
+ #grass.message("Total time: %s"%(elapsed))
+ #grass.message("Measuring time - end: %s "%self.end)
+
+ self.logger.info("TOTAL TIME e: %s"%(elapsedTotal))
+ self.logger.info("Measuring time - END: %s "%str(datetime.now()))
+
def isAttributExist(connection, schema, table, columns):
sql = "SELECT EXISTS( SELECT * FROM information_schema.columns WHERE \
table_schema = '%s' AND \
@@ -483,6 +520,8 @@
print "I/O error({0}): {1}".format(e.errno, e.strerror)
+
+
def randomWord(length):
return ''.join(random.choice(string.lowercase) for i in range(length))
Modified: grass-addons/grass7/gui/wxpython/wx.mwprecip/pgwrapper.py
===================================================================
--- grass-addons/grass7/gui/wxpython/wx.mwprecip/pgwrapper.py 2016-01-11 09:44:55 UTC (rev 67545)
+++ grass-addons/grass7/gui/wxpython/wx.mwprecip/pgwrapper.py 2016-01-11 10:19:04 UTC (rev 67546)
@@ -4,6 +4,7 @@
import sys
import psycopg2 as ppg
# import psycopg2.extensions
+import logging
class pgwrapper:
def __init__(self, dbname, host='', user='', passwd='', port=''):
@@ -14,6 +15,7 @@
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.
+ self.logger = logging.getLogger('mwprecip')
def setConnect(self):
conn_string = "dbname='%s'" % self.dbname
@@ -28,7 +30,9 @@
try:
conn = ppg.connect(conn_string)
except:
- print 'Cannot connect to database'
+ self.logger.error('Cannot connect to database')
+ self.print_message('Cannot connect to database')
+ return
return conn
@@ -36,8 +40,8 @@
try:
return self.connection.cursor()
except:
- print 'cannot set cursor'
-
+ self.logger.error('Cannot set cursor')
+ self.print_message('Cannot set cursor')
'''
def setIsoLvl(self, lvl='0'):
if lvl == 0:
@@ -53,6 +57,8 @@
except Exception, err:
self.connection.rollback()
+ self.logger.error(" Catched error (as expected):\n")
+ self.logger.error(err)
self.print_message(" Catched error (as expected):\n")
self.print_message(err)
@@ -67,6 +73,8 @@
self.connection.rollback()
self.print_message(" Catched error (as expected):\n")
self.print_message(err)
+ self.logger.error("Catched error (as expected):\n")
+ self.logger.error(err)
pass
@@ -80,13 +88,14 @@
def executeSql(self, sql, results=True, commit=False):
# Excute the SQL statement.
- self.print_message (sql)
+ self.logger.debug(sql)
try:
self.cursor.execute(sql)
except Exception, e:
self.connection.rollback()
self.print_message(e.pgerror)
+ self.logger.error(e.pgerror)
if commit:
self.connection.commit()
@@ -122,7 +131,6 @@
sql_update_col = 'UPDATE "' + table + '" SET ' + parse
else:
sql_update_col = 'UPDATE "' + table + '" SET ' + parse + ' WHERE ' + where
- print "upcol %s" % sql_update_col
# Excute the SQL statement.
self.cursor.execute(sql_update_col)
More information about the grass-commit
mailing list