]> granicus.if.org Git - clang/commitdiff
Make scan-view more robust / friendly when bug reporting fails.
authorDaniel Dunbar <daniel@zuster.org>
Sat, 20 Sep 2008 01:43:16 +0000 (01:43 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Sat, 20 Sep 2008 01:43:16 +0000 (01:43 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56382 91177308-0d34-0410-b5e6-96231b3b80d8

tools/scan-view/Reporter.py
tools/scan-view/Resources/FileRadar.scpt
tools/scan-view/ScanView.py

index a28d0945ac3e8a9f1548e460a426c3ac0e6fcfa1..5bfe4469061eef729937f5a1c70719015590ee23 100644 (file)
@@ -2,7 +2,14 @@
 
 import subprocess, sys, os
 
-__all__ = ['BugReport', 'getReporters']
+__all__ = ['ReportFailure', 'BugReport', 'getReporters']
+
+#
+
+class ReportFailure(Exception):
+    """Generic exception for failures in bug reporting."""
+    def __init__(self, value):        
+        self.value = value
 
 # Collect information about a bug.
 
@@ -135,18 +142,29 @@ class RadarReporter:
                    p = subprocess.Popen(args, 
                                  stdout=subprocess.PIPE, stderr=subprocess.PIPE)
                except:
-            print >>sys.stderr, '%s: SERVER: radar failed'%(sys.argv[0],)
-            sys.print_exc()
-            raise
+            raise ReportFailure("Unable to file radar (AppleScript failure).")
         data, err = p.communicate()
-#        print >>sys.stderr, '%s: SERVER: radar report: "%s" "%s"'%(sys.argv[0],data, err)
         res = p.wait()
-#        print >>sys.stderr, '%s: SERVER: radar report res: %d'%(sys.argv[0],res,)
 
         if res:
-            raise RuntimeError,'Radar submission failed.'
+            raise ReportFailure("Unable to file radar (AppleScript failure).")
+
+        try:
+            values = eval(data)
+        except:
+            raise ReportFailure("Unable to process radar results.")
 
-        return data.replace('\n','\n<br>')
+        # We expect (int: bugID, str: message)
+        if len(values) != 2 or not isinstance(values[0], int):
+            raise ReportFailure("Unable to process radar results.")
+
+        bugID,message = values
+        bugID = int(bugID)
+        
+        if not bugID:
+            raise ReportFailure(message)
+        
+        return "Filed: <a href=\"rdar://%d/\">%d</a>"%(bugID,bugID)
 
 ###
 
index 145386c30c6a12c125c8186be44d2cfacbdb2b7a..a22489f38f866866426d01e08662bddf93eed11f 100644 (file)
Binary files a/tools/scan-view/Resources/FileRadar.scpt and b/tools/scan-view/Resources/FileRadar.scpt differ
index e340a9fa6cc37a17d128aa9e512e26f9de26befa..5e7bbf4fe8c4d2dd3b7619646544652f6824d9bc 100644 (file)
@@ -11,7 +11,7 @@ import threading
 import time
 import socket
 
-from Reporter import BugReport
+import Reporter
 
 # Keys replaced by server.
 
@@ -43,6 +43,13 @@ class ReporterThread(threading.Thread):
             time.sleep(3)
             if self.server.options.debug:
                 print >>sys.stderr, "%s: SERVER: submission complete."%(sys.argv[0],)
+        except Reporter.ReportFailure,e:
+            s = StringIO.StringIO()
+            print >>s,'Submission Failed<br><pre>'
+            print >>s,e.value
+            print >>s,'</pre>'
+            self.status = s.getvalue()
+            return            
         except Exception,e:
             s = StringIO.StringIO()
             import traceback
@@ -54,8 +61,8 @@ class ReporterThread(threading.Thread):
 
         s = StringIO.StringIO()
         print >>s, 'Submission Complete!'
-        print >>s, '<hr>'
         if result is not None:
+            print >>s, '<hr>'
             print >>s, result
         self.status = s.getvalue()
 
@@ -184,7 +191,7 @@ class ScanViewRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
         # Create the report.
         path = os.path.join(self.server.root, 'report-%s.html'%report)
         files = [path]
-        br = BugReport(title, description, files)
+        br = Reporter.BugReport(title, description, files)
 
         # Send back an initial response and wait for the report to
         # finish.