From e14ee09ee7d907ec8962615ae22ded80765852a3 Mon Sep 17 00:00:00 2001 From: Joerg Jaspert Date: Fri, 23 Jan 2009 00:00:08 +0100 Subject: [PATCH] Revert "Merge commit 'stew/popen2-must-die' into merge" This reverts commit d72561f42b76635948b88902ecd0966cecec9aaf. Signed-off-by: Joerg Jaspert --- dak/generate_index_diffs.py | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/dak/generate_index_diffs.py b/dak/generate_index_diffs.py index a58abdc5..286c1eba 100755 --- a/dak/generate_index_diffs.py +++ b/dak/generate_index_diffs.py @@ -32,7 +32,6 @@ import sys, os, tempfile import apt_pkg -import bz2, gzip, time from daklib import utils ################################################################################ @@ -83,9 +82,9 @@ def smartopen(file): if os.path.isfile(file): f = open(file, "r") elif os.path.isfile("%s.gz" % file): - f = decompressors[ 'zcat' ]( file ) + f = create_temp_file(os.popen("zcat %s.gz" % file, "r")) elif os.path.isfile("%s.bz2" % file): - f = decompressors[ 'bzcat' ]( file ) + f = create_temp_file(os.popen("bzcat %s.bz2" % file, "r")) else: f = None return f @@ -174,8 +173,17 @@ class Updates: for h in l: out.write(" %s %7d %s\n" % (hs[h][1][0], hs[h][1][1], h)) -decompressors = { 'zcat' : gzip.GzipFile, - 'bzip2' : bz2.BZ2File } +def create_temp_file(r): + f = tempfile.TemporaryFile() + while 1: + x = r.readline() + if not x: break + f.write(x) + r.close() + del x,r + f.flush() + f.seek(0) + return f def sizesha1(f): size = os.fstat(f.fileno())[6] @@ -298,7 +306,10 @@ def main(): if not Options.has_key("PatchName"): format = "%Y-%m-%d-%H%M.%S" - Options["PatchName"] = time.strftime( format ) + i,o = os.popen2("date +%s" % (format)) + i.close() + Options["PatchName"] = o.readline()[:-1] + o.close() AptCnf = apt_pkg.newConfiguration() apt_pkg.ReadConfigFileISC(AptCnf,utils.which_apt_conf_file()) -- 2.39.5