public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Robin H. Johnson" <robbat2@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] packages:master commit in: dbgenerator/
Date: Fri,  8 Jul 2011 01:52:29 +0000 (UTC)	[thread overview]
Message-ID: <5a95efa1da01fecb1516a94263cacc3744e7dab4.robbat2@gentoo> (raw)

commit:     5a95efa1da01fecb1516a94263cacc3744e7dab4
Author:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
AuthorDate: Fri Jul  8 01:42:29 2011 +0000
Commit:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Fri Jul  8 01:42:46 2011 +0000
URL:        http://sources.gentoo.org/gitweb/?p=packages.git;a=commit;h=5a95efa1

Improve version detection code.

---
 dbgenerator/database.py |   20 ++++++++++++--------
 1 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/dbgenerator/database.py b/dbgenerator/database.py
index 94ae0e2..6698d90 100644
--- a/dbgenerator/database.py
+++ b/dbgenerator/database.py
@@ -549,20 +549,23 @@ class SQLPackageDatabase(object):
     def schema_is_current(self):
         """Check if the database schema version matches the
             version expected by the sourcecode"""
+        result = False
+        detected_version = None
         try:
             sql = self.sql['SELECT_schema_is_current']
             self.cursor.execute(sql)
             entries = self.cursor.fetchall()
-            if entries is None:
-                return False
-            current_schema = entries[0][0]
-            return current_schema == self.schema_version
+            if entries is not None:
+                current_schema = entries[0][0]
+                result = (current_schema == self.schema_version)
+                detected_version = current_schema)
         except IndexError:
-            return False
+            pass
         except self.db.OperationalError:
-            return False
+            pass
         except self.db.ProgrammingError:
-            return False
+            pass
+        return (result, detected_version)
 
     def _preparesql(self):
         """Prepare all SQL statements for the relevant DB backend"""
@@ -614,7 +617,8 @@ class SQLitePackageDB(SQLPackageDatabase):
         self.cursor = self.db.cursor()
         self._preparesql()
 
-        if not self.schema_is_current():
+        schema_check = self.schema_is_current()
+        if not schema_check[0]:
             print 'Schema is outdated, flushing!'
             self.initdb = True
         if self.initdb:



             reply	other threads:[~2011-07-08  1:53 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-08  1:52 Robin H. Johnson [this message]
  -- strict thread matches above, loose matches on Subject: below --
2011-07-08  2:30 [gentoo-commits] packages:master commit in: dbgenerator/ Robin H. Johnson
2013-04-14 21:01 Christian Ruppert
2014-01-25 15:09 Christian Ruppert
2014-01-25 15:42 Christian Ruppert
2014-03-17 15:39 Alec Warner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5a95efa1da01fecb1516a94263cacc3744e7dab4.robbat2@gentoo \
    --to=robbat2@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox