]> git.decadent.org.uk Git - dak.git/blobdiff - dak/split_done.py
lotsa files
[dak.git] / dak / split_done.py
index c595f68e2e7af07e8844b81906ce28234d3cc466..8b5b57fe2ef2db0cf2b1a882ad7aa30615eb3422 100755 (executable)
@@ -1,7 +1,8 @@
 #!/usr/bin/env python
 
-# Copyright (C) 2004, 2005  James Troup <james@nocrew.org>
-# $Id: nina,v 1.2 2005-11-15 09:50:32 ajt Exp $
+""" Split queue/done into date based subdirectories """
+# Copyright (C) 2004, 2005, 2006  James Troup <james@nocrew.org>
+# Copyright (C) 2008  Joerg Jaspert <joerg@debian.org>
 
 # 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
 ################################################################################
 
 import glob, os, stat, time
-import utils
+from daklib import utils
 
 ################################################################################
 
 def main():
     Cnf = utils.get_conf()
     count = 0
+    move_date = int(time.time())-(30*84600)
     os.chdir(Cnf["Dir::Queue::Done"])
     files = glob.glob("%s/*" % (Cnf["Dir::Queue::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)
@@ -39,7 +44,7 @@ def main():
             dest = dirname + '/' + os.path.basename(filename)
             if os.path.exists(dest):
                 utils.fubar("%s already exists." % (dest))
-            print "Move: %s -> %s" % (filename, dest) 
+            print "Move: %s -> %s" % (filename, dest)
             os.rename(filename, dest)
             count = count + 1
     print "Moved %d files." % (count)