/[gentoo]/src/packages/daily.py
Gentoo

Contents of /src/packages/daily.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.6 - (hide annotations) (download) (as text)
Mon Oct 17 05:45:08 2005 UTC (8 years, 11 months ago) by marduk
Branch: MAIN
CVS Tags: v1_3_1, HEAD
Branch point for: v1_3
Changes since 1.5: +4 -6 lines
File MIME type: text/x-python
Backported arch/prevarch db format from pre_2-0

1 marduk 1.5 #!/usr/bin/python -O
2 marduk 1.1
3     import sys
4     import config
5     import ebuilddb
6     import gentoo
7     import os
8     import time
9     from genarchbar import genarchbar
10    
11     print 'Status: 200 Ok'
12     print 'Content-type: text/html'
13     print
14    
15     def error():
16     print ('<div class="centerpage">\n'
17     '<table class="ebuild">\n'
18     '<tr><td class="fields">Error in request</td></tr><br>\n'
19     '<tr><td class="item"><img src="%s/?category=generic" align="right" alt="">'
20     '<p>An error was encountered processing your request. Request a '
21 marduk 1.4 'different page or check the <a href="%s">packages.gentoo.org main page</a>.'
22 marduk 1.1 '</p></td></tr>'
23     '</table>'
24     '</div>') % (config.ICONS,config.FEHOME)
25    
26     try:
27     uri = os.environ['REQUEST_URI']
28     datestring = uri.split('/daily/')[1]
29     except KeyError:
30     datestring =""
31    
32     params = datestring.split('/')
33     today = time.gmtime(time.time())
34     try:
35     year,month,day = [int(i) for i in params[:3]]
36     except ValueError:
37     year,month,day = today[:3]
38    
39     try:
40     arch = params[4]
41     except IndexError:
42     arch = ''
43    
44     if arch not in [''] + config.ARCHLIST:
45     arch = ''
46    
47     try:
48     branch = params[5]
49     except IndexError:
50     branch = ''
51    
52     if branch not in ('','stable','testing'):
53     branch = ''
54    
55     # see if we're cached, if so write the cache and exit
56     if today[:3] == (year,month,day):
57     # today is always cached ;-)
58     archnav = os.path.join(config.LOCALHOME,arch,branch,'archnav.html')
59     filename = os.path.join(config.LOCALHOME,arch,branch,'main.shtml')
60     sys.stdout.write(open(archnav,'r').read())
61     sys.stdout.write('<br>\n')
62     sys.stdout.write(open(filename,'r').read())
63     sys.exit(0)
64     else:
65     filename = os.path.join(config.LOCALHOME,'daily','cache',
66     '%d%02d%02d-%s-%s.html' % (year,month,day,arch,branch))
67     if os.path.exists(filename):
68     sys.stdout.write(open(filename,'r').read())
69     sys.exit(0)
70    
71     db = ebuilddb.db_connect()
72     c = db.cursor()
73    
74     extra = ''
75     if arch:
76 marduk 1.6 stable_extra = ('FIND_IN_SET("%s", ebuild.arch) > 0 AND '
77     'FIND_IN_SET("%s", ebuild.prevarch) = 0 ' % (arch, arch))
78     testing_extra = ('FIND_IN_SET("~%s", ebuild.arch) > 0 AND '
79     'FIND_IN_SET("%s", ebuild.prevarch) = 0 ' % (arch, arch))
80 marduk 1.2 if branch == 'stable':
81     extra = ' AND (%s) ' % stable_extra
82     elif branch == 'testing':
83     extra = ' AND (%s) ' % testing_extra
84     else:
85     extra = ' AND ((%s) OR (%s)) ' % (stable_extra, testing_extra)
86    
87 marduk 1.1 query = ('SELECT ebuild.category,'
88     'ebuild.name,'
89     'version,'
90     'when_found,'
91     'description,'
92     'changelog,'
93     'arch,'
94     'homepage,'
95 marduk 1.5 'license, is_masked '
96 marduk 1.1 'FROM ebuild,package '
97 marduk 1.3 'WHERE SUBSTRING(when_found FROM 1 FOR 8) = "%s%02d%02d" '
98 marduk 1.1 'AND ebuild.name = package.name '
99     'AND ebuild.category = package.category %s'
100     'ORDER BY when_found desc' %
101     (year, month, day,extra))
102    
103     c.execute(query)
104     results = c.fetchall()
105    
106     s = genarchbar('%sdaily/%d/%02d/%02d/' % (config.FEHOME,year,month,day),arch,branch) + '<br>\n'
107     for result in results:
108     ebuild = gentoo.query_to_dict(result)
109     s = s + gentoo.ebuild_to_html(ebuild) + '<br>\n'
110     print s
111    
112     # cache to file, if not todays date
113     if today[:3] != (year,month,day):
114     filename = os.path.join(config.LOCALHOME,'daily','cache',
115     '%d%02d%02d-%s-%s.html' % (year,month,day,arch,branch))
116 marduk 1.2 open(filename,'w').write(s)

  ViewVC Help
Powered by ViewVC 1.1.20