summaryrefslogtreecommitdiff
path: root/usr/src/tools/onbld/Checks/DbLookups.py
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src/tools/onbld/Checks/DbLookups.py')
-rw-r--r--usr/src/tools/onbld/Checks/DbLookups.py35
1 files changed, 30 insertions, 5 deletions
diff --git a/usr/src/tools/onbld/Checks/DbLookups.py b/usr/src/tools/onbld/Checks/DbLookups.py
index 84cbbe96bc..d396a68cbc 100644
--- a/usr/src/tools/onbld/Checks/DbLookups.py
+++ b/usr/src/tools/onbld/Checks/DbLookups.py
@@ -1,4 +1,4 @@
-#! /usr/bin/python
+#!ON_PYTHON
#
# CDDL HEADER START
#
@@ -26,15 +26,16 @@
# Copyright 2010, Richard Lowe
# Copyright 2018 OmniOS Community Edition (OmniOSce) Association.
+# Copyright (c) 2019, Joyent, Inc.
#
# Various database lookup classes/methods, i.e.:
-# * monaco
-# * bugs.opensolaris.org (b.o.o.)
# * redmine (illumos.org)
+# * smartos
#
import re
+import json
try:
from urllib.request import urlopen, Request
from urllib.error import HTTPError
@@ -66,9 +67,9 @@ class BugDB(object):
print r["6505625"]["synopsis"]
"""
- VALID_DBS = ["illumos"]
+ VALID_DBS = ["illumos", "smartos"]
- def __init__(self, priority = ["illumos"]):
+ def __init__(self, priority = VALID_DBS):
"""Create a BugDB object.
Keyword argument:
@@ -79,6 +80,24 @@ class BugDB(object):
raise BugDBException(database)
self.__priority = priority
+ def __smartosbug(self, cr):
+ url = "http://smartos.org/bugview/json/%s" % cr
+ req = Request(url)
+
+ try:
+ data = urlopen(req)
+ except HTTPError as e:
+ if e.code == 404 or e.code == 403 or e.code == 400:
+ raise NonExistentBug(cr)
+ else:
+ raise
+
+ bug = json.load(data)
+
+ return {'cr_number': bug['id'],
+ 'synopsis': bug['summary']
+ }
+
def __illbug(self, cr):
url = "http://illumos.org/issues/%s.xml" % cr
@@ -121,6 +140,12 @@ class BugDB(object):
results[str(cr)] = self.__illbug(cr)
except NonExistentBug:
continue
+ elif database == "smartos":
+ for cr in crs:
+ try:
+ results[str(cr)] = self.__smartosbug(cr)
+ except NonExistentBug:
+ continue
# the CR has already been found by one bug database
# so don't bother looking it up in the others