From 11fe18479eeb7bb97062a2922da13ba816597007 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Thu, 7 Feb 2008 19:36:17 -0600 Subject: pactest: make more resiliant to missing files Add a bunch of guards around function calls like open() and stat() to ensure we are not going to get ourselves a python error. This made implementing and testing the new upgrade045 pactest much easier, as its whole purpose was to create a dead symlink and debug a segfault of pacman (which caused no DB entries to be written) to support the previously checked in fix for FS#9235 (commit 0c2206f542ce6df2606586d43f190cd5a423fb13). Both of these cases are now non-fatal in pactest. Signed-off-by: Dan McGee --- pactest/pmdb.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'pactest/pmdb.py') diff --git a/pactest/pmdb.py b/pactest/pmdb.py index cc852c2a..af392000 100755 --- a/pactest/pmdb.py +++ b/pactest/pmdb.py @@ -119,7 +119,10 @@ def db_read(self, name): # desc filename = os.path.join(path, "desc") - fd = file(filename, "r") + if not os.path.isfile(filename): + print "invalid db entry found (desc missing) for pkg", pkgname + return None + fd = open(filename, "r") while 1: line = fd.readline() if not line: @@ -158,7 +161,10 @@ def db_read(self, name): # files filename = os.path.join(path, "files") - fd = file(filename, "r") + if not os.path.isfile(filename): + print "invalid db entry found (files missing) for pkg", pkgname + return None + fd = open(filename, "r") while 1: line = fd.readline() if not line: @@ -177,6 +183,9 @@ def db_read(self, name): # depends filename = os.path.join(path, "depends") + if not os.path.isfile(filename): + print "invalid db entry found (depends missing) for pkg", pkgname + return None fd = file(filename, "r") while 1: line = fd.readline() -- cgit v1.2.3-54-g00ecf