[ews-app] Fetch builder id to name mapping
authoraakash_jain@apple.com <aakash_jain@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 14 Feb 2019 00:16:16 +0000 (00:16 +0000)
committeraakash_jain@apple.com <aakash_jain@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 14 Feb 2019 00:16:16 +0000 (00:16 +0000)
https://bugs.webkit.org/show_bug.cgi?id=194355

Reviewed by Lucas Forschler.

* BuildSlaveSupport/ews-app/ews/common/buildbot.py:
(Buildbot.get_builder_id_to_name_mapping):
(Buildbot._get_display_name_from_builder_name):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@241485 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Tools/BuildSlaveSupport/ews-app/ews/common/buildbot.py
Tools/ChangeLog

index f85ad5f..9d9ffd4 100644 (file)
 
 import logging
 import os
+import re
 import subprocess
 
+import ews.common.util as util
 import ews.config as config
 
 _log = logging.getLogger(__name__)
@@ -49,3 +51,26 @@ class Buildbot():
             _log.warn('Error executing: {}, return code={}'.format(command, return_code))
 
         return return_code
+
+    @classmethod
+    def get_builder_id_to_name_mapping(cls):
+        builder_id_to_name_mapping = {}
+        builder_url = 'http://{}/api/v2/builders'.format(config.BUILDBOT_SERVER_HOST)
+        builders_data = util.fetch_data_from_url(builder_url)
+        if not builders_data:
+            return {}
+        for builder in builders_data.json().get('builders', []):
+            builder_id = builder['builderid']
+            builder_name = builder.get('name')
+            display_name = builder.get('description')
+            if not display_name:
+                display_name = Buildbot._get_display_name_from_builder_name(builder_name)
+            builder_id_to_name_mapping[builder_id] = {'builder_name': builder_name, 'display_name': display_name}
+        return builder_id_to_name_mapping
+
+    @classmethod
+    def _get_display_name_from_builder_name(cls, builder_name):
+        words = re.split('[, \-_:()]+', builder_name)
+        if not words:
+            return builder_name
+        return words[0].lower()
index 22cc6a5..c76865a 100644 (file)
@@ -1,3 +1,14 @@
+2019-02-13  Aakash Jain  <aakash_jain@apple.com>
+
+        [ews-app] Fetch builder id to name mapping
+        https://bugs.webkit.org/show_bug.cgi?id=194355
+
+        Reviewed by Lucas Forschler.
+
+        * BuildSlaveSupport/ews-app/ews/common/buildbot.py:
+        (Buildbot.get_builder_id_to_name_mapping):
+        (Buildbot._get_display_name_from_builder_name):
+
 2019-02-12  Jiewen Tan  <jiewen_tan@apple.com>
 
         Further restricting webarchive loads