| 1 | #!/usr/bin/python -O |
1 | #!/usr/bin/python -O |
| 2 | |
2 | |
| 3 | import sys |
|
|
| 4 | import config |
3 | import config |
| 5 | import ebuilddb |
4 | import ebuilddb |
| 6 | import gentoo |
5 | import gentoo |
| 7 | import os |
6 | import os |
| 8 | import time |
7 | import time |
| … | |
… | |
| 50 | branch = '' |
49 | branch = '' |
| 51 | |
50 | |
| 52 | if branch not in ('','stable','testing'): |
51 | if branch not in ('','stable','testing'): |
| 53 | branch = '' |
52 | branch = '' |
| 54 | |
53 | |
| 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() |
54 | db = ebuilddb.db_connect() |
| 72 | c = db.cursor() |
55 | c = db.cursor() |
| 73 | |
56 | |
| 74 | extra = '' |
57 | extra = '' |
| 75 | if arch: |
58 | if arch: |
| … | |
… | |
| 92 | 'changelog,' |
75 | 'changelog,' |
| 93 | 'arch,' |
76 | 'arch,' |
| 94 | 'homepage,' |
77 | 'homepage,' |
| 95 | 'license, is_masked ' |
78 | 'license, is_masked ' |
| 96 | 'FROM ebuild,package ' |
79 | 'FROM ebuild,package ' |
| 97 | 'WHERE SUBSTRING(when_found FROM 1 FOR 8) = "%s%02d%02d" ' |
80 | 'WHERE DATE(when_found) = "%s-%02d-%02d" ' |
| 98 | 'AND ebuild.name = package.name ' |
81 | 'AND ebuild.name = package.name ' |
| 99 | 'AND ebuild.category = package.category %s' |
82 | 'AND ebuild.category = package.category %s' |
| 100 | 'ORDER BY when_found desc' % |
83 | 'ORDER BY when_found desc' % |
| 101 | (year, month, day,extra)) |
84 | (year, month, day,extra)) |
| 102 | |
85 | |
| … | |
… | |
| 106 | s = genarchbar('%sdaily/%d/%02d/%02d/' % (config.FEHOME,year,month,day),arch,branch) + '<br>\n' |
89 | s = genarchbar('%sdaily/%d/%02d/%02d/' % (config.FEHOME,year,month,day),arch,branch) + '<br>\n' |
| 107 | for result in results: |
90 | for result in results: |
| 108 | ebuild = gentoo.query_to_dict(result) |
91 | ebuild = gentoo.query_to_dict(result) |
| 109 | s = s + gentoo.ebuild_to_html(ebuild) + '<br>\n' |
92 | s = s + gentoo.ebuild_to_html(ebuild) + '<br>\n' |
| 110 | print s |
93 | 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 | open(filename,'w').write(s) |
|
|