From bf961022b5e191e897e68f69784425d2c8166968 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20=27Necoro=27=20Neumann?= Date: Thu, 20 May 2010 13:02:29 +0200 Subject: Handle missing eix-cache file more gracefully --- portato/db/eix_sql.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/portato/db/eix_sql.py b/portato/db/eix_sql.py index 758f42c..58b0acc 100644 --- a/portato/db/eix_sql.py +++ b/portato/db/eix_sql.py @@ -20,10 +20,14 @@ except ImportError: import os from .sql import SQLDatabase +from .exceptions import DatabaseInitError from ..eix import EixReader from ..helper import debug, warning from ..backend import system +class EixInitError (DatabaseInitError): + pass + class EixSQLDatabase (SQLDatabase): CACHE_FILE = "/var/cache/eix" @@ -35,6 +39,9 @@ class EixSQLDatabase (SQLDatabase): warning(_("Cache file '%s' does not exist. Using default instead."), self.cache) self.cache = self.CACHE_FILE + if not os.path.exists(self.cache): + raise EixInitError(_("Cache file '%s' does not exist.") % self.cache) + debug("Using '%s' as eix cache file.", self.cache) session["cache"] = self.cache -- cgit v1.2.3