[oe-commits] org.oe.dev classes/seppuku.bbclass: Merge with the one used at openmoko's autobuilder

freyther commit openembedded-commits at lists.openembedded.org
Sat May 19 19:46:39 UTC 2007


classes/seppuku.bbclass: Merge with the one used at openmoko's autobuilder
    -Properly quote the PR, PV and such.
    -Log communication with the bugzilla to a log file for inspection.

Author: freyther at openembedded.org
Branch: org.openembedded.dev
Revision: 7e901e0c9463e84a57c40aecf70affbcb9bef3a1
ViewMTN: http://monotone.openembedded.org/revision.psp?id=7e901e0c9463e84a57c40aecf70affbcb9bef3a1
Files:
1
classes/seppuku.bbclass
Diffs:

#
# mt diff -rda0e3b3c320146c0d4bd3536d2cece74b0fa7bbc -r7e901e0c9463e84a57c40aecf70affbcb9bef3a1
#
# 
# 
# patch "classes/seppuku.bbclass"
#  from [71eb24e672dd81ac82c65fe115526fcd7bb17beb]
#    to [fb98aeef695eae7972516d4280eb563c9b1efaca]
# 
============================================================
--- classes/seppuku.bbclass	71eb24e672dd81ac82c65fe115526fcd7bb17beb
+++ classes/seppuku.bbclass	fb98aeef695eae7972516d4280eb563c9b1efaca
@@ -110,7 +110,7 @@ def seppuku_find_bug_report_old():
 
 
 
-def seppuku_find_bug_report(opener, query, product, component, bugname):
+def seppuku_find_bug_report(debug_file, opener, query, product, component, bugname):
     """
     Find a bug report with the sane name and return the bug id
     and the status.
@@ -124,6 +124,11 @@ def seppuku_find_bug_report(opener, quer
     http://bugs.openembedded.org/buglist.cgi?short_desc_type=substring&short_desc=manual+test+bug&product=Openembedded&emailreporter2=1&emailtype2=substring&email2=freyther%40yahoo.com
     but it does not support ctype=csv...
     """
+    import urllib
+    product   = urllib.quote(product)
+    component = urllib.quote(component)
+    bugname   = urllib.quote(bugname)
+
     result = opener.open("%(query)s?product=%(product)s&component=%(component)s&short_desc_type=substring&short_desc=%(bugname)s" % vars())
     if result.code != 200:
         raise "Can not query the bugzilla at all"
