X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;ds=sidebyside;f=daklib%2Fdbconn.py;h=5c987bdc56881ab01dbc7884aa9f31c26431017e;hb=154f11d09071db32cfbf6451b8f059702856421d;hp=c6612b72519235bd06df3fd6eeb663b93b8a8308;hpb=554c9c0777c3444720c8d6064608cff5f89f62c0;p=dak.git diff --git a/daklib/dbconn.py b/daklib/dbconn.py index c6612b72..5c987bdc 100755 --- a/daklib/dbconn.py +++ b/daklib/dbconn.py @@ -39,6 +39,7 @@ import re import psycopg2 import traceback import commands +import signal try: # python >= 2.6 @@ -487,6 +488,11 @@ __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, \ @@ -525,7 +531,8 @@ class DBBinary(ORMObject): package does not contain any regular file. ''' fullpath = self.poolfile.fullpath - dpkg = Popen(['dpkg-deb', '--fsys-tarfile', fullpath], stdout = PIPE) + dpkg = Popen(['dpkg-deb', '--fsys-tarfile', fullpath], stdout = PIPE, + preexec_fn = subprocess_setup) tar = TarFile.open(fileobj = dpkg.stdout, mode = 'r|') for member in tar.getmembers(): if not member.isdir(): @@ -2872,6 +2879,12 @@ class Suite(ORMObject): return session.query(DBSource).filter_by(source = source). \ with_parent(self) + def get_overridesuite(self): + if self.overridesuite is None: + return self + else: + return object_session(self).query(Suite).filter_by(suite_name=self.overridesuite).one() + __all__.append('Suite') @session_wrapper @@ -3147,7 +3160,9 @@ __all__.append('VersionCheck') def get_version_checks(suite_name, check = None, session = None): suite = get_suite(suite_name, session) if not suite: - return None + # Make sure that what we return is iterable so that list comprehensions + # involving this don't cause a traceback + return [] q = session.query(VersionCheck).filter_by(suite=suite) if check: q = q.filter_by(check=check)