From: Joerg Jaspert Date: Sat, 24 Jan 2009 01:45:14 +0000 (+0100) Subject: various X-Git-Url: https://git.decadent.org.uk/gitweb/?a=commitdiff_plain;h=bd78bbf9170cc8ee2dda06a7f060fd3370fea2bd;p=dak.git various use the new "style" for the temp_filename function, and if applicable also use os.fdopen. Signed-off-by: Joerg Jaspert --- diff --git a/dak/check_archive.py b/dak/check_archive.py index 896ab1f5..33dc8481 100755 --- a/dak/check_archive.py +++ b/dak/check_archive.py @@ -307,7 +307,7 @@ def validate_sources(suite, component): filename = "%s/dists/%s/%s/source/Sources.gz" % (Cnf["Dir::Root"], suite, component) print "Processing %s..." % (filename) # apt_pkg.ParseTagFile needs a real file handle and can't handle a GzipFile instance... - temp_filename = utils.temp_filename() + (fd, temp_filename) = utils.temp_filename() (result, output) = commands.getstatusoutput("gunzip -c %s > %s" % (filename, temp_filename)) if (result != 0): sys.stderr.write("Gunzip invocation failed!\n%s\n" % (output)) @@ -346,7 +346,7 @@ def validate_packages(suite, component, architecture): % (Cnf["Dir::Root"], suite, component, architecture) print "Processing %s..." % (filename) # apt_pkg.ParseTagFile needs a real file handle and can't handle a GzipFile instance... - temp_filename = utils.temp_filename() + (fd, temp_filename) = utils.temp_filename() (result, output) = commands.getstatusoutput("gunzip -c %s > %s" % (filename, temp_filename)) if (result != 0): sys.stderr.write("Gunzip invocation failed!\n%s\n" % (output)) diff --git a/dak/cruft_report.py b/dak/cruft_report.py index 5a2abd61..0f1125f8 100755 --- a/dak/cruft_report.py +++ b/dak/cruft_report.py @@ -377,7 +377,7 @@ def main (): for component in components: filename = "%s/dists/%s/%s/source/Sources.gz" % (Cnf["Dir::Root"], suite, component) # apt_pkg.ParseTagFile needs a real file handle and can't handle a GzipFile instance... - temp_filename = utils.temp_filename() + (fd, temp_filename) = utils.temp_filename() (result, output) = commands.getstatusoutput("gunzip -c %s > %s" % (filename, temp_filename)) if (result != 0): sys.stderr.write("Gunzip invocation failed!\n%s\n" % (output)) @@ -429,7 +429,7 @@ def main (): for architecture in architectures: filename = "%s/dists/%s/%s/binary-%s/Packages.gz" % (Cnf["Dir::Root"], suite, component, architecture) # apt_pkg.ParseTagFile needs a real file handle - temp_filename = utils.temp_filename() + (fd, temp_filename) = utils.temp_filename() (result, output) = commands.getstatusoutput("gunzip -c %s > %s" % (filename, temp_filename)) if (result != 0): sys.stderr.write("Gunzip invocation failed!\n%s\n" % (output)) diff --git a/dak/import_archive.py b/dak/import_archive.py index 4432ff1a..53635e2a 100755 --- a/dak/import_archive.py +++ b/dak/import_archive.py @@ -477,7 +477,7 @@ def process_packages (filename, suite, component, archive): ############################################################################### def do_sources(sources, suite, component, server): - temp_filename = utils.temp_filename() + (fd, temp_filename) = utils.temp_filename() (result, output) = commands.getstatusoutput("gunzip -c %s > %s" % (sources, temp_filename)) if (result != 0): utils.fubar("Gunzip invocation failed!\n%s" % (output), result) diff --git a/dak/process_new.py b/dak/process_new.py index e45dd8b2..8a43f127 100755 --- a/dak/process_new.py +++ b/dak/process_new.py @@ -309,8 +309,8 @@ def index_range (index): def edit_new (new): # Write the current data to a temporary file - temp_filename = utils.temp_filename() - temp_file = utils.open_file(temp_filename, 'w') + (fd, temp_filename) = utils.temp_filename() + temp_file = os.fdopen(fd, 'w') print_new (new, 0, temp_file) temp_file.close() # Spawn an editor on that file @@ -455,8 +455,8 @@ def edit_overrides (new): def edit_note(note): # Write the current data to a temporary file - temp_filename = utils.temp_filename() - temp_file = utils.open_file(temp_filename, 'w') + (fd, temp_filename) = utils.temp_filename() + temp_file = os.fdopen(temp_filename, 'w') temp_file.write(note) temp_file.close() editor = os.environ.get("EDITOR","vi") @@ -561,12 +561,12 @@ def add_overrides (new): def prod_maintainer (): # Here we prepare an editor and get them ready to prod... - temp_filename = utils.temp_filename() + (fd, temp_filename) = utils.temp_filename() editor = os.environ.get("EDITOR","vi") answer = 'E' while answer == 'E': os.system("%s %s" % (editor, temp_filename)) - f = utils.open_file(temp_filename) + f = os.fdopen(fd) prod_message = "".join(f.readlines()) f.close() print "Prod message:" diff --git a/dak/reject_proposed_updates.py b/dak/reject_proposed_updates.py index a61db174..4510ee0e 100755 --- a/dak/reject_proposed_updates.py +++ b/dak/reject_proposed_updates.py @@ -123,12 +123,12 @@ def reject (reject_message = ""): # If we weren't given a manual rejection message, spawn an editor # so the user can add one in... if not reject_message: - temp_filename = utils.temp_filename() + (fd, temp_filename) = utils.temp_filename() editor = os.environ.get("EDITOR","vi") answer = 'E' while answer == 'E': os.system("%s %s" % (editor, temp_filename)) - f = utils.open_file(temp_filename) + f = os.fdopen(fd) reject_message = "".join(f.readlines()) f.close() print "Reject message:" diff --git a/dak/rm.py b/dak/rm.py index 350cd1ea..c2c5fa48 100755 --- a/dak/rm.py +++ b/dak/rm.py @@ -113,7 +113,7 @@ def reverse_depends_check(removals, suites, arches=None): for component in components: filename = "%s/dists/%s/%s/binary-%s/Packages.gz" % (Cnf["Dir::Root"], suites[0], component, architecture) # apt_pkg.ParseTagFile needs a real file handle and can't handle a GzipFile instance... - temp_filename = utils.temp_filename() + (fd, temp_filename) = utils.temp_filename() (result, output) = commands.getstatusoutput("gunzip -c %s > %s" % (filename, temp_filename)) if (result != 0): utils.fubar("Gunzip invocation failed!\n%s\n" % (output), result) @@ -198,7 +198,7 @@ def reverse_depends_check(removals, suites, arches=None): for component in components: filename = "%s/dists/%s/%s/source/Sources.gz" % (Cnf["Dir::Root"], suites[0], component) # apt_pkg.ParseTagFile needs a real file handle and can't handle a GzipFile instance... - temp_filename = utils.temp_filename() + (fd, temp_filename) = utils.temp_filename() result, output = commands.getstatusoutput("gunzip -c %s > %s" % (filename, temp_filename)) if result != 0: sys.stderr.write("Gunzip invocation failed!\n%s\n" % (output)) @@ -425,7 +425,7 @@ def main (): # If we don't have a reason; spawn an editor so the user can add one # Write the rejection email out as the .reason file if not Options["Reason"] and not Options["No-Action"]: - temp_filename = utils.temp_filename() + (fd, temp_filename) = utils.temp_filename() editor = os.environ.get("EDITOR","vi") result = os.system("%s %s" % (editor, temp_filename)) if result != 0: diff --git a/daklib/queue.py b/daklib/queue.py index 1fcfeaaf..09831f4d 100755 --- a/daklib/queue.py +++ b/daklib/queue.py @@ -499,19 +499,18 @@ distribution.""" if changes["architecture"].has_key("source") and \ dsc.has_key("bts changelog"): - temp_filename = utils.temp_filename(Cnf["Dir::Queue::BTSVersionTrack"], - dotprefix=1, perms=0644) - version_history = utils.open_file(temp_filename, 'w') + (fd, temp_filename) = utils.temp_filename(Cnf["Dir::Queue::BTSVersionTrack"], prefix=".") + version_history = os.fdopen(temp_filename, 'w') version_history.write(dsc["bts changelog"]) version_history.close() filename = "%s/%s" % (Cnf["Dir::Queue::BTSVersionTrack"], changes_file[:-8]+".versions") os.rename(temp_filename, filename) + os.chmod(filename, "0644") # Write out the binary -> source mapping. - temp_filename = utils.temp_filename(Cnf["Dir::Queue::BTSVersionTrack"], - dotprefix=1, perms=0644) - debinfo = utils.open_file(temp_filename, 'w') + (fd, temp_filename) = utils.temp_filename(Cnf["Dir::Queue::BTSVersionTrack"], prefix=".") + debinfo = os.fdopen(temp_filename, 'w') for file_entry in file_keys: f = files[file_entry] if f["type"] == "deb": @@ -523,6 +522,7 @@ distribution.""" filename = "%s/%s" % (Cnf["Dir::Queue::BTSVersionTrack"], changes_file[:-8]+".debinfo") os.rename(temp_filename, filename) + os.chmod(filename, "0644") self.queue_build("accepted", Cnf["Dir::Queue::Accepted"]) @@ -670,7 +670,7 @@ distribution.""" # If we weren't given a manual rejection message, spawn an # editor so the user can add one in... if manual and not reject_message: - temp_filename = utils.temp_filename() + (fd, temp_filename) = utils.temp_filename() editor = os.environ.get("EDITOR","vi") answer = 'E' while answer == 'E':