X-Git-Url: https://git.tld-linux.org/?p=tld-ftp-admin.git;a=blobdiff_plain;f=wwwbin%2Fclean-dups-old.py;fp=wwwbin%2Fclean-dups-old.py;h=0000000000000000000000000000000000000000;hp=e0ba2a0dc6bc40eceb92a1414e0203775d2a99ec;hb=f7b22268ab563fa906be0653d037f1805e220e5c;hpb=b7b854ca43601a08077b7c4c4fa1313a198d936a diff --git a/wwwbin/clean-dups-old.py b/wwwbin/clean-dups-old.py deleted file mode 100755 index e0ba2a0..0000000 --- a/wwwbin/clean-dups-old.py +++ /dev/null @@ -1,69 +0,0 @@ -#!/usr/bin/python -# arekm, 2008 -# remove - -import os -import re -import time -import rpm -import sys - -re_info = re.compile(r'.*\.info$') -re_nvr = re.compile('^(.*)-([^-]*)-([^-]*)\.info$') -dir = '/home/pld/admins/th/ftp/test/SRPMS/.metadata' - -def compare(f1, f2): - m1 = re_nvr.match(f1) - n1 = m1.group(1) - v1 = m1.group(2) - r1 = m1.group(3) - - m2 = re_nvr.match(f2) - n2 = m2.group(1) - v2 = m2.group(2) - r2 = m2.group(3) - - l1 = rpm.labelCompare((n1, v1, r1), (n2, v2, r2)) - l2 = rpm.labelCompare((n2, v2, r2), (n1, v1, r1)) - - if l1 > 0 and l2 > 0: - return 0 - - return -l1 - - -def find_old(files): - return sorted(files, compare) - -files = {} -dupes = {} - -for file in os.listdir(dir): - if not re_info.match(file): - continue - - m = re_nvr.match(file) - if not m: - print "problem with: %s" % file - sys.exit(1) - - if len(sys.argv) == 0: - p = os.path.join(dir, file) - mtime = os.stat(p).st_mtime - if mtime > time.time() - 3*86400: - continue - - name = m.group(1) - - if files.has_key(name): - if dupes.has_key(name): - dupes[name].append(file) - else: - dupes[name] = [ files[name] ] - dupes[name].append(file) - else: - files[name] = file - -for i in dupes.iterkeys(): - for old in find_old(dupes[i])[1:]: - os.system("/home/pld/admins/th/pld-ftp-admin/scripts/remove.py test %s" % old)