summaryrefslogtreecommitdiff
path: root/usr/src
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src')
-rw-r--r--usr/src/tools/onbld/Checks/Comments.py15
-rw-r--r--usr/src/tools/onbld/Checks/DbLookups.py101
-rw-r--r--usr/src/tools/onbld/Checks/Rti.py5
-rw-r--r--usr/src/tools/onbld/hgext/cdm.py3
4 files changed, 56 insertions, 68 deletions
diff --git a/usr/src/tools/onbld/Checks/Comments.py b/usr/src/tools/onbld/Checks/Comments.py
index 9154e84abc..8583acc159 100644
--- a/usr/src/tools/onbld/Checks/Comments.py
+++ b/usr/src/tools/onbld/Checks/Comments.py
@@ -21,7 +21,7 @@
#
#
-# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
+# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
@@ -51,7 +51,7 @@ def isBug(comment):
def normalize_arc(caseid):
return re.sub(r'^([A-Z][A-Z]*ARC)[/ \t]', '\\1 ', caseid)
-def comchk(comments, check_db=True, output=sys.stderr):
+def comchk(comments, check_db=True, output=sys.stderr, arcPath=None):
'''Validate checkin comments against ON standards.
Comments must be a list of one-line comments, with no trailing
@@ -147,7 +147,7 @@ def comchk(comments, check_db=True, output=sys.stderr):
entered])
if check_db:
- valid = ARC(arcs.keys())
+ valid = ARC(arcs.keys(), arcPath)
for case, insts in arcs.iteritems():
if len(insts) > 1:
@@ -159,22 +159,19 @@ def comchk(comments, check_db=True, output=sys.stderr):
if not case in valid:
errors['nonexistent'].append(' '.join(case))
continue
- #
- # The opensolaris.org ARC interfaces only give us the
- # first 40 characters of the case name, so we must limit
- # our checking similarly.
+
#
# We first try a direct match between the actual case name
# and the entered comment. If that fails we remove a possible
# trailing (fix nit)-type comment, and re-try.
#
for entered in insts:
- if entered[0:40] == valid[case]:
+ if entered == valid[case]:
break
else:
# Try again with trailing (fix ...) removed.
dbcom = re.sub(r' \([^)]+\)$', '', entered)
- if dbcom[0:40] != valid[case]:
+ if dbcom != valid[case]:
errors['nomatch'].append(
[' '.join(case), valid[case],
entered])
diff --git a/usr/src/tools/onbld/Checks/DbLookups.py b/usr/src/tools/onbld/Checks/DbLookups.py
index c5b4b50fbc..aa45504281 100644
--- a/usr/src/tools/onbld/Checks/DbLookups.py
+++ b/usr/src/tools/onbld/Checks/DbLookups.py
@@ -21,7 +21,7 @@
#
#
-# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
+# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
@@ -29,9 +29,10 @@
# Various database lookup classes/methods, i.e.:
# * monaco
# * bugs.opensolaris.org (b.o.o.)
-# * opensolaris.org/cgi/arc.py (for ARC)
+# * arc.opensolaris.org/cgi-bin/arc.cgi (for ARC)
#
+import csv
import re
import urllib
import urllib2
@@ -41,25 +42,13 @@ from socket import socket, AF_INET, SOCK_STREAM
from onbld.Checks import onSWAN
-class BugException(Exception):
- def __init__(self, data=''):
- self.data = data
- Exception.__init__(self, data)
-
- def __str__(self):
- return "Unknown error: %s" % self.data
-
-class NonExistentBug(BugException):
+class NonExistentBug(Exception):
def __str__(self):
- return "Bug %s does not exist" % self.data
+ return "Bug %s does not exist" % (Exception.__str__(self))
class BugDBException(Exception):
- def __init__(self, data=''):
- self.data = data
- Exception.__init__(self, data)
-
def __str__(self):
- return "Unknown bug database: %s" % self.data
+ return "Unknown bug database: %s" % (Exception.__str__(self))
class BugDB(object):
"""Lookup change requests.
@@ -75,7 +64,7 @@ class BugDB(object):
print r["6505625"]["synopsis"]
"""
- def __init__(self, priority = ("bugster",), forceBoo = False):
+ def __init__(self, priority = ("bugster",), forceBoo=False):
"""Create a BugDB object.
Keyword argument:
@@ -224,15 +213,17 @@ class BugDB(object):
return results
####################################################################
-def ARC(arclist):
- opts = {}
- url = "http://opensolaris.org/cgi/arc.py"
- opts["n"] = str(len(arclist))
- for i, arc in enumerate(arclist):
- arc, case = arc
- opts["arc" + str(i)] = arc
- opts["case" + str(i)] = case
- req = urllib2.Request(url, urllib.urlencode(opts))
+class ARCException(Exception):
+ """This covers arc.cgi script failure."""
+ def __str__(self):
+ return "Error retrieving ARC data: %s" % (Exception.__str__(self))
+
+def ARC(arclist, arcPath=None):
+ if not arcPath:
+ arcPath = "http://arc.opensolaris.org/cgi-bin/arc.cgi"
+ fields = ["present", "arc", "year", "case", "status", "title"]
+ opts = [("case", "%s/%s" % (a, c)) for a, c in arclist]
+ req = urllib2.Request(arcPath, urllib.urlencode(opts))
try:
data = urllib2.urlopen(req).readlines()
except urllib2.HTTPError, e:
@@ -245,14 +236,13 @@ def ARC(arclist):
' got error: "' + e.reason[1] + '"'
raise e
ret = {}
- for line in data:
- oneline = line.rstrip('\n')
- fields = oneline.split('|')
- # check if each is valid ( fields[0]::validity )
- if fields[0] != "0":
- continue
- arc, case = fields[1].split(" ")
- ret[(arc, case)] = fields[2]
+ for line in csv.DictReader(data, fields):
+ if line["present"] == "exists":
+ yc = "%s/%s" % (line["year"], line["case"])
+ ret[(line["arc"], yc)] = line["title"]
+ elif line["present"] == "fatal":
+ raise ARCException(line["arc"])
+
return ret
####################################################################
@@ -268,40 +258,39 @@ WEBRTICLI = '/net/onnv.sfbay.sun.com/export/onnv-gate/public/bin/webrticli'
class RtiException(Exception):
- def __init__(self, data=''):
- self.data = data
- Exception.__init__(self, data)
-
- def __str__(self):
- return "Unknown error: %s" % self.data
+ pass
class RtiCallFailed(RtiException):
def __str__(self):
- return "Unable to call webrti: %s" % self.data
+ return "Unable to call webrti: %s" % (RtiException.__str__(self))
class RtiSystemProblem(RtiException):
def __str__(self):
- return "RTI status cannot be determined: %s" % self.data
+ return "RTI status cannot be determined for CR: %s" % (RtiException.__str__(self))
class RtiIncorrectCR(RtiException):
def __str__(self):
- return "Incorrect CR number specified: %s" % self.data
+ return "Incorrect CR number specified: %s" % (RtiException.__str__(self))
class RtiNotFound(RtiException):
def __str__(self):
- return "RTI not found: %s" % self.data
+ return "RTI not found for CR: %s" % (RtiException.__str__(self))
class RtiNeedConsolidation(RtiException):
def __str__(self):
- return "More than one consolidation has this CR: %s" % self.data
+ return "More than one consolidation has this CR: %s" % (RtiException.__str__(self))
class RtiBadGate(RtiException):
def __str__(self):
- return "Incorrect gate name specified: %s" % self.data
+ return "Incorrect gate name specified: %s" % (RtiException.__str__(self))
+
+class RtiUnknownException(Exception):
+ def __str__(self):
+ return "Unknown webrti return code: %s" % (RtiException.__str__(self))
class RtiOffSwan(RtiException):
def __str__(self):
- return "RTI status checks need SWAN access: %s" % self.data
+ return "RTI status checks need SWAN access: %s" % (RtiException.__str__(self))
WEBRTI_ERRORS = {
'1': RtiSystemProblem,
@@ -405,17 +394,23 @@ class Rti:
# parse the data to see if we got a return code
# if we did, then that's bad. if we didn't,
- # then our call was successfully
+ # then our call was successful
m = returnCodeRe.search(data)
if m:
+ rc = m.group(1)
# we got a return code, set it in our
# object, set the webRtiOutput for debugging
# or logging, and return a failure
- if m.group(1) in WEBRTI_ERRORS:
- exc = WEBRTI_ERRORS[m.group(1)]
+ if rc in WEBRTI_ERRORS:
+ exc = WEBRTI_ERRORS[rc]
+ if exc == RtiBadGate:
+ edata = gate
+ else:
+ edata = cr
else:
- exc = RtiException
- raise exc(data)
+ exc = RtiUnknownException
+ edata = rc
+ raise exc(edata)
data = data.splitlines()
# At this point, we should have valid data
diff --git a/usr/src/tools/onbld/Checks/Rti.py b/usr/src/tools/onbld/Checks/Rti.py
index 38ba2500c7..0dd3ffcaa9 100644
--- a/usr/src/tools/onbld/Checks/Rti.py
+++ b/usr/src/tools/onbld/Checks/Rti.py
@@ -110,11 +110,6 @@ def rti(bugids, gatePath=None, consolidation=None,
except RtiOffSwan, e:
output.write("%s\n" % e)
return False
- except RtiNotFound, e:
- output.write("Error: no RTI found for bug %s\n"
- % cr)
- badRtis.append(cr)
- continue
except RtiException, e:
output.write("%s\n" % e)
badRtis.append(cr)
diff --git a/usr/src/tools/onbld/hgext/cdm.py b/usr/src/tools/onbld/hgext/cdm.py
index 01299d7e80..aa1cd42f49 100644
--- a/usr/src/tools/onbld/hgext/cdm.py
+++ b/usr/src/tools/onbld/hgext/cdm.py
@@ -293,7 +293,8 @@ def cdm_comchk(ui, repo, **opts):
ui.write('Comments check:\n')
check_db = not opts.get('nocheck')
- return Comments.comchk(active.comments(), check_db=check_db, output=ui)
+ return Comments.comchk(active.comments(), check_db=check_db, output=ui,
+ arcPath=ui.config('cdm', 'arcpath', None))
def cdm_cddlchk(ui, repo, *args, **opts):