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

Contents of /src/packages/query_ebuild.py

Parent Directory Parent Directory | Revision Log Revision Log


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

1 marduk 1.1 #!/usr/bin/python
2    
3     import cgi
4     import os
5     import sys
6     import config
7     import gentoo,ebuilddb
8    
9 marduk 1.2 DEFAULT_EBUILD = "404"
10 marduk 1.1 PKG_DIR = config.EBUILD_FILES
11    
12     if len(sys.argv):
13 marduk 1.2 ebuild = sys.argv[1]
14 marduk 1.1 else:
15 marduk 1.2 ebuild = DEFAULT_EBUILD
16    
17 marduk 1.1
18     html_file = os.path.join(PKG_DIR,"%s.html" % ebuild.replace('..',''))
19 marduk 1.2 #if os.path.exists(html_file):
20     if 0:
21     send_file = html_file
22 marduk 1.1 else:
23 marduk 1.2 # let's try the database
24     # connect
25 marduk 1.3 pieces = gentoo.portage.pkgsplit(ebuild)
26     name = pieces[0]
27     if pieces[2] == 'r0':
28     version = pieces[1]
29     else:
30     version = '-'.join(pieces[1:])
31 marduk 1.2 db = ebuilddb.db_connect()
32     # query
33     query = ('SELECT ebuild.category,ebuild.name,version,when_found,'
34     'description,changelog,arch,homepage,license '
35     'FROM ebuild,package WHERE ebuild.name="%s" AND '
36     'version="%s" AND '
37     'ebuild.name=package.name AND ebuild.category=package.category '
38     'ORDER by when_found DESC LIMIT 1' % (name,version))
39     #print query
40     c = db.cursor()
41     c.execute(query)
42     result = c.fetchone()
43     if result:
44     #print result
45     eb = gentoo.query_to_dict(result)
46     sys.stdout.write(gentoo.ebuild_to_html(eb,show_bugs=1))
47     sys.exit(0)
48     # else 404
49     else:
50     send_file = os.path.join(PKG_DIR,"%s.html" % DEFAULT_EBUILD)
51 marduk 1.1
52     sys.stdout.write(open(send_file,"r").read())
53     sys.stdout.flush()

  ViewVC Help
Powered by ViewVC 1.1.20