X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=dak%2Fsplit_done.py;h=3d07287240f18fb4e5272274dffc53fa8fe7d760;hb=7ba4ac6dfc9ec4473e99b814a35add978cc00264;hp=6b6d28fbf7370bfd09130fb53912a7ed1604d0f7;hpb=06ce98c8111a8b09e5603dbbd34324a216412d69;p=dak.git diff --git a/dak/split_done.py b/dak/split_done.py index 6b6d28fb..3d072872 100755 --- a/dak/split_done.py +++ b/dak/split_done.py @@ -1,6 +1,8 @@ #!/usr/bin/env python +""" Split queue/done into date based subdirectories """ # Copyright (C) 2004, 2005, 2006 James Troup +# Copyright (C) 2008 Joerg Jaspert # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -19,26 +21,31 @@ ################################################################################ import glob, os, stat, time -import dak.lib.utils +from daklib import utils ################################################################################ def main(): - Cnf = dak.lib.utils.get_conf() + Cnf = utils.get_conf() count = 0 - os.chdir(Cnf["Dir::Queue::Done"]) - files = glob.glob("%s/*" % (Cnf["Dir::Queue::Done"])) + move_date = int(time.time()) + os.chdir(Cnf["Dir::Done"]) + files = glob.glob("%s/*" % (Cnf["Dir::Done"])) for filename in files: if os.path.isfile(filename): - mtime = time.gmtime(os.stat(filename)[stat.ST_MTIME]) + filemtime = os.stat(filename)[stat.ST_MTIME] + if filemtime > move_date: + continue + mtime = time.gmtime(filemtime) dirname = time.strftime("%Y/%m/%d", mtime) if not os.path.exists(dirname): print "Creating: %s" % (dirname) os.makedirs(dirname) dest = dirname + '/' + os.path.basename(filename) if os.path.exists(dest): - dak.lib.utils.fubar("%s already exists." % (dest)) - print "Move: %s -> %s" % (filename, dest) + utils.warn("%s already exists." % (dest)) + continue + print "Move: %s -> %s" % (filename, dest) os.rename(filename, dest) count = count + 1 print "Moved %d files." % (count)