summaryrefslogtreecommitdiff
path: root/pactest/util.py
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2008-02-07 19:36:17 -0600
committerDan McGee <dan@archlinux.org>2008-02-07 19:36:17 -0600
commit11fe18479eeb7bb97062a2922da13ba816597007 (patch)
treedcc9807d8c3d78bfbbec9153cf4955e4580cbdde /pactest/util.py
parent0c2206f542ce6df2606586d43f190cd5a423fb13 (diff)
downloadpacman-11fe18479eeb7bb97062a2922da13ba816597007.tar.xz
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 <dan@archlinux.org>
Diffstat (limited to 'pactest/util.py')
-rwxr-xr-xpactest/util.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/pactest/util.py b/pactest/util.py
index b24bfdcf..2a6ff4e7 100755
--- a/pactest/util.py
+++ b/pactest/util.py
@@ -196,6 +196,9 @@ def mkcfgfile(filename, root, option, db):
def getmd5sum(filename):
"""
"""
+ if not os.path.isfile(filename):
+ print "file %s does not exist!" % filename
+ return ""
fd = open(filename, "rb")
checksum = md5.new()
while 1:
@@ -223,6 +226,9 @@ def mkmd5sum(data):
def getmtime(filename):
"""
"""
+ if not os.path.exists(filename):
+ print "path %s does not exist!" % filename
+ return 0, 0, 0
st = os.stat(filename)
return st[stat.ST_ATIME], st[stat.ST_MTIME], st[stat.ST_CTIME]