]> git.decadent.org.uk Git - dak.git/blob - dak/split_done.py
Remove debug output
[dak.git] / dak / split_done.py
1 #!/usr/bin/env python
2
3 # Copyright (C) 2004, 2005, 2006  James Troup <james@nocrew.org>
4
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.
9
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.
14
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
18
19 ################################################################################
20
21 import glob, os, stat, time
22 import daklib.utils
23
24 ################################################################################
25
26 def main():
27     Cnf = daklib.utils.get_conf()
28     count = 0
29     os.chdir(Cnf["Dir::Queue::Done"])
30     files = glob.glob("%s/*" % (Cnf["Dir::Queue::Done"]))
31     for filename in files:
32         if os.path.isfile(filename):
33             mtime = time.gmtime(os.stat(filename)[stat.ST_MTIME])
34             dirname = time.strftime("%Y/%m/%d", mtime)
35             if not os.path.exists(dirname):
36                 print "Creating: %s" % (dirname)
37                 os.makedirs(dirname)
38             dest = dirname + '/' + os.path.basename(filename)
39             if os.path.exists(dest):
40                 daklib.utils.fubar("%s already exists." % (dest))
41             print "Move: %s -> %s" % (filename, dest) 
42             os.rename(filename, dest)
43             count = count + 1
44     print "Moved %d files." % (count)
45
46 ############################################################
47
48 if __name__ == '__main__':
49     main()