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.
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)
###
import time
import socket
-from Reporter import BugReport
+import Reporter
# Keys replaced by server.
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
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()
# 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.