Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

web status: add alert_msg

implement a simple way for action ressources to report errors to users

if action resource returns a tuple, then it is URL, alert_msg, the message is displayed
in the next web page

Signed-off-by: Pierre Tardy <pierre.tardy@intel.com>
  • Loading branch information...
commit 6eea4692f7d390caa531884626b7816eb556237c 1 parent 43eb37b
@tardyp authored
View
7 master/buildbot/status/web/base.py
@@ -213,6 +213,7 @@ def getContext(self, request):
welcomeurl = rootpath,
authz = self.getAuthz(request),
request = request,
+ alert_msg = request.args.get("alert_msg", [""])[0],
)
@@ -230,11 +231,17 @@ def performAction(self, request):
@param request: the web request
@returns: URL via Deferred
+ can also return (URL, alert_msg) to display simple
+ feedback to user in case of failure
"""
def render(self, request):
d = defer.maybeDeferred(lambda : self.performAction(request))
def redirect(url):
+ if isinstance(url, tuple):
+ url, alert_msg = url
+ if alert_msg:
+ url += "?alert_msg="+urllib.quote(alert_msg, safe='')
request.redirect(url)
request.write("see <a href='%s'>%s</a>" % (url,url))
try:
View
17 master/buildbot/status/web/build.py
@@ -58,19 +58,24 @@ def performAction(self, req):
comments = req.args.get("comments", ["<no reason specified>"])[0]
reason = ("The web-page 'rebuild' button was pressed by "
"'%s': %s\n" % (name, comments))
+ msg = ""
extraProperties = getAndCheckProperties(req)
if not bc or not b.isFinished() or extraProperties is None:
- log.msg("could not rebuild: bc=%s, isFinished=%s"
- % (bc, b.isFinished()))
- # TODO: indicate an error
+ msg = "could not rebuild: "
+ if b.isFinished():
+ msg += "build still not finished "
+ if bc:
+ msg += "could not get builder control"
else:
d = bc.rebuildBuild(b, reason, extraProperties)
wfd = defer.waitForDeferred(d)
yield wfd
tup = wfd.getResult()
# check that (bsid, brids) were properly stored
- if not isinstance(tup, (int, dict)):
- log.err("while rebuilding a build")
+ if not (isinstance(tup, tuple) and
+ isinstance(tup[0], int) and
+ isinstance(tup[1], dict)):
+ msg = "rebuilding a build failed "+ str(tup)
# we're at
# http://localhost:8080/builders/NAME/builds/5/rebuild?[args]
# Where should we send them?
@@ -82,7 +87,7 @@ def performAction(self, req):
# evidence of their build starting (or to see the reason that it
# didn't start). This should be the Builder page.
- url = path_to_builder(req, self.builder)
+ url = path_to_builder(req, self.builder), msg
yield url
View
6 master/buildbot/status/web/templates/layout.html
@@ -51,6 +51,12 @@
{%- block barecontent -%}
<hr/>
+
+ {% if alert_msg != "" %}
+ <div class="alert">
+ {{ alert_msg }}
+ </div>
+ {% endif %}
<div class="content">
{%- block content -%}
Please sign in to comment.
Something went wrong with that request. Please try again.