3 # Copyright (C) 2004, 2005, 2006 James Troup <james@nocrew.org>
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 ################################################################################
21 import glob, os, stat, time
22 from daklib import utils
24 ################################################################################
27 Cnf = utils.get_conf()
29 move_date = int(time.time())-(30*84600)
30 os.chdir(Cnf["Dir::Queue::Done"])
31 files = glob.glob("%s/*" % (Cnf["Dir::Queue::Done"]))
32 for filename in files:
33 if os.path.isfile(filename):
34 filemtime = os.stat(filename)[stat.ST_MTIME]
35 if filemtime > move_date:
37 mtime = time.gmtime(filemtime)
38 dirname = time.strftime("%Y/%m/%d", mtime)
39 if not os.path.exists(dirname):
40 print "Creating: %s" % (dirname)
42 dest = dirname + '/' + os.path.basename(filename)
43 if os.path.exists(dest):
44 utils.fubar("%s already exists." % (dest))
45 print "Move: %s -> %s" % (filename, dest)
46 os.rename(filename, dest)
48 print "Moved %d files." % (count)
50 ############################################################
52 if __name__ == '__main__':