@@ -131,8 +136,13 @@ def seppuku_find_bug_report(opener, quer
     scanner = seppuku_find_bug_report_old()
     scanner.feed(txt)
     if len(scanner.result()) == 0:
+        print >> debug_file, "Scanner failed to scan the html site"
+        print >> debug_file, "%(query)s?product=%(product)s&component=%(component)s&short_desc_type=substring&short_desc=%(bugname)s" % vars()
+        print >> debug_file, txt
         return (False,None)
     else: # silently pick the first result
+        print >> debug_file, "Result of bug search is "
+        print >> debug_file, txt
         (number,status) = scanner.result()[0]
         return (not status in ["CLOS", "RESO", "VERI"],number)
 
@@ -206,12 +216,17 @@ def seppuku_file_bug(poster, file, produ
         print e
         return False
 
-    if result.code != 200:
-        return False
+    # scan the result for a bug number
+    # it will look like 
+    # '<a href="show_bug.cgi?id=308">Back To BUG# 308</a>'
+    import re
+    res = re.findall(("\>Back To BUG\# (?P<int>\d+)\</a\>"), result.read() )
+    if result.code != 200 or len(res) != 1:
+        return None 
     else:
-        return True
+        return res[0] 
 
-def seppuku_create_attachment(poster, attach_query, product, component, bug_number, text, file):
+def seppuku_create_attachment(debug, poster, attach_query, product, component, bug_number, text, file):
     """
 
     Create a new attachment for the failed report
@@ -235,7 +250,7 @@ def seppuku_create_attachment(poster, at
         print e
         return False
 
-    print result.read()
+    print >> debug, result.read()
     if result.code != 200:
         return False
     else:
@@ -284,12 +299,15 @@ python seppuku_eventhandler() {
         passw   = bb.data.getVar("SEPPUKU_PASS",  data, True)
         product = bb.data.getVar("SEPPUKU_PRODUCT", data, True)
         component = bb.data.getVar("SEPPUKU_COMPONENT", data, True)
+        # evil hack to figure out what is going on
+        debug_file = open(os.path.join(bb.data.getVar("TMPDIR", data, True),"..","seppuku-log"),"a")
 
         if not seppuku_login(opener, login, user, passw):
             bb.note("Login to bugzilla failed")
+            print >> debug_file, "Login to bugzilla failed"
             return NotHandled
         else:
-            print "Logged into the box"
+            print >> debug_file, "Logged into the box"
 
         file = None
         if name == "TaskFailed":
@@ -300,34 +318,44 @@ python seppuku_eventhandler() {
             log_file = glob.glob("%s/log.%s.*" % (bb.data.getVar('T', event.data, True), event.task))
             text     = "The package failed to build at %s" % bb.data.getVar('DATETIME', data, True) 
             if len(log_file) != 0:
-                file     = open(log_file[0], 'r')
+                print >> debug_file, "Adding log file %s" % log_file[0]
+                file = open(log_file[0], 'r')
+            else:
+                print >> debug_file, "No log file found for the glob"
         elif name == "NoProvider":
             bugname = "noprovider for %s runtime: %s" % (event.getItem, event.getisRuntime)
             text    = "Please fix it"
         else:
+            print >> debug_file, "Unknown name '%s'" % name
             assert False
 
-        (bug_open, bug_number) = seppuku_find_bug_report(opener, query, product, component, bugname)
+        (bug_open, bug_number) = seppuku_find_bug_report(debug_file, opener, query, product, component, bugname)
+        print >> debug_file, "Bug is open: %s and bug number: %s" % (bug_open, bug_number)
 
-        bb.note("Bug is open: %s and bug number: %s" % (bug_open, bug_number))
-
         # The bug is present and still open, no need to attach an error log
         if bug_number and bug_open:
-            bb.note("The bug is known as '%s'" % bug_number)
+            print >> debug_file, "The bug is known as '%s'" % bug_number
             return NotHandled
 
         if bug_number and not bug_open:
             if not seppuku_reopen_bug(poster, reopen, product, component, bug_number, bugname, text):
-                bb.note("Failed to reopen the bug report")
-        elif not seppuku_file_bug(poster, newbug, product, component, bugname, text):
-            bb.note("Filing a bugreport failed")
+                print >> debug_file, "Failed to reopen the bug report"
+            else:
+                print >> debug_file, "Reopened the bug report"
+        else:	
+            bug_number = seppuku_file_bug(poster, newbug, product, component, bugname, text)
+            if not bug_number:
+                print >> debug_file, "Filing a bugreport failed"
         else:
-            # get the new bug number and create an attachment
-            (bug_open, bug_number) = seppuku_find_bug_report(opener, query, product, component, bugname)
+            print >> debug_file, "The new bug_number: '%s'" % bug_number
 
         if file:
-            if not seppuku_create_attachment(poster, attach, product, component, bug_number, text, file):
-                bb.note("Failed to attach the build log")
+            if not seppuku_create_attachment(debug_file, poster, attach, product, component, bug_number, text, file):
+                print >> debug_file, "Failed to attach the build log"
+            else:
+                print >> debug_file, "Created an attachment for '%s' '%s' '%s'" % (product, component, bug_number)
+        else:
+            print >> debug_file, "Not trying to create an attachment"
 
     return NotHandled
 }






More information about the Openembedded-commits mailing list