diff options
author | René 'Necoro' Neumann <necoro@necoro.net> | 2009-08-14 19:42:01 +0200 |
---|---|---|
committer | René 'Necoro' Neumann <necoro@necoro.net> | 2009-08-14 19:42:01 +0200 |
commit | 801316be64177d889ab21fc28c07dd4d77cb8184 (patch) | |
tree | 3966d67a043cb372bb51a9acdf533ef919122d44 /portato/db/eix_sql.py | |
parent | 636eb3064e8ff8957bbf9fd172d7a0c6827e973c (diff) | |
download | portato-801316be64177d889ab21fc28c07dd4d77cb8184.tar.gz portato-801316be64177d889ab21fc28c07dd4d77cb8184.tar.bz2 portato-801316be64177d889ab21fc28c07dd4d77cb8184.zip |
Fix the EixSQLDatabase and EixReader
Diffstat (limited to '')
-rw-r--r-- | portato/db/eix_sql.py | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/portato/db/eix_sql.py b/portato/db/eix_sql.py index 0e4f569..ac31019 100644 --- a/portato/db/eix_sql.py +++ b/portato/db/eix_sql.py @@ -21,29 +21,31 @@ import os from .sql import SQLDatabase from ..eix import EixReader -from ..helper import debug +from ..helper import debug, warning from ..backend import system class EixSQLDatabase (SQLDatabase): - CACHE_FILE = "/var/eix/cache" + CACHE_FILE = "/var/cache/eix" def __init__ (self, session): - SQLDatabase.__init__(self, session) - if "cache" not in session: + self.cache = session.get("cache", self.CACHE_FILE) + if not os.path.exists(self.cache): + warning(_("Cache file '%s' does not exist. Using default instead."), self.cache) self.cache = self.CACHE_FILE - session["cache"] = self.cache - else: - self.cache = session["cache"] debug("Using '%s' as eix cache file.", self.cache) + + session["cache"] = self.cache + + SQLDatabase.__init__(self, session) def updated (self): mtime = os.stat(self.cache).st_mtime old = self.session.get("mtime", 0) - self.session["mtime"] = mtime + self.session["mtime"] = str(mtime) return old < mtime |