scripts/list-ci-changes.py | 80 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+)
New commits: commit 046c468924a047588ac1328b13d334bb8484480e Author: Miklos Vajna <vmik...@collabora.co.uk> AuthorDate: Wed Oct 31 09:11:59 2018 +0100 Commit: Miklos Vajna <vmik...@collabora.co.uk> CommitDate: Wed Oct 31 09:14:18 2018 +0100 list-ci-changes: add cmdline tool to list not yet queued gerrit changes If you push a change to gerrit and the build queue is long enough, then there is no "Build queued" on it, but it's not ignored, either. This tool can list the changes which are in this "not yet queued" state, without having to interact with the hard-to-understand ci.libreoffice.org in a browser. Change-Id: Ibe7579d911741dce491d5538ab76639d453769dc diff --git a/scripts/list-ci-changes.py b/scripts/list-ci-changes.py new file mode 100755 index 0000000..99a8c1b --- /dev/null +++ b/scripts/list-ci-changes.py @@ -0,0 +1,80 @@ +#!/usr/bin/env python3 +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# Lists your outgoing gerrit changes, showing if the change is waiting in the +# CI queue. Useful as otherwise the web browser would show this info in a huge +# tooltip that usually blinks + frequently reloads. +# +# The only optional parameter is a gerrit change integer, in that case it +# checks for that change, instead of all your own changes. +# + +from html.parser import HTMLParser +import json +import re +import subprocess +import urllib.request +import sys + + +def getGerritChanges(): + ret = [] + + p = subprocess.Popen(["ssh", "logerrit", "gerrit", "query", "--format=json", "status:open project:core owner:self"], stdout=subprocess.PIPE) + lines = p.communicate()[0].decode('utf-8').splitlines() + for line in lines: + j = json.loads(line) + if "url" in j.keys(): + ret.append(j) + + return ret + + +def downloadString(url): + response = urllib.request.urlopen(url) + data = response.read() + return data.decode('utf-8') + + +def getCIChanges(changesHTML): + class MyHTMLParser(HTMLParser): + def __init__(self): + HTMLParser.__init__(self) + self.changes = [] + + def handle_starttag(self, tag, attrs): + if tag == "a": + for attrKey, attrValue in attrs: + if attrKey == "tooltip": + match = re.match(".*(https://gerrit.libreoffice.org/[0-9]+).*", attrValue) + if match: + self.changes.append(match.group(1)) + + parser = MyHTMLParser() + parser.feed(changesHTML) + return sorted(set(parser.changes)) + +def main(): + if len(sys.argv) > 1: + gerrit = [{"url": "https://gerrit.libreoffice.org/" + sys.argv[1], "branch": "unknown"}] + else: + gerrit = getGerritChanges() + + changesHTML = downloadString("https://ci.libreoffice.org/ajaxBuildQueue") + ci = getCIChanges(changesHTML) + + for gerritChange in gerrit: + line = gerritChange["url"] + " for " + gerritChange["branch"] + ": " + if gerritChange["url"] in ci: + line += "change is in the CI queue" + else: + line += "change is not in the CI queue" + print(line) + +if __name__ == '__main__': + main() + +# vim:set shiftwidth=4 softtabstop=4 expandtab: _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits