[Piuparts-commits] [piuparts] 05/09: dwke: write all content to a .kpr at once

Holger Levsen holger at moszumanska.debian.org
Sat Mar 1 21:08:40 UTC 2014


This is an automated email from the git hooks/post-receive script.

holger pushed a commit to branch develop
in repository piuparts.

commit ffbab4894b4966aac6051b12dae90d96c4f7ca2b
Author: Andreas Beckmann <anbe at debian.org>
Date:   Sat Feb 22 15:54:09 2014 +0100

    dwke: write all content to a .kpr at once
    
    do not keep the file open and partially written while parsing the logfile
    
    Signed-off-by: Andreas Beckmann <anbe at debian.org>
---
 custom-scripts/scripts/pre_install_database-server |  1 +
 master-bin/detect_well_known_errors.py             | 11 +++++++----
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/custom-scripts/scripts/pre_install_database-server b/custom-scripts/scripts/pre_install_database-server
index 25f4594..153b26f 100755
--- a/custom-scripts/scripts/pre_install_database-server
+++ b/custom-scripts/scripts/pre_install_database-server
@@ -67,6 +67,7 @@ case ${PIUPARTS_OBJECTS%%=*} in
 	glance-common)				SQLITE3=yes ;;
 	glance-registry)			SQLITE3=yes ;;
 	glpi)					MYSQL=yes ;;
+	gnuhealth-server)			POSTGRESQL=yes ;;
 	grr)					MYSQL=yes ;;
 	heat-api)				SQLITE3=yes ;;
 	heat-api-cfn)				SQLITE3=yes ;;
diff --git a/master-bin/detect_well_known_errors.py b/master-bin/detect_well_known_errors.py
index 4cdc5ae..533d859 100755
--- a/master-bin/detect_well_known_errors.py
+++ b/master-bin/detect_well_known_errors.py
@@ -57,6 +57,10 @@ def setup_logging(log_level):
     logger.addHandler(handler)
 
 
+def write_file(filename, contents):
+    with file(filename, "w") as f:
+        f.write(contents)
+
 def mtime(path):
     return os.path.getmtime(path)
 
@@ -98,13 +102,12 @@ def make_kprs(logdict, kprdict, problem_list):
 
             where = get_where(logpath)
 
-            kf = open(get_kpr_path(logpath), 'a')
-
+            kprs = ""
             for problem in problem_list:
                 if problem.has_problem(logbody, where):
-                    kf.write("%s/%s.log %s\n" % (where, pkg_spec, problem.name))
+                    kprs += "%s/%s.log %s\n" % (where, pkg_spec, problem.name)
 
-            kf.close()
+            write_file(get_kpr_path(logpath), kprs)
         except IOError:
             logging.error("File error processing %s" % logpath)
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/piuparts/piuparts.git



More information about the Piuparts-commits mailing list