diff options
Diffstat (limited to 'classes/seppuku.bbclass')
| -rw-r--r-- | classes/seppuku.bbclass | 84 |
1 files changed, 57 insertions, 27 deletions
diff --git a/classes/seppuku.bbclass b/classes/seppuku.bbclass index 7e4b2098be..546738dde8 100644 --- a/classes/seppuku.bbclass +++ b/classes/seppuku.bbclass @@ -32,7 +32,7 @@ def seppuku_login(opener, login, user, password): the resulting page then @param opened = cookie enabled urllib2 opener - @param login = http://bugs.openembedded.org/query.cgi? + @param login = http://bugs.openembedded.net/query.cgi? @param user = Your username @param password = Your password """ @@ -116,12 +116,12 @@ def seppuku_find_bug_report(debug_file, opener, query, product, component, bugna and the status. @param opener = urllib2 opener - @param query = e.g. http://bugs.openembedded.org/query.cgi? + @param query = e.g. http://bugs.openembedded.net/query.cgi? @param product = search for this product @param component = search for this component @param bugname = the bug to search for - 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 + http://bugs.openembedded.net/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 @@ -129,7 +129,9 @@ def seppuku_find_bug_report(debug_file, opener, query, product, component, bugna component = urllib.quote(component) bugname = urllib.quote(bugname) - result = opener.open("%(query)sproduct=%(product)s&component=%(component)s&short_desc_type=substring&short_desc=%(bugname)s" % vars()) + file = "%(query)sproduct=%(product)s&component=%(component)s&short_desc_type=substring&short_desc=%(bugname)s" % vars() + print >> debug_file, "Trying %s" % file + result = opener.open(file) if result.code != 200: raise "Can not query the bugzilla at all" txt = result.read() @@ -138,11 +140,11 @@ def seppuku_find_bug_report(debug_file, opener, query, product, component, bugna if len(scanner.result()) == 0: print >> debug_file, "Scanner failed to scan the html site" print >> debug_file, "%(query)sproduct=%(product)s&component=%(component)s&short_desc_type=substring&short_desc=%(bugname)s" % vars() - print >> debug_file, txt + #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 + #print >> debug_file, txt (number,status) = scanner.result()[0] return (not status in ["CLOS", "RESO", "VERI"],number) @@ -152,7 +154,7 @@ def seppuku_reopen_bug(poster, file, product, component, bug_number, bugname, te Same as with opening a new report, some bits need to be inside the url - http://bugs.openembedded.org/process_bug.cgi?id=239&bug_file_loc=http%3A%2F%2F&version=Angstrom&longdesclength=2&product=Openembedded&component=Build&comment=bla&priority=P2&bug_severity=normal&op_sys=Linux&rep_platform=Other&knob=reopen&short_desc=foo + http://bugs.openembedded.net/process_bug.cgi?id=239&bug_file_loc=http%3A%2F%2F&version=Angstrom&longdesclength=2&product=Openembedded&component=Build&comment=bla&priority=P2&bug_severity=normal&op_sys=Linux&rep_platform=Other&knob=reopen&short_desc=foo """ import urllib2 @@ -187,7 +189,7 @@ def seppuku_file_bug(poster, file, product, component, bugname, text): Create a completely new bug report - http://bugs.openembedded.org/post_bug.cgi?bug_file_loc=http%3A%2F%2F&version=Angstrom&product=Openembedded&component=Build&short_desc=foo&comment=bla&priority=P2&bug_severity=normal&op_sys=Linux&rep_platform=Other + http://bugs.openembedded.net/post_bug.cgi?bug_file_loc=http%3A%2F%2F&version=Angstrom&product=Openembedded&component=Build&short_desc=foo&comment=bla&priority=P2&bug_severity=normal&op_sys=Linux&rep_platform=Other You are forced to add some default values to the bugzilla query and stop with '&' @@ -226,7 +228,7 @@ def seppuku_file_bug(poster, file, product, component, bugname, text): else: return res[0] -def seppuku_create_attachment(debug, poster, attach_query, product, component, bug_number, text, file): +def seppuku_create_attachment(data, debug, poster, attach_query, product, component, bug_number, text, file): """ Create a new attachment for the failed report @@ -235,10 +237,20 @@ def seppuku_create_attachment(debug, poster, attach_query, product, component, b if not bug_number: import bb bb.note("Can't create an attachment, no bugnumber passed to method") + print >> debug, "Can't create an attachment, no bugnumber passed to method" + return False + + if not attach_query: + import bb + bb.note("Can't create an attachment, no attach_query passed to method") + print >> debug, "Can't create an attachment, no attach_query passed to method" return False + import bb + logdescription = "Build log for machine %s" % (bb.data.getVar('MACHINE', data, True)) + import urllib2 - param = { "bugid" : bug_number, "action" : "insert", "data" : file, "description" : "Build log", "ispatch" : "0", "contenttypemethod" : "list", "contenttypeselection" : "text/plain", "comment" : text } + param = { "bugid" : bug_number, "action" : "insert", "data" : file, "description" : logdescription, "ispatch" : "0", "contenttypemethod" : "list", "contenttypeselection" : "text/plain", "comment" : text } try: result = poster.open( attach_query, param ) @@ -248,12 +260,16 @@ def seppuku_create_attachment(debug, poster, attach_query, product, component, b return False except Exception, e: print e - return False + print >> debug, "Got exception in poster.open( attach_query, param )" + print >> debug, "attach_query: %s param: %s" % (attach_query, param ) + return False - print >> debug, result.read() + txt = result.read() if result.code != 200: + print >> debug, "Got bad return code (%s)" % result.code return False else: + print >> debug, "Got good return code (200)" return True @@ -289,8 +305,8 @@ python seppuku_eventhandler() { if name == "PkgFailed": if not bb.data.getVar('SEPPUKU_AUTOBUILD', data, True) == "0": - build.exec_task('do_clean', data) - elif name == "TaskFailed" or name == "NoProvider": + build.exec_func('do_clean', data) + elif name == "TaskFailed": cj = cookielib.CookieJar() opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj)) poster = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj),MultipartPostHandler.MultipartPostHandler) @@ -303,6 +319,12 @@ 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) + proxy = bb.data.getVar('HTTP_PROXY', data, True ) + if (proxy): + phl = urllib2.ProxyHandler({'http' : proxy}) + poster.add_handler(phl) + opener.add_handler(phl) + # evil hack to figure out what is going on debug_file = open(os.path.join(bb.data.getVar("TMPDIR", data, True),"..","seppuku-log"),"a") @@ -315,20 +337,16 @@ python seppuku_eventhandler() { file = None if name == "TaskFailed": - bugname = "%(package)s-%(pv)s-%(pr)s-%(task)s" % { "package" : bb.data.getVar("PN", data, True), + bugname = "%(package)s-%(pv)s-autobuild" % { "package" : bb.data.getVar("PN", data, True), "pv" : bb.data.getVar("PV", data, True), - "pr" : bb.data.getVar("PR", data, True), - "task" : e.task } + } log_file = glob.glob("%s/log.%s.*" % (bb.data.getVar('T', event.data, True), event.task)) - text = "The package failed to build at %s for machine %s" % (bb.data.getVar('DATETIME', data, True), bb.data.getVar( 'MACHINE', data, True ) ) + text = "The %s step in %s failed at %s for machine %s" % (e.task, bb.data.getVar("PN", data, True), bb.data.getVar('DATETIME', data, True), bb.data.getVar( 'MACHINE', data, True ) ) if len(log_file) != 0: 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 " % (event.getItem) - # text = "Please fix it" else: print >> debug_file, "Unknown name '%s'" % name assert False @@ -336,16 +354,23 @@ python seppuku_eventhandler() { (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) - # The bug is present and still open, no need to attach an error log + # The bug is present and still open, attach an error log if bug_number and bug_open: print >> debug_file, "The bug is known as '%s'" % bug_number + if file: + if not seppuku_create_attachment(data, debug_file, poster, attach, product, component, bug_number, text, file): + print >> debug_file, "Failed to attach the build log for bug #%s" % bug_number + 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 for bug #%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): - print >> debug_file, "Failed to reopen the bug report" + print >> debug_file, "Failed to reopen the bug #%s" % bug_number else: - print >> debug_file, "Reopened the bug report" + print >> debug_file, "Reopened the bug #%s" % bug_number else: bug_number = seppuku_file_bug(poster, newbug, product, component, bugname, text) if not bug_number: @@ -354,12 +379,17 @@ python seppuku_eventhandler() { print >> debug_file, "The new bug_number: '%s'" % bug_number if bug_number and file: - if not seppuku_create_attachment(debug_file, poster, attach, product, component, bug_number, text, file): - print >> debug_file, "Failed to attach the build log" + if not seppuku_create_attachment(data, debug_file, poster, attach, product, component, bug_number, text, file): + print >> debug_file, "Failed to attach the build log for bug #%s" % bug_number 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" + print >> debug_file, "Not trying to create an attachment for bug #%s" % bug_number + + # store bug number for oestats-client + if bug_number: + bb.data.setVar('OESTATS_BUG_NUMBER', bug_number, event.data) + bb.data.setVar('OESTATS_BUG_TRACKER', "http://bugs.openembedded.net/", event.data) return NotHandled } |
