kopia lustrzana https://github.com/ctjacobs/pyqso
More error handling.
rodzic
5eca6d4e68
commit
ebc6d767aa
|
@ -45,7 +45,8 @@ class Log(Gtk.ListStore):
|
|||
return
|
||||
|
||||
def populate(self):
|
||||
""" Remove everything in the Gtk.ListStore that is rendered already (via the TreeView), and start afresh. """
|
||||
""" Remove everything in the Gtk.ListStore that is rendered already (via the TreeView), and start afresh.
|
||||
Return True if successful, and False otherwise. """
|
||||
|
||||
logging.debug("Populating '%s'..." % self.name)
|
||||
self.add_missing_db_columns()
|
||||
|
@ -61,9 +62,10 @@ class Log(Gtk.ListStore):
|
|||
liststore_entry.append(r[field_name])
|
||||
self.append(liststore_entry)
|
||||
logging.debug("Finished populating '%s'." % self.name)
|
||||
return True # Success
|
||||
else:
|
||||
logging.error("Could not populate '%s' because of a database error." % self.name)
|
||||
return
|
||||
return False # Failure
|
||||
|
||||
def add_missing_db_columns(self):
|
||||
""" Check whether each field name in AVAILABLE_FIELD_NAMES_ORDERED is in the database table. If not, add it
|
||||
|
@ -90,7 +92,8 @@ class Log(Gtk.ListStore):
|
|||
with self.connection:
|
||||
c.execute("ALTER TABLE %s ADD COLUMN %s TEXT DEFAULT \"\"" % (self.name, field_name.lower()))
|
||||
except sqlite.Error as e:
|
||||
logging.exception("Could not add the missing database column '%s'." % field_name)
|
||||
logging.exception(e)
|
||||
logging.error("Could not add the missing database column '%s'." % field_name)
|
||||
pass
|
||||
logging.debug("Finished adding any missing database columns.")
|
||||
return
|
||||
|
|
|
@ -64,8 +64,9 @@ class Logbook(Gtk.Notebook):
|
|||
if(name[0][0:7] == "sqlite_"):
|
||||
continue # Skip SQLite internal tables
|
||||
l = Log(self.connection, name[0])
|
||||
l.populate()
|
||||
self.logs.append(l)
|
||||
success = l.populate()
|
||||
if(success):
|
||||
self.logs.append(l)
|
||||
except (sqlite.Error, IndexError) as e:
|
||||
logging.exception(e)
|
||||
logging.exception("Oops! Something went wrong when trying to retrieve the logs from the logbook.")
|
||||
|
|
Ładowanie…
Reference in New Issue