Plan 9 from Bell Labs’s /usr/web/sources/contrib/iainws/patchStatistics.py

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


"""Prints usage statistics of patches that have been applied to Plan 9""" 

import urllib


if __name__ == "__main__": 
    ok = False 
    urls = ["http://plan9.bell-labs.com/sources/patch/sorry/", "http://plan9.bell-labs.com/sources/patch/applied/"] 
    for url in urls: 
        s = "" 
        s = url[url.find("patch/")+6:len(s)-1] 
        print s.upper() 
        filehandle = urllib.urlopen(url) 
        res = [] 
        for line in filehandle.readlines(): 
            if line.startswith("<!-- END HEADER -->"): 
                ok = True 
            elif line.startswith("<!-- BEGIN TAIL -->"): 
                ok = False 
            if ok == True: 
                res.append(line) 

        answers = [] 

        for line in res: 
            line = line[line.find("0")+1:line.find("<a")] 
            print line 
            line = line.split(" ") 
            temp = [] 
            for ob in line: 
                if ob != '': 
                    temp.append(ob) 
            answers.append(temp[::-1])
	answers.sort()

	months = ["Jan", "Feb", "Mar", "Apr", "May","Jun", "Jul", "Aug", "Sep", "Oct", "Nov","Dec"] 
        cnt = 0; 
        lookup_month = {} 
        for month in months: 
            lookup_month[month] = cnt 
            cnt = cnt + 1 
        table = {} 
        for i in range(2004, 2012): 
            for month in months: 
                entry = str(i) + " " + month 
                table[entry] = 0 

        for line in answers: 
            if len(line) == 3: 
                entry = line[0] + " " + line[2] 
                if table.has_key(entry): 
                    table[entry] = table[entry] + 1 

        frequencies = [] 

        for key, value in table.iteritems(): 
            key = key.split(" ") 
            frequencies.append([key[0], lookup_month[key[1]], value]) 

        frequencies.sort() 
        for values in frequencies: 
            print str(values[0])+ " "+ str(months[values[1]]), ";", values[2]



Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].