[Piuparts-commits] [SCM] piuparts git repository branch, develop, updated. 0.46-19-g5ed50ea
Andreas Beckmann
debian at abeckmann.de
Sat Sep 15 14:29:52 UTC 2012
The following commit has been merged in the develop branch:
commit 5a0e8430b6506f60a84c52a8d7d45c0e62fbe86b
Author: Andreas Beckmann <debian at abeckmann.de>
Date: Sat Sep 15 09:24:40 2012 +0200
p-r: rewrite find_files_with_suffix()
take into account that logfiles may be deleted concurrently
Signed-off-by: Andreas Beckmann <debian at abeckmann.de>
diff --git a/debian/changelog b/debian/changelog
index 630d476..aa8024c 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -5,6 +5,7 @@ piuparts (0.47) UNRELEASED; urgency=low
* piuparts-master.py:
* piuparts-slave.py:
* piuparts-report.py:
+ - Rewrite find_files_with_suffix(), handle disappearing files.
* New custom script pre_remove_50_find_missing_copyright: check for missing
/usr/share/doc/$package/copyright files. (Closes: #683685)
* Rename custom script post_install_find_bad_permissions to
diff --git a/piuparts-report.py b/piuparts-report.py
index effeb07..1ef20d3 100644
--- a/piuparts-report.py
+++ b/piuparts-report.py
@@ -459,16 +459,18 @@ def maintainer_subdir(maintainer):
return maintainer.lower()[:1]
-def find_files_with_suffix(dir,suffix):
- files=[name for name in os.listdir(dir) if name.endswith(suffix)]
- # sort by age
- content = {}
- for vfile in files:
- content[vfile] = os.path.getmtime(os.path.join(dir,vfile))
- # Sort keys, based on time stamps
- files = content.keys()
- files.sort(lambda x,y: cmp(content[x],content[y]))
- return files
+def find_files_with_suffix(vdir, suffix):
+ pairs = [] # (mtime, name)
+ for name in os.listdir(vdir):
+ if name.endswith(suffix):
+ try:
+ if os.path.isfile(os.path.join(vdir, name)):
+ mtime = os.path.getmtime(os.path.join(vdir, name))
+ pairs.append((mtime, name))
+ except OSError:
+ pass
+ # sort by mtime
+ return [x[1] for x in sorted(pairs)]
def update_file(source, target):
if os.path.exists(target):
--
piuparts git repository
More information about the Piuparts-commits
mailing list