[poky] [PATCH 1/2] distro_check.py: Add a new function to reduce the repeat code

Mei Lei lei.mei at intel.com
Thu May 12 23:59:45 PDT 2011


From: Mei Lei <lei.mei at intel.com>

A lot of repeat code in distrodata.bbclass when creating log file, we can define a function called create_log_file to do it.

Signed-off-by: Mei Lei <lei.mei at intel.com>
---
 meta/lib/oe/distro_check.py |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/meta/lib/oe/distro_check.py b/meta/lib/oe/distro_check.py
index c85d4fb..134e92a 100644
--- a/meta/lib/oe/distro_check.py
+++ b/meta/lib/oe/distro_check.py
@@ -341,6 +341,21 @@ def compare_in_distro_packages_list(distro_check_dir, d):
     bb.note("Matching: %s" % matching_distros)
     return matching_distros
 
+def create_log_file(d, logname):
+    #logpath = bb.data.getVar('LOG_DIR', e.data, 1)
+    logpath = bb.data.getVar('LOG_DIR', d, 1)
+    bb.utils.mkdirhier(logpath)
+    logfile = logpath +"/" + logname.split(".")[0] + ".%s.csv" % bb.data.getVar('DATETIME', d, 1)
+    if not os.path.exists(logfile):
+            slogfile = os.path.join(logpath, logname)
+            if os.path.exists(slogfile):
+                    os.remove(slogfile)
+            os.system("touch %s" % logfile)
+            os.symlink(logfile, slogfile)
+            bb.data.setVar('LOG_FILE', logfile, d)
+    return logfile
+
+
 def save_distro_check_result(result, datetime, d):
     pn = bb.data.getVar('PN', d, True)
     logdir = bb.data.getVar('LOG_DIR', d, True)
-- 
1.6.3.3




More information about the poky mailing list