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

Contents of /src/packages/daily.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (show annotations) (download) (as text)
Sun Oct 17 16:53:21 2004 UTC (10 years ago) by marduk
Branch: MAIN
Branch point for: pre_2-0
Changes since 1.3: +1 -1 lines
File MIME type: text/x-python
Various fixes & enhancements

1 #!/usr/bin/python -OO
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 # 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 stable_extra = ('ebuild.arch REGEXP "^%s| %s" '
77 ' AND ebuild.prevarch NOT REGEXP"^%s| %s"'
78 % (arch,arch,arch,arch))
79 testing_extra = ('ebuild.arch REGEXP "^~%s| ~%s" '
80 ' AND ebuild.prevarch NOT REGEXP "^~%s| ~%s"'
81 % (arch,arch,arch,arch))
82 if branch == 'stable':
83 extra = ' AND (%s) ' % stable_extra
84 elif branch == 'testing':
85 extra = ' AND (%s) ' % testing_extra
86 else:
87 extra = ' AND ((%s) OR (%s)) ' % (stable_extra, testing_extra)
88
89 query = ('SELECT ebuild.category,'
90 'ebuild.name,'
91 'version,'
92 'when_found,'
93 'description,'
94 'changelog,'
95 'arch,'
96 'homepage,'
97 'license '
98 'FROM ebuild,package '
99 'WHERE SUBSTRING(when_found FROM 1 FOR 8) = "%s%02d%02d" '
100 'AND ebuild.name = package.name '
101 'AND ebuild.category = package.category %s'
102 'ORDER BY when_found desc' %
103 (year, month, day,extra))
104
105 c.execute(query)
106 results = c.fetchall()
107
108 s = genarchbar('%sdaily/%d/%02d/%02d/' % (config.FEHOME,year,month,day),arch,branch) + '<br>\n'
109 for result in results:
110 ebuild = gentoo.query_to_dict(result)
111 s = s + gentoo.ebuild_to_html(ebuild) + '<br>\n'
112 print s
113
114 # cache to file, if not todays date
115 if today[:3] != (year,month,day):
116 filename = os.path.join(config.LOCALHOME,'daily','cache',
117 '%d%02d%02d-%s-%s.html' % (year,month,day,arch,branch))
118 open(filename,'w').write(s)

  ViewVC Help
Powered by ViewVC 1.1.20