aboutsummaryrefslogtreecommitdiff
path: root/scripts/auto-build/create-latest-build-listing.py
blob: f7d97a88e46b754805f68a46943a98880a861e10 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/python

import string
import os,sys,errno
import re
import StringIO


for root, dirs, files in os.walk('/var/www/auto-build/'):
        dirs.sort()
        if 'latest' in dirs:
                dirs.remove('latest')
        for name in files:
                m = re.search('^Pd-[01]\.[0-9][0-9].*[^5]$', name)
                if m:
                        commonbuildname = re.sub('-20[01][0-9][01][0-9][0-9][0-9]', '', name)
                        commonbuildpath = os.path.join('/var/www/auto-build/latest', commonbuildname)
                        buildtarball = os.path.join(root, m.string)
                        #print "link: ", buildtarball, commonbuildpath
                        try:
                                os.symlink(buildtarball, commonbuildpath)
                        except OSError, e:
                                if e.errno == errno.EEXIST:
                                        #print "removing ", commonbuildpath
                                        os.remove(commonbuildpath)
                                        os.symlink(buildtarball, commonbuildpath)