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

Contents of /src/packages/daily.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.6.2.2 - (hide annotations) (download) (as text)
Tue Jan 16 02:57:06 2007 UTC (7 years, 8 months ago) by marduk
Branch: v1_3
Changes since 1.6.2.1: +0 -1 lines
File MIME type: text/x-python
Removed unused import

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

  ViewVC Help
Powered by ViewVC 1.1.20