# usage: cd to the script path, then type: python kpvsum1.1.1.py
# past the url page of section you wish to check. It returns package number,
# free package, non adopted, adopted non-free.
# by default it check the page: http://wiki.gnewsense.org/Kernel/Ubuntu-hardy-drivers. For this
# you have to hit enter, only.
# if page to check is >>> http://wiki.gnewsense.org/Kernel/Image
# or >>> http://wiki.gnewsense.org/Kernel/Ubuntu-hardy-drivers
# it print on file 'Summary.txt' a table for the weekly update like this
'''
!!Package Section Summary (10 Mar 08)
||border=1 width=50%
||Completed, Free||0||
||Completed, NOT Free, age <= 28 days||0||
||Completed, NOT Free, age > 28 days||0||
||NOT Completed, age <= 28 days||0||
||NOT Completed, age > 28 days||1||
||NOT adopted||23||
||Total||25||
'''
import urllib
import string
from time import gmtime, strftime
URLtoOPEN=raw_input("enter URL (nothing for kernel's drivers main page): ")
if URLtoOPEN=="":a= urllib.urlopen('http://wiki.gnewsense.org/Kernel/Ubuntu-hardy-drivers')
else:a = urllib.urlopen(URLtoOPEN)
sectionadd="
30 days
NCnoT=0 #not completed
NCnoT30d=0 #not completed > 30 days
# 2419200 secondi in 28 giorni //// 86400 secondi in un giorno
# 10 11 12 = ind primadata 14=ind completati, 15=ind certif free
for x in SECTIONLIST:
try:
Q=0
listX=string.split(x)
if URLtoOPEN!="":
listX.insert(5,"add")
listX.insert(6,"adssss")
listnum=['0','1','2','3','4','5','6','7','8','9',]
mesi={"Jan":1,"Feb":2,"Mar":3,"Apr":4,"May":5,"Jun":6, "Jul":7,"Aug":8,"Sep":9,"Oct":10,"Nov":11,"Dec":12}
limit=2419200
datenow=string.split(strftime("%d %b %y", gmtime()))
if mesi.has_key(datenow[1])==1:M=mesi[datenow[1]]
TimeSecondNow=(int(datenow[0])*86400)+M*2592000+(int(datenow[2])+2000)*2592000*12
Na=string.join([x for x in listX[10] if x in listnum],"") #old day
Nc=string.join([x for x in listX[12] if x in listnum],"") #old year
Nb=string.join(listX[11],"") #old month
for x in mesi:
if Nb == x:Nb=mesi[x]
TimeSecondAdopt=int(Na)*86400+int(Nb)*2592000+(int(Nc)+2000)*2592000*12
DELTAT=TimeSecondNow - TimeSecondAdopt
if complete in listX[14] and complete in listX[15]:R+=1 #completed, free
elif complete in listX[14] and complete not in listX[15]:
if DELTAT <= limit:CnoT+=1 #completed, not free
elif DELTAT > limit:CnoT30d+=1 #completed, not free > 30 days
elif complete not in listX[14] and complete not in listX[15]:
if DELTAT <= limit:NCnoT+=1 #not completed
elif DELTAT > limit:NCnoT30d+=1 #not completed > 30 days
except: "something is not well formatted"
print "Total section:",TotalSection
print "adopted:",countyes
print "not adopted:",countnot
print "Section 100% Free:",R
if URLtoOPEN=="" or URLtoOPEN=="http://wiki.gnewsense.org/Kernel/Image":
table=open('Summary.txt',"w")
ttt=["!!Package Section Summary (",strftime("%d %b %y", gmtime()),")\n||border=1 width=50%\n||Completed, Free||",str(R),"||\n||Completed, NOT Free, age <= 28 days||",str(CnoT),"||\n||Completed, NOT Free, age > 28 days||",str(CnoT30d),"||\n||NOT Completed, age <= 28 days||",str(NCnoT),"||\n||NOT Completed, age > 28 days||",str(NCnoT30d),"||\n||NOT adopted||",str(countnot),"||\n||Total||",str(TotalSection),"||\n"]
table.write(string.join(ttt,""))
table.close()
|