Print this page
3674 onbld Checks should not query opensolaris.org

Split Close
Expand all
Collapse all
          --- old/usr/src/tools/onbld/Checks/DbLookups.py
          +++ new/usr/src/tools/onbld/Checks/DbLookups.py
↓ open down ↓ 54 lines elided ↑ open up ↑
  55   55          """Lookup change requests.
  56   56  
  57   57          Usage:
  58   58          bdb = BugDB()
  59   59          r = bdb.lookup("6455550")
  60   60          print r["6455550"]["synopsis"]
  61   61          r = bdb.lookup(["6455550", "6505625"])
  62   62          print r["6505625"]["synopsis"]
  63   63          """
  64   64  
  65      -        VALID_DBS = ["bugster", "illumos"]
       65 +        VALID_DBS = ["illumos"]
  66   66  
  67      -        def __init__(self, priority = ("illumos", "bugster")):
       67 +        def __init__(self, priority = ["illumos"]):
  68   68                  """Create a BugDB object.
  69   69  
  70   70                  Keyword argument:
  71   71                  priority: use bug databases in this order
  72   72                  """
  73   73                  for database in priority:
  74   74                          if database not in self.VALID_DBS:
  75   75                                  raise BugDBException, database
  76   76                  self.__priority = priority
  77   77  
↓ open down ↓ 11 lines elided ↑ open up ↑
  89   89                                  raise
  90   90  
  91   91                  bug = ElementTree.parse(data)
  92   92  
  93   93                  return {'cr_number': bug.find('id').text,
  94   94                          'synopsis': bug.find('subject').text,
  95   95                          'status': bug.find('status').attrib['name']
  96   96                  }
  97   97  
  98   98  
  99      -        def __boobug(self, cr):
 100      -                cr = str(cr)
 101      -                url = "http://bugs.opensolaris.org/view_bug.do"
 102      -                req = urllib2.Request(url, urllib.urlencode({"bug_id": cr}))
 103      -                results = {}
 104      -                try:
 105      -                        data = urllib2.urlopen(req).readlines()
 106      -                except urllib2.HTTPError, e:
 107      -                        if e.code != 404:
 108      -                                print "ERROR: HTTP error at " + \
 109      -                                        req.get_full_url() + \
 110      -                                        " got error: " + str(e.code)
 111      -                                raise e
 112      -                        else:
 113      -                                raise NonExistentBug(cr)
 114      -                except urllib2.URLError, e:
 115      -                        print "ERROR: could not connect to " + \
 116      -                                req.get_full_url() + \
 117      -                                ' got error: "' + e.reason[1] + '"'
 118      -                        raise e
 119      -                htmlParser = htmllib.HTMLParser(None)
 120      -                metaHtmlRe = re.compile(r'^<meta name="([^"]+)" content="([^"]*)">$')
 121      -                for line in data:
 122      -                        m = metaHtmlRe.search(line)
 123      -                        if not m:
 124      -                                continue
 125      -                        val = urllib.unquote(m.group(2))
 126      -                        htmlParser.save_bgn()
 127      -                        htmlParser.feed(val)
 128      -                        results[m.group(1)] = htmlParser.save_end()
 129      -                htmlParser.close()
 130      -
 131      -                if "synopsis" not in results:
 132      -                        raise NonExistentBug(cr)
 133      -
 134      -                results["cr_number"] = cr
 135      -                results["sub_category"] = results.pop("subcategory")
 136      -                results["status"] = results.pop("state")
 137      -                results["date_submitted"] = results.pop("submit_date")
 138      -
 139      -                return results
 140      -
 141   99          def lookup(self, crs):
 142  100                  """Return all info for requested change reports.
 143  101  
 144  102                  Argument:
 145  103                  crs: one change request id (may be integer, string, or list),
 146  104                       or multiple change request ids (must be a list)
 147  105  
 148  106                  Returns:
 149  107                  Dictionary, mapping CR=>dictionary, where the nested dictionary
 150  108                  is a mapping of field=>value
 151  109                  """
 152  110                  results = {}
 153  111                  if not isinstance(crs, list):
 154  112                          crs = [str(crs)]
 155  113                  for database in self.__priority:
 156      -                        if database == "bugster":
      114 +                        if database == "illumos":
 157  115                                  for cr in crs:
 158      -                                        cr = str(cr)
 159  116                                          try:
 160      -                                                results[cr] = self.__boobug(cr)
 161      -                                        except NonExistentBug:
 162      -                                                continue
 163      -                        elif database == "illumos":
 164      -                                for cr in crs:
 165      -                                        try:
 166  117                                                  results[str(cr)] = self.__illbug(cr)
 167  118                                          except NonExistentBug:
 168  119                                                  continue
 169  120  
 170  121                          # the CR has already been found by one bug database
 171  122                          # so don't bother looking it up in the others
 172  123                          for cr in crs:
 173  124                                  if cr in results:
 174  125                                          crs.remove(cr)
 175  126  
 176  127                  return results
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX