#!/usr/bin/python2.6 # -*- coding: latin-1 -*- # # Copyright (c) 2006, Ingo Juergensmann # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # check_installed.phtml comes with ABSOLUTELY NO WARRANTY # import os, sys, cgi from string import * import psycopg2 homedir="/home/builddnet" #os.environ['HOME'] f = open(homedir+"/conf.d/database.conf") while 1: line = f.readline() if len(line)==0: break if line.count("host"): host = split(line,"=")[1] elif line.count("port"): port = split(line,"=")[1] elif line.count("username"): username = split(line,"=")[1] elif line.count("password"): password = split(line,"=")[1] elif line.count("database"): database = split(line,"=")[1] #dsn = "dbname=buildd user=builddnet" dsn = "dbname=%s host=%s user=%s password=%s" % ( database, host, username, password ) db = psycopg2.connect(dsn) csr = db.cursor() form = cgi.FieldStorage() if form.has_key('flavour'): flavour = form['flavour'].value if form.has_key('arch'): arch = form['arch'].value #if form.has_key('flavour'): # flavour = form['flavour'].value i = 1 res="" #flavour="unstable" #arch="m68k" print "Content-type: text/html" print """ buildd.net - packages Dep-Wait check """ print '[back]' % (flavour, arch) modes=['buildd', 'package', 'date'] del modes[index(modes, form['mode'].value)] for mo in modes: print ' [%s]' % ( flavour, arch, mo, mo) print """
""" print " %s/%s check Installed" % (arch, flavour) print """


Legend:

  • Buildd, Package, Version: should be obvious
  • Waiting on : the package is waiting on that/those packages to become available.
  • For: time a package is waiting for that (yet unfulfilled) dependency.
    n/a = sadly, the *-all.txt wasn't exported with --verbose option of wanna-build, so there is no information when the state changed from Needs-Build or Building to Dep-Wait.
  • Note: This is an experimental page - it's neither free of bugs nor complete!

    """ def tableheader(mode): print """ """ # if mode=="buildd": print ' ' print ' ' print ' ' #print ' ' print ' ' elif mode=="package": print ' ' print ' ' print ' ' #print ' ' print ' ' elif mode=="date": #print ' ' print ' ' print ' ' print ' ' print ' ' # print "" def tablefooter(count): print """
    Buildd:Package:Version:Waiting on:Installed on:Package:Version:Buildd:Waiting on:Installed on:Waiting on:Installed on:Package:Version:Buildd:
    """ print "

    Total: %s packages installed

    " % count def archoutput(flavour, arch): global i, form, res if form.has_key('mode'): mode = form['mode'].value builddarray=[] packagearray=[] datearray=[] bgcolor="#f8f8ff" path = "/home/builddnet/%s/listdir/%s-all.txt" % (flavour,arch) f = open(path, 'r') date = "un kno wn da:te" while 1: line = f.readline() #print line if not line: break if (line.count("Installed by") or line.count("Installed [")): #print line, "
    " packageversion= os.path.basename(split(line, " ")[0]) package, version = split(packageversion, "_") string = "buildd_%s-" % arch if line.count("by "): buildd = replace(split(replace(replace(split(line, " ", 1)[1], "Installed ", ""), "by ", ""))[0], string, "") else: buildd="unknown" #print buildd version=str(version[0:len(version)-1]) nextline = strip(f.readline()) #if nextline.count("Previous state was Uploaded "): # depline=replace(replace(replace(nextline, "Dependencies: ", ""), " ", " "), ", ", "
    ") #print depline # z=0 #while 1: # nextline=f.readline() if nextline.count('Previous state was Uploaded'): date = strip(replace(replace(nextline, "Previous state was Uploaded until ", ""), "\n", "")) # elif nextline.count('Previous state was Building'): # date = strip(replace(replace(nextline, "Previous state was Building until ", ""), "\n", "")) # elif nextline.count('Previous state was Failed'): # date = strip(replace(replace(nextline, "Previous state was Failed until ", ""), "\n", "")) # elif nextline.count('Previous state was Dep-Wait-Removed'): # date = strip(replace(replace(nextline, "Previous state was Dep-Wait-Removed until ", ""), "\n", "")) #else: # break #print '%s_all.txt is not exported with --verbose option!' % arch # print '' # break #print date #try: # sqlcmd = "select ((now()-'%s'))" % date # csr.execute(sqlcmd) # sqlresult = csr.fetchone() # res=str(sqlresult[0]) #except: # res="n/a" # date="n/a" foo='%s %s %s %s' % (buildd,package,version,date) bar=split(foo) #print foo, "
    " builddarray.append(bar) foo='%s %s %s %s' % (package,version,buildd,date) bar=split(foo) packagearray.append(bar) foo='%s %s %s %s' % (date,buildd,package,version) bar=split(foo) datearray.append(split(date+" "+buildd+" "+package+" "+version)) #print "unsorted:
    ", builddarray,"

    " builddarray.sort() packagearray.sort() datearray.sort() #print "sorted:
    ", builddarray, "

    " #print packagearray,"

    " #print datearray,"

    " #mode="package" if mode=="buildd": tableoutput(mode, builddarray) elif mode=="package": tableoutput(mode, packagearray) elif mode=="date": tableoutput(mode, datearray) return def tableoutput(mode, array): global i, form, flavour, arch #print mode #print array, "
    " if form.has_key('buildd'): formbuildd = form['buildd'].value if not len(array): print 'No Installed packages found!' print '' sys.exit() tableheader(mode) for line in array: #print line, "
    " if form.has_key('buildd') and not line.count(formbuildd): pass else: #i = i +1 k = i % 2 if k == 1: bgcolor="#f8f8ff" else: bgcolor="#e0e0f0" if mode=="buildd": buildd = line[0] package = line[1] version = line[2] #deps = line[3] res = join(line[3:7]) if res.count(":")==3: res=replace(res, ":", "d ", 1) if res.count("-"): fcolor="#000000" else: fcolor="#000000" print ' ' % bgcolor #print ' %s' % arch print ' %s' % (flavour, arch, mode, buildd, buildd) print ' %s' % (flavour, package, arch, package) print ' %s' % version #print ' %s' % (flavour, deps, arch, deps) print ' %s' % (fcolor, res) print ' ' i = i +1 elif mode=="package": buildd = line[2] package = line[0] version = line[1] #deps = line[3] res = join(line[3:7]) if res.count(":")==3: res=replace(res, ":", "d ", 1) if res.count("-"): fcolor="#000000" else: fcolor="#000000" print ' ' % bgcolor #print ' %s' % arch print ' %s' % (flavour, package, arch, package) print ' %s' % version print ' %s' % (flavour, arch, mode, buildd, buildd) #print ' %s' % (flavour, deps, arch, deps) print ' %s' % (fcolor, res) print ' ' i = i +1 elif mode=="date": buildd = line[4] package = line[5] version = line[6] #deps = line[1] res = join(line[0:4]) if res.count(":")==3: res=replace(res, ":", "d ", 1) if res.count("-"): fcolor="#000000" else: fcolor="#000000" print ' ' % bgcolor #print ' %s' % arch #print ' %s' % (flavour, deps, arch, deps) print ' %s' % (fcolor, res) print ' %s' % (flavour, package, arch, package) print ' %s' % version print ' %s' % (flavour, arch, mode, buildd, buildd) print ' ' i = i +1 tablefooter(i) archoutput(flavour, arch) print ""