[glom] Use try around get_value_at().
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glom] Use try around get_value_at().
- Date: Fri, 15 Apr 2011 07:42:57 +0000 (UTC)
commit 117fef4a2bdb21dfad72777c3897e6e886f14d49
Author: Murray Cumming <murrayc murrayc com>
Date: Fri Apr 15 09:35:47 2011 +0200
Use try around get_value_at().
.../repository_analyzer_begin_scan.py | 44 ++++++++++++++++++--
1 files changed, 40 insertions(+), 4 deletions(-)
---
diff --git a/examples/example_scripts/repository_analyzer_begin_scan.py b/examples/example_scripts/repository_analyzer_begin_scan.py
index c8952d6..5fd07d9 100644
--- a/examples/example_scripts/repository_analyzer_begin_scan.py
+++ b/examples/example_scripts/repository_analyzer_begin_scan.py
@@ -1369,7 +1369,16 @@ def get_next_automatic_id_number(table_name, field_name):
max_id = 0
if(datamodel and (datamodel.get_n_rows() > 0) and (datamodel.get_n_columns() > 0)):
- max_id_value = datamodel.get_value_at(0, 0)
+ max_id_value = None
+ try:
+ max_id_value = datamodel.get_value_at(0, 0)
+ except:
+ # Current versions of PyGObject throw an exception because
+ # libgda returns a G_TYPE_INVALID GValue for NULL SQL Values.
+ # See https://bugzilla.gnome.org/show_bug.cgi?id=647272
+ # And this can throw an exception from libgda anyway.
+ max_id_value = None
+
if(max_id_value == None): #This seems to be the result when there are no records. I guess it is a NULL value in the result.
max_id = 0
else:
@@ -1394,7 +1403,16 @@ def get_record_exists_already(table_name, field_name, sql_field_value):
datamodel = execute_sql_select_query(sql_query)
if(datamodel and (datamodel.get_n_rows() > 0) and (datamodel.get_n_columns() > 0)):
- count = datamodel.get_value_at(0, 0).get()
+ count = None
+ try:
+ count = datamodel.get_value_at(0, 0)
+ except:
+ # Current versions of PyGObject throw an exception because
+ # libgda returns a G_TYPE_INVALID GValue for NULL SQL Values.
+ # See https://bugzilla.gnome.org/show_bug.cgi?id=647272
+ # And this can throw an exception from libgda anyway.
+ count = None
+
if(count == None): #This seems to be the result when there are no records. I guess it is a NULL value in the result.
return False
else:
@@ -1407,7 +1425,16 @@ def get_license_id_of_last_package_scan(package_name):
datamodel = execute_sql_select_query(sql_query)
if(datamodel and (datamodel.get_n_rows() > 0) and (datamodel.get_n_columns() > 0)):
- result = datamodel.get_value_at(0, 0).get()
+ result = None
+ try:
+ result = datamodel.get_value_at(0, 0)
+ except:
+ # Current versions of PyGObject throw an exception because
+ # libgda returns a G_TYPE_INVALID GValue for NULL SQL Values.
+ # See https://bugzilla.gnome.org/show_bug.cgi?id=647272
+ # And this can throw an exception from libgda anyway.
+ result = None
+
if(result == None): #This seems to be the result when there are no records. I guess it is a NULL value in the result.
return None
else:
@@ -1420,7 +1447,16 @@ def get_version_of_last_package_scan(package_name):
datamodel = execute_sql_select_query(sql_query)
if(datamodel and (datamodel.get_n_rows() > 0) and (datamodel.get_n_columns() > 0)):
- result = datamodel.get_value_at(0, 0).get()
+ result = None
+ try:
+ result = datamodel.get_value_at(0, 0)
+ except:
+ # Current versions of PyGObject throw an exception because
+ # libgda returns a G_TYPE_INVALID GValue for NULL SQL Values.
+ # See https://bugzilla.gnome.org/show_bug.cgi?id=647272
+ # And this can throw an exception from libgda anyway.
+ result = None
+
if(result == None): #This seems to be the result when there are no records. I guess it is a NULL value in the result.
return None
else:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]