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

Contents of /src/packages/daily.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.6.2.1 - (show annotations) (download) (as text)
Tue Jan 16 02:53:37 2007 UTC (8 years ago) by marduk
Branch: v1_3
Changes since 1.6: +1 -23 lines
File MIME type: text/x-python
Date comparisions are SQL-standard.  Removed unused caching logic.

1 #!/usr/bin/python -O
2
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 'different page or check the <a href="%s">packages.gentoo.org main page</a>.'
22 '</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 db = ebuilddb.db_connect()
56 c = db.cursor()
57
58 extra = ''
59 if arch:
60 stable_extra = ('FIND_IN_SET("%s", ebuild.arch) > 0 AND '
61 'FIND_IN_SET("%s", ebuild.prevarch) = 0 ' % (arch, arch))
62 testing_extra = ('FIND_IN_SET("~%s", ebuild.arch) > 0 AND '
63 'FIND_IN_SET("%s", ebuild.prevarch) = 0 ' % (arch, arch))
64 if branch == 'stable':
65 extra = ' AND (%s) ' % stable_extra
66 elif branch == 'testing':
67 extra = ' AND (%s) ' % testing_extra
68 else:
69 extra = ' AND ((%s) OR (%s)) ' % (stable_extra, testing_extra)
70
71 query = ('SELECT ebuild.category,'
72 'ebuild.name,'
73 'version,'
74 'when_found,'
75 'description,'
76 'changelog,'
77 'arch,'
78 'homepage,'
79 'license, is_masked '
80 'FROM ebuild,package '
81 'WHERE DATE(when_found) = "%s-%02d-%02d" '
82 'AND ebuild.name = package.name '
83 'AND ebuild.category = package.category %s'
84 'ORDER BY when_found desc' %
85 (year, month, day,extra))
86
87 c.execute(query)
88 results = c.fetchall()
89
90 s = genarchbar('%sdaily/%d/%02d/%02d/' % (config.FEHOME,year,month,day),arch,branch) + '<br>\n'
91 for result in results:
92 ebuild = gentoo.query_to_dict(result)
93 s = s + gentoo.ebuild_to_html(ebuild) + '<br>\n'
94 print s

  ViewVC Help
Powered by ViewVC 1.1.20