@@ -0,0 +1,2099 @@
+#!/usr/bin/env python3%0A#%0A# This Source Code Form is subject to the terms of the Mozilla Public%0A# License, v. 2.0. If a copy of the MPL was not distributed with this%0A# file, You can obtain one at http://mozilla.org/MPL/2.0/.%0A#%0A# Lists your outgoing gerrit changes, showing if the change is waiting in the%0A# CI queue. Useful as otherwise the web browser would show this info in a huge%0A# tooltip that usually blinks + frequently reloads.%0A#%0A%0Afrom html.parser import HTMLParser%0Aimport json%0Aimport re%0Aimport subprocess%0Aimport urllib.request%0A%0A%0Adef getGerritChanges():%0A    ret = %5B%5D%0A%0A    p = subprocess.Popen(%5B%22ssh%22, %22logerrit%22, %22gerrit%22, %22query%22, %22--format=json%22, %22status:open project:core owner:self%22%5D, stdout=subprocess.PIPE)%0A    lines = p.communicate()%5B0%5D.decode('utf-8').splitlines()%0A    for line in lines:%0A        j = json.loads(line)%0A        if %22url%22 in j.keys():%0A            ret.append(j)%0A%0A    return ret%0A%0A%0Adef downloadString(url):%0A    response = urllib.request.urlopen(url)%0A    data = response.read()%0A    return data.decode('utf-8')%0A%0A%0Adef getCIChanges(changesHTML):%0A    class MyHTMLParser(HTMLParser):%0A        def __init__(self):%0A            HTMLParser.__init__(self)%0A            self.changes = %5B%5D%0A%0A        def handle_starttag(self, tag, attrs):%0A            if tag == %22a%22:%0A                for attrKey, attrValue in attrs:%0A                    if attrKey == %22tooltip%22:%0A                        match = re.match(%22.*(https://gerrit.libreoffice.org/%5B0-9%5D+).*%22, attrValue)%0A                        if match:%0A                            self.changes.append(match.group(1))%0A%0A    parser = MyHTMLParser()%0A    parser.feed(changesHTML)%0A    return sorted(set(parser.changes))%0A%0Agerrit = getGerritChanges()%0A%0AchangesHTML = downloadString(%22https://ci.libreoffice.org/ajaxBuildQueue%22)%0Aci = getCIChanges(changesHTML)%0A%0Afor gerritChange in gerrit:%0A    line = gerritChange%5B%22url%22%5D + %22 for %22 + gerritChange%5B%22branch%22%5D + %22: %22%0A    if gerritChange%5B%22url%22%5D in ci:%0A        line += %22change is in the CI queue%22%0A    else:%0A        line += %22change is not in the CI queue%22%0A    print(line)%0A%0A# vim:set shiftwidth=4 softtabstop=4 expandtab:%0A

add ci queue view script