Sophie

Sophie

distrib > Fedora > 13 > i386 > by-pkgid > e8a890a0806bad090507daa262acb01f > files > 4

virtaal-0.6.1-8.fc13.src.rpm

--- src/trunk/virtaal/virtaal/plugins/tm/models/tinytm.py	2010/09/14 14:49:58	15768
+++ src/trunk/virtaal/virtaal/plugins/tm/models/tinytm.py	2010/09/14 14:59:13	15769
@@ -18,6 +18,8 @@
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, see <http://www.gnu.org/licenses/>.
 
+import logging
+
 from virtaal.common import pan_app
 
 from basetmmodel import BaseTMModel
@@ -69,10 +71,13 @@
         # Uncomment this if you don't trust the results
         #results = self._db.execute("""SELECT * FROM tinytm_get_fuzzy_matches('en', 'de', 'THE EUROPEAN ECONOMIC COMMUNITY', '', '')""")
         cursor = self._db_con.cursor()
-        cursor.execute(
-            """SELECT * FROM tinytm_get_fuzzy_matches(%s, %s, %s, '', '')""",
-            (self.source_lang, self.target_lang, query_str.encode('utf-8'))
-        )
+        try:
+            cursor.execute(
+                """SELECT * FROM tinytm_get_fuzzy_matches(%s, %s, %s, '', '')""",
+                (self.source_lang, self.target_lang, query_str.encode('utf-8'))
+            )
+        except psycopg.Error, e:
+            logging.error("[%s] %s" % (e.pgcode, e.pgerror))
         for result in cursor.fetchall():
             quality, source, target = result[:3]
             if not isinstance(target, unicode):