import apt_inst
import shutil
import commands
-from daklib import database
+
from daklib import utils
+from daklib.dbconn import DBConn, get_binary_from_name_suite
from daklib.regexes import html_escaping, re_html_escaping, re_version, re_spacestrip, \
re_contrib, re_nonfree, re_localhost, re_newlinespace, \
re_package, re_doc_directory
################################################################################
Cnf = None
-projectB = None
-
Cnf = utils.get_conf()
-projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"]))
-database.init(Cnf, projectB)
printed_copyrights = {}
package_relations = {} #: Store relations of packages for later output
suite_where = " ='%s'" % suite
comma_count = 1
+ session = DBConn().session()
for l in depends_tree:
if (comma_count >= 2):
result += ", "
result += " | "
# doesn't do version lookup yet.
- q = projectB.query("SELECT DISTINCT(b.package), b.version, c.name, su.suite_name FROM binaries b, files fi, location l, component c, bin_associations ba, suite su WHERE b.package='%s' AND b.file = fi.id AND fi.location = l.id AND l.component = c.id AND ba.bin=b.id AND ba.suite = su.id AND su.suite_name %s ORDER BY b.version desc" % (d['name'], suite_where))
- ql = q.getresult()
- if ql:
- i = ql[0]
+ res = get_binary_from_name_suite(d['name'], suite_where)
+ if res.rowcount > 0:
+ i = res.fetchone()
adepends = d['name']
if d['version'] != '' :
# else: => byhand
def main ():
- global Cnf, projectB, db_files, waste, excluded
+ global Cnf, db_files, waste, excluded
# Cnf = utils.get_conf()
__all__.append('get_binaries_from_name')
+def get_binary_from_name_suite(package, suitename, session=None):
+ ### For dak examine-package
+ ### XXX: Doesn't use object API yet
+ if session is None:
+ session = DBConn().session()
+
+ sql = """SELECT DISTINCT(b.package), b.version, c.name, su.suite_name
+ FROM binaries b, files fi, location l, component c, bin_associations ba, suite su
+ WHERE b.package=:package
+ AND b.file = fi.id
+ AND fi.location = l.id
+ AND l.component = c.id
+ AND ba.bin=b.id
+ AND ba.suite = su.id
+ AND su.suite_name=:suitename
+ ORDER BY b.version DESC"""
+
+ return session.execute(sql, {'package': package, 'suitename': suitename})
+
+__all__.append('get_binary_from_name_suite')
+
def get_binary_components(package, suitename, arch, session=None):
# Check for packages that have moved from one component to another
query = """SELECT c.name FROM binaries b, bin_associations ba, suite s, location l, component c, architecture a, files f