]> git.decadent.org.uk Git - dak.git/blobdiff - daklib/dbconn.py
Reset signal handler to default action in child processes
[dak.git] / daklib / dbconn.py
index 22d20a577707e5efed603727ef4356313a24aeb4..7d5a7481723b360f3525d3727f8fbf96d4c3dfb7 100644 (file)
 ################################################################################
 
 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
@@ -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():
@@ -2667,8 +2661,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,
@@ -2817,7 +2810,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,
@@ -2940,5 +2933,3 @@ class DBConn(object):
         return session
 
 __all__.append('DBConn')
-
-