~ubuntu-branches/ubuntu/maverick/ubufox/maverick-proposed

« back to all changes in this revision

Viewing changes to pfs/db/plugindb.py

  • Committer: Bazaar Package Importer
  • Author(s): Alexander Sack
  • Date: 2008-09-12 12:02:19 UTC
  • mto: (1.1.23)
  • mto: This revision was merged to the branch mainline in revision 16.
  • Revision ID: james.westby@ubuntu.com-20080912120219-0z5uyj4ifjaii3wa
Tags: upstream-0.6~b1
ImportĀ upstreamĀ versionĀ 0.6~b1

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/usr/bin/python
2
2
#
3
 
# Copyright (C) 2007  Canonical Ltd.
 
3
# Copyright (C) 2007-2008 Canonical Ltd.
4
4
#
5
5
# This program is free software; you can redistribute it and/or modify
6
6
# it under the terms of the GNU General Public License as published by
23
23
import sqlite3
24
24
import sys
25
25
 
26
 
if len(sys.argv) < 2:
27
 
        print "CMD <release>"
 
26
if len(sys.argv) < 3:
 
27
        print "CMD <release> <archs>"
28
28
        sys.exit(2)
29
29
 
30
 
archs="amd64 i386 powerpc sparc"
31
30
releases=sys.argv[1]
 
31
archs=sys.argv[2]
32
32
 
33
33
print "RELEASES", releases
34
34
 
 
35
mimetype_pkgweights = { "application/x-shockwave-flash" : { "flashplugin-nonfree" : 9 } }       
 
36
 
35
37
class AptPluginDbUpdater:
36
38
 
37
39
        def __init__ (self, apt_con, configroot):
41
43
        def redo_arch_rel_data (self, architecture, rel, entries):
42
44
                self._apt_con.execute('delete from package where architecture=? AND distribution=?', (architecture, rel))
43
45
                for e in entries:
44
 
                        print "insert into package (pkgname, pkgdesc, pkglongdesc, name, mimetype, architecture, appid, distribution, section) values (?,?,?,?,?,?,\"{"+e.app_id.strip()+"}\",?,?)", \
45
 
                        e.pkgname, e.pkgdesc, e.pkglongdesc, e.name, e.mimetype, architecture, e.distribution, e.section
 
46
                        pkgweight = 0
 
47
                        if e.mimetype in mimetype_pkgweights and e.pkgname in mimetype_pkgweights [ e.mimetype ]:
 
48
                                pkgweight = mimetype_pkgweights [ e.mimetype ] [ e.pkgname ]
 
49
 
 
50
                        print "insert into package (pkgname, pkgdesc, pkglongdesc, name, mimetype, architecture, appid, distribution, section, weight) values (?,?,?,?,?,?,\"{"+e.app_id.strip()+"}\",?,?,?)", \
 
51
                        e.pkgname, e.pkgdesc, e.pkglongdesc, e.name, e.mimetype, architecture, e.distribution, e.section, pkgweight
46
52
 
47
53
                        try:
48
 
                                self._apt_con.execute("insert into package (pkgname, pkgdesc, pkglongdesc, name, mimetype, architecture, appid, distribution, section) values (?,?,?,?,?,?,\"{"+e.app_id.strip()+"}\",?,?)", \
49
 
                                        (e.pkgname, e.pkgdesc, e.pkglongdesc, e.name, e.mimetype, architecture, e.distribution, e.section))
 
54
                                self._apt_con.execute("insert into package (pkgname, pkgdesc, pkglongdesc, name, mimetype, architecture, appid, distribution, section, weight) values (?,?,?,?,?,?,\"{"+e.app_id.strip()+"}\",?,?,?)", \
 
55
                                        (e.pkgname, e.pkgdesc, e.pkglongdesc, e.name, e.mimetype, architecture, e.distribution, e.section, pkgweight))
50
56
                                print " ... inserted ... "
51
57
                        except Exception, e:
52
58
                                print "ERROR", e.args
71
77
                                "  appid string NOT NULL," + \
72
78
                                "  distribution string NOT NULL," + \
73
79
                                "  section string NOT NULL," + \
 
80
                                "  weight integer NOT NULL," + \
74
81
                                "  UNIQUE (pkgname, architecture, appid, mimetype, distribution)" + \
75
82
                                ");")
76
83
 
95
102
 
96
103
 
97
104
 
98
 
dbfile="/tmp/sqlite3.db"
 
105
dbfile="/tmp/apt-plugins.sqlite"
99
106
apt_con = sqlite3.connect(dbfile)
100
107
updater = AptPluginDbUpdater(apt_con, "./")
101
108
updater.run()