public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Zac Medico" <zmedico@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/cache/
Date: Mon,  7 Feb 2011 00:14:40 +0000 (UTC)	[thread overview]
Message-ID: <33b8ae45109ebbbd62a560690ccbaf2c009772b1.zmedico@gentoo> (raw)

commit:     33b8ae45109ebbbd62a560690ccbaf2c009772b1
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Mon Feb  7 00:13:22 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon Feb  7 00:13:22 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=33b8ae45

cache.sqlite: handle sqlite ImportError

This will fix bug #353836.

---
 pym/portage/cache/sqlite.py |   23 +++++++++++++++--------
 1 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/pym/portage/cache/sqlite.py b/pym/portage/cache/sqlite.py
index 2e13be3..d15b6ec 100644
--- a/pym/portage/cache/sqlite.py
+++ b/pym/portage/cache/sqlite.py
@@ -1,4 +1,4 @@
-# Copyright 1999-2010 Gentoo Foundation
+# Copyright 1999-2011 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 import sys
@@ -8,11 +8,6 @@ from portage import os
 from portage import _unicode_decode
 from portage.util import writemsg
 from portage.localization import _
-try:
-	import sqlite3 as db_module # sqlite3 is optional with >=python-2.5
-except ImportError:
-	from pysqlite2 import dbapi2 as db_module
-DBError = db_module.Error
 
 if sys.hexversion >= 0x3000000:
 	basestring = str
@@ -25,12 +20,11 @@ class database(fs_template.FsBased):
 	# to calculate the number of pages requested, according to the following
 	# equation: cache_bytes = page_bytes * page_count
 	cache_bytes = 1024 * 1024 * 10
-	_db_module = db_module
-	_db_error = DBError
 	_db_table = None
 
 	def __init__(self, *args, **config):
 		super(database, self).__init__(*args, **config)
+		self._import_sqlite()
 		self._allowed_keys = ["_mtime_", "_eclasses_"]
 		self._allowed_keys.extend(self._known_keys)
 		self._allowed_keys.sort()
@@ -49,6 +43,19 @@ class database(fs_template.FsBased):
 		self._db_init_connection(config)
 		self._db_init_structures()
 
+	def _import_sqlite(self):
+		# sqlite3 is optional with >=python-2.5
+		try:
+			import sqlite3 as db_module
+		except ImportError:
+			try:
+				from pysqlite2 import dbapi2 as db_module
+			except ImportError as e:
+				raise cache_errors.InitializationError(self.__class__, e)
+
+		self._db_module = db_module
+		self._db_error = db_module.Error
+
 	def _db_escape_string(self, s):
 		"""meta escaping, returns quoted string for use in sql statements"""
 		if not isinstance(s, basestring):



             reply	other threads:[~2011-02-07  0:14 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-07  0:14 Zac Medico [this message]
  -- strict thread matches above, loose matches on Subject: below --
2011-02-08  6:37 [gentoo-commits] proj/portage:master commit in: pym/portage/cache/ Zac Medico
2011-05-12 19:02 Zac Medico
2011-05-12 19:02 Zac Medico
2011-05-12 19:05 Zac Medico
2011-09-07 15:56 Zac Medico
2011-10-14 15:30 Zac Medico
2011-10-18  5:26 Zac Medico
2011-10-29 23:10 Zac Medico
2012-05-23 19:00 Zac Medico
2012-05-24 19:06 Zac Medico
2012-06-10  8:25 Zac Medico
2012-06-10  8:28 Zac Medico
2012-06-10  8:35 Zac Medico
2012-09-18 19:02 Zac Medico
2012-09-25  1:42 Zac Medico
2012-09-25  1:54 Zac Medico
2012-09-25  3:44 Zac Medico
2012-10-02 20:30 Zac Medico
2012-11-21  4:38 Zac Medico
2013-01-18 15:32 Zac Medico
2013-01-18 16:37 Zac Medico
2013-01-18 17:12 Zac Medico
2013-07-26  7:57 Zac Medico
2013-07-26  8:23 Arfrever Frehtes Taifersar Arahesis
2014-11-14 17:33 Zac Medico
2015-12-29 16:42 Zac Medico
2015-12-29 16:42 Zac Medico
2015-12-29 16:42 Zac Medico
2016-07-13 11:32 Zac Medico
2016-07-24 23:22 Zac Medico
2016-09-19 16:57 Zac Medico

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=33b8ae45109ebbbd62a560690ccbaf2c009772b1.zmedico@gentoo \
    --to=zmedico@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