X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=daklib%2Fcontents.py;h=08b09cb3aac0958209f54b66620c0f376799e71c;hb=519c1dbf89c13557afc15a429164616ac563d379;hp=e5abcac61a916d13d15b9ed7c339ffc539d3a504;hpb=804dd3773d8322fb28c165e24b46d3d025f044c2;p=dak.git diff --git a/daklib/contents.py b/daklib/contents.py index e5abcac6..08b09cb3 100644 --- a/daklib/contents.py +++ b/daklib/contents.py @@ -31,11 +31,10 @@ from daklib.filewriter import BinaryContentsFileWriter, SourceContentsFileWriter from multiprocessing import Pool from shutil import rmtree -from subprocess import Popen, PIPE, check_call from tempfile import mkdtemp +import daklib.daksubprocess import os.path -import signal class BinaryContentsWriter(object): ''' @@ -135,14 +134,9 @@ select bc.file, string_agg(o.section || '/' || b.package, ',' order by b.package ''' Returns the header for the Contents files as a string. ''' - header_file = None - try: - filename = os.path.join(Config()['Dir::Templates'], 'contents') - header_file = open(filename) + filename = os.path.join(Config()['Dir::Templates'], 'contents') + with open(filename) as header_file: return header_file.read() - finally: - if header_file: - header_file.close() def write_file(self): ''' @@ -383,12 +377,6 @@ def binary_scan_helper(binary_id): scanner = BinaryContentsScanner(binary_id) scanner.scan() - -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 UnpackedSource(object): ''' UnpackedSource extracts a source package into a temporary location and @@ -403,7 +391,7 @@ class UnpackedSource(object): self.root_directory = os.path.join(temp_directory, 'root') command = ('dpkg-source', '--no-copy', '--no-check', '-q', '-x', dscfilename, self.root_directory) - check_call(command, preexec_fn = subprocess_setup) + daklib.daksubprocess.check_call(command) def get_root_directory(self): ''' @@ -506,4 +494,3 @@ def source_scan_helper(source_id): scanner.scan() except Exception as e: print e -