summaryrefslogtreecommitdiffstats
path: root/WebKitTools/Scripts/modules/statusbot.py
diff options
context:
space:
mode:
Diffstat (limited to 'WebKitTools/Scripts/modules/statusbot.py')
-rw-r--r--WebKitTools/Scripts/modules/statusbot.py39
1 files changed, 31 insertions, 8 deletions
diff --git a/WebKitTools/Scripts/modules/statusbot.py b/WebKitTools/Scripts/modules/statusbot.py
index 9c9ba04..350aebf 100644
--- a/WebKitTools/Scripts/modules/statusbot.py
+++ b/WebKitTools/Scripts/modules/statusbot.py
@@ -46,21 +46,44 @@ http://wwwsearch.sourceforge.net/mechanize/
"""
exit(1)
+import urllib2
+
+
class StatusBot:
default_host = "webkit-commit-queue.appspot.com"
def __init__(self, host=default_host):
+ self.set_host(host)
+ self.browser = Browser()
+
+ def set_host(self, host):
self.statusbot_host = host
self.statusbot_server_url = "http://%s" % self.statusbot_host
- self.update_status_url = "%s/update_status" % self.statusbot_server_url
- self.browser = Browser()
- def update_status(self, status, bug_id=None, patch_id=None):
- self.browser.open(self.update_status_url)
+ def update_status(self, queue_name, status, patch=None, results_file=None):
+ # During unit testing, statusbot_host is None
+ if not self.statusbot_host:
+ return
+
+ update_status_url = "%s/update-status" % self.statusbot_server_url
+ self.browser.open(update_status_url)
self.browser.select_form(name="update_status")
- if bug_id:
- self.browser['bug_id'] = str(bug_id)
- if patch_id:
- self.browser['patch_id'] = str(patch_id)
+ self.browser['queue_name'] = queue_name
+ if patch:
+ if patch.get('bug_id'):
+ self.browser['bug_id'] = str(patch['bug_id'])
+ if patch.get('id'):
+ self.browser['patch_id'] = str(patch['id'])
self.browser['status'] = status
+ if results_file:
+ self.browser.add_file(results_file, "text/plain", "results.txt", 'results_file')
self.browser.submit()
+
+ def patch_status(self, queue_name, patch_id):
+ update_status_url = "%s/patch-status/%s/%s" % (self.statusbot_server_url, queue_name, patch_id)
+ try:
+ return urllib2.urlopen(update_status_url).read()
+ except urllib2.HTTPError, e:
+ if e.code == 404:
+ return None
+ raise e