X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=daklib%2Fdbconn.py;h=988309361b3bef1fa2295c8184bedc8f60eddc31;hb=7c73ca0018de48b6366b0e26c37439f20ff4b2d5;hp=e5d4049c3f833951519d72deee4131aee3144bfb;hpb=3aa655a3111581af526137f5154a9c5b4c7d0dcf;p=dak.git diff --git a/daklib/dbconn.py b/daklib/dbconn.py index e5d4049c..98830936 100644 --- a/daklib/dbconn.py +++ b/daklib/dbconn.py @@ -34,13 +34,13 @@ ################################################################################ import apt_pkg +import daklib.daksubprocess import os from os.path import normpath import re import psycopg2 +import subprocess import traceback -import commands -import signal try: # python >= 2.6 @@ -52,7 +52,6 @@ except: from datetime import datetime, timedelta from errno import ENOENT from tempfile import mkstemp, mkdtemp -from subprocess import Popen, PIPE from tarfile import TarFile from inspect import getargspec @@ -110,11 +109,11 @@ class DebVersion(UserDefinedType): return None sa_major_version = sqlalchemy.__version__[0:3] -if sa_major_version in ["0.5", "0.6", "0.7", "0.8"]: +if sa_major_version in ["0.5", "0.6", "0.7", "0.8", "0.9"]: from sqlalchemy.databases import postgres postgres.ischema_names['debversion'] = DebVersion else: - raise Exception("dak only ported to SQLA versions 0.5 to 0.8. See daklib/dbconn.py") + raise Exception("dak only ported to SQLA versions 0.5 to 0.9. See daklib/dbconn.py") ################################################################################ @@ -498,11 +497,6 @@ __all__.append('BinContents') ################################################################################ -def subprocess_setup(): - # Python installs a SIGPIPE handler by default. This is usually not what - # non-Python subprocesses expect. - signal.signal(signal.SIGPIPE, signal.SIG_DFL) - class DBBinary(ORMObject): def __init__(self, package = None, source = None, version = None, \ maintainer = None, architecture = None, poolfile = None, \ @@ -539,8 +533,8 @@ class DBBinary(ORMObject): package does not contain any regular file. ''' fullpath = self.poolfile.fullpath - dpkg = Popen(['dpkg-deb', '--fsys-tarfile', fullpath], stdout = PIPE, - preexec_fn = subprocess_setup) + dpkg_cmd = ('dpkg-deb', '--fsys-tarfile', fullpath) + dpkg = daklib.daksubprocess.Popen(dpkg_cmd, stdout=subprocess.PIPE) tar = TarFile.open(fileobj = dpkg.stdout, mode = 'r|') for member in tar.getmembers(): if not member.isdir(): @@ -578,7 +572,6 @@ class DBBinary(ORMObject): @rtype: dict @return: fields of the control section as a dictionary. ''' - import apt_pkg stanza = self.read_control() return apt_pkg.TagSection(stanza) @@ -1199,7 +1192,7 @@ class Keyring(object): k = os.popen(self.gpg_invocation % keyring, "r") key = None - signingkey = False + need_fingerprint = False for line in k: field = line.split(":") @@ -1210,18 +1203,16 @@ class Keyring(object): if "@" in addr: self.keys[key]["email"] = addr self.keys[key]["name"] = name - self.keys[key]["fingerprints"] = [] - signingkey = True - elif key and field[0] == "sub" and len(field) >= 12: - signingkey = ("s" in field[11]) + need_fingerprint = True elif key and field[0] == "uid": (name, addr) = self.parse_address(field[9]) if "email" not in self.keys[key] and "@" in addr: self.keys[key]["email"] = addr self.keys[key]["name"] = name - elif signingkey and field[0] == "fpr": - self.keys[key]["fingerprints"].append(field[9]) + elif need_fingerprint and field[0] == "fpr": + self.keys[key]["fingerprints"] = [field[9]] self.fpr_lookup[field[9]] = key + need_fingerprint = False def import_users_from_ldap(self, session): import ldap @@ -2669,8 +2660,7 @@ class DBConn(object): mapper(Component, self.tbl_component, properties = dict(component_id = self.tbl_component.c.id, - component_name = self.tbl_component.c.name, - suites = relation(Suite, secondary=self.tbl_component_suite)), + component_name = self.tbl_component.c.name), extension = validator) mapper(DBConfig, self.tbl_config, @@ -2819,7 +2809,7 @@ class DBConn(object): acls = relation(ACL, secondary=self.tbl_suite_acl_map, collection_class=set), components = relation(Component, secondary=self.tbl_component_suite, order_by=self.tbl_component.c.ordering, - backref=backref('suite'))), + backref=backref('suites'))), extension = validator) mapper(Uid, self.tbl_uid, @@ -2942,5 +2932,3 @@ class DBConn(object): return session __all__.append('DBConn') - -