+ self.unguardReading()
+ if rv[0:5] == "SQL: ":
+ return self.returnSqlStatementResult(rv[6:])
+ else:
+ return rv
+
+ def initMysqlConn(self):
+ global import_mysql_ok
+ if not import_mysql_ok:
+ return
+ host=self.config_parser.get("mysql", "host")
+ user=self.config_parser.get("mysql", "user")
+ pwd=self.config_parser.get("mysql", "pwd")
+ db=self.config_parser.get("mysql", "db")
+ if host != "" and user != "" and pwd != "" and db != "" and self.dbconn is None:
+ try:
+ dbconn = MySQLdb.connect (host = host, user = user, passwd = pwd, db = db)
+ self.dbconn=dbconn
+ except MySQLdb.Error, e:
+ logging.error("Error connecting to MySql Database: %d: %s" % (e.args[0], e.args[1]))
+
+ def returnSqlStatementResult(self, statement):
+ if self.dbconn is None:
+ return ""
+ cursor = self.dbconn.cursor()
+ try:
+ cursor.execute(statement)
+ results = cursor.fetchall()
+ res_str = " ".join(map(lambda row: row[0], results))
+ logging.debug("UWSCfg: mysql resulst: "+res_str)
+ cursor.close()
+ return res_str
+ except:
+ logging.error("UWSCfg: Mysql Stmt failed: " + statement)
+ traceback.print_exc(file=sys.stdout)
+ return ""
+
+def touchURL(url):
+ try:
+ f = urllib.urlopen(url)
+ rq_response = f.read()
+ logging.debug("touchURL: Response "+rq_response)
+ f.close()
+ return rq_response
+ except Exception, e:
+ logging.error("touchURL: "+str(e))