From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1Qf0Fw-00074r-FE for garchives@archives.gentoo.org; Fri, 08 Jul 2011 01:53:24 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id E49B621C090; Fri, 8 Jul 2011 01:52:31 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id B4F5E21C060 for ; Fri, 8 Jul 2011 01:52:31 +0000 (UTC) Received: from flycatcher.gentoo.org (flycatcher.gentoo.org [81.93.255.6]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 2E9E62AC0AC for ; Fri, 8 Jul 2011 01:52:31 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by flycatcher.gentoo.org (Postfix) with ESMTP id DBB5D2004B for ; Fri, 8 Jul 2011 01:52:29 +0000 (UTC) From: "Robin H. Johnson" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Robin H. Johnson" Message-ID: <5a95efa1da01fecb1516a94263cacc3744e7dab4.robbat2@gentoo> Subject: [gentoo-commits] packages:master commit in: dbgenerator/ X-VCS-Repository: packages X-VCS-Files: dbgenerator/database.py X-VCS-Directories: dbgenerator/ X-VCS-Committer: robbat2 X-VCS-Committer-Name: Robin H. Johnson X-VCS-Revision: 5a95efa1da01fecb1516a94263cacc3744e7dab4 Date: Fri, 8 Jul 2011 01:52:29 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: X-Archives-Hash: 836a349525340d687b0b5d153e5b8b9b commit: 5a95efa1da01fecb1516a94263cacc3744e7dab4 Author: Robin H. Johnson gentoo org> AuthorDate: Fri Jul 8 01:42:29 2011 +0000 Commit: Robin H. Johnson gentoo org> CommitDate: Fri Jul 8 01:42:46 2011 +0000 URL: http://sources.gentoo.org/gitweb/?p=3Dpackages.git;a=3Dcommit= ;h=3D5a95efa1 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 =3D False + detected_version =3D None try: sql =3D self.sql['SELECT_schema_is_current'] self.cursor.execute(sql) entries =3D self.cursor.fetchall() - if entries is None: - return False - current_schema =3D entries[0][0] - return current_schema =3D=3D self.schema_version + if entries is not None: + current_schema =3D entries[0][0] + result =3D (current_schema =3D=3D self.schema_version) + detected_version =3D 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) =20 def _preparesql(self): """Prepare all SQL statements for the relevant DB backend""" @@ -614,7 +617,8 @@ class SQLitePackageDB(SQLPackageDatabase): self.cursor =3D self.db.cursor() self._preparesql() =20 - if not self.schema_is_current(): + schema_check =3D self.schema_is_current() + if not schema_check[0]: print 'Schema is outdated, flushing!' self.initdb =3D True if self.initdb: