示例#1
0
 def select(cls, orderBy=None, progress=None):
     cols  = ",".join(Database().get_col('backport'))
     stmt  = "SELECT %s FROM backport" % cols
     archs = RebuilddConfig().get('build', 'more_archs').split()
     if progress == 'complete':
         stmt += " WHERE progress = %d" % len(archs)
     if progress == 'partial':
         stmt += " WHERE progress >= 0 and progress < %d" % len(archs)
     if progress == 'null':
         stmt += " WHERE progress < 0"
     if orderBy:
         stmt += " ORDER BY %s" % orderBy
     cursor = Database().get_cnx().cursor()
     cursor.execute(stmt)
     backports = []
     for (pkg, dist, origin, bleeding, official, target, archs, progress, policy) in cursor:
         b = cls()
         b.pkg      = pkg
         b.dist     = dist
         b.origin   = origin
         b.bleeding = bleeding 
         b.official = official
         b.target   = target
         b.archs    = eval(archs)
         b.progress = progress
         b.policy   = policy
         backports.append(b)
     return backports
示例#2
0
 def select(cls, package_id=None, dist=None, arch=None):
     cursor = Database().get_cnx().cursor()
     stmt = "SELECT id, status, mailto, package_id, dist, arch, creation_date, status_changed, build_start, build_end, host FROM job"
     if package_id and dist and arch:
         cursor.execute("%s WHERE package_id=%d and dist='%s' and arch='%s'" % (stmt, package_id, dist, arch))
     elif package_id:
         cursor.execute("%s WHERE package_id=%d" % (stmt, package_id))
     elif dist:
         cursor.execute("%s WHERE dist='%s'" % (stmt, dist))
     elif package_id:
         cursor.execute("%s WHERE package_id=%d" % (stmt, package_id))
     else:
         cursor.execute("%s" % stmt)
     jobs = []
     for id, status, mailto, package_id, dist, arch, creation_date, status_changed, build_start, build_end, host in cursor:
         j = cls()
         j.id       = id
         j.status = status
         j.mailto = mailto
         j.package_id = package_id
         j.dist = dist
         j.arch = arch
         j.creation_date = creation_date
         j.status_changed = status_changed
         j.build_start = build_start
         j.build_end = build_end
         j.host = host
         jobs.append(j)
     return jobs
示例#3
0
 def select(cls, name=None):
     cursor = Database().get_cnx().cursor()
     if name:
         cursor.execute("SELECT id, name, version, priority FROM package where name='%s'" % name)
     else:
         cursor.execute("SELECT id, name, version, priority FROM package")
     packages = []
     for id, name, version, priority in cursor:
         p = cls()
         p.id       = id
         p.name     = name
         p.version  = version
         p.priority = priority
         packages.append(p)
     return packages
示例#4
0
    def jobs(cls, dist=None, progress=None, status=None, orderBy=None):

        cols  = Database().get_col('backport')
        archs = RebuilddConfig().get('build', 'more_archs').split()
        select = "SELECT %s, job.id, job.status, job.arch FROM backport" % ", ".join(['backport.%s' % c for c in cols])
        join_pkg = " INNER JOIN package ON package.name=backport.pkg and package.version=backport.target and package.id=job.package_id"
        join_job = " INNER JOIN job ON job.dist=backport.dist"
        if type(status) == tuple:
           join_job += " and job.status IN (%s)" % ", ".join(str(s) for s in status)
        if type(status) == int:
           join_job += " and job.status=%d" % status
        if dist:
           join_job += " and job.dist='%s'" % dist
        stmt = select + join_pkg + join_job

        if progress == 'complete':
            stmt += " WHERE backport.progress = %d" % len(archs)
        if progress == 'partial':
            stmt += " WHERE backport.progress >= 0 and backport.progress < %d" % len(archs)
        if progress == 'null':
            stmt += " WHERE backport.progress < 0"
        if orderBy:
            stmt += " ORDER BY %s" % orderBy

        cursor = Database().get_cnx().cursor()
        cursor.execute(stmt)

        backports = []
        
        for (pkg, dist, origin, bleeding, official, target, archs, progress, policy, job_id, job_status, job_arch) in cursor:
            b = cls()
            b.pkg      = pkg
            b.dist     = dist
            b.origin   = origin
            b.bleeding = bleeding 
            b.official = official
            b.target   = target
            b.archs    = eval(archs)
            b.progress = progress
            b.policy   = policy
            j = Job()
            j.id     = job_id
            j.status = job_status
            j.arch   = job_arch
            b.job    = j
            backports.append(b)
        return backports
示例#5
0
    def join(cls, progress=None, status=None, orderBy=None):

        cols  = Database().get_col('backport')
        archs = RebuilddConfig().get('build', 'archs').split()
        select = "SELECT %s, job.id, job.status, job.arch FROM job" % ", ".join(['backport.%s' % c for c in cols])
        join_pkg = " INNER JOIN package ON package.name=backport.pkg and package.version=backport.target and package.id=job.package_id"
        join_bkp = " INNER JOIN backport ON backport.dist=job.dist"
        if progress == 'complete':
            join_bkp += " and backport.progress = %d" % len(archs)
        if progress == 'partial':
            join_bkp += " and backport.progress >= 0 and backport.progress < %d" % len(archs)
        if progress == 'null':
            join_bkp += " and backport.progress < 0"

        stmt = select + join_pkg + join_bkp

        if status:
            stmt += " WHERE job.status=%s" % status
        if orderBy:
            stmt += " ORDER BY %s" % orderBy

        cursor = Database().get_cnx().cursor()
        cursor.execute(stmt)

        jobs = []
        
        for (pkg, dist, origin, bleeding, official, target, archs, progress, policy, job_id, job_status, job_arch) in cursor:
            j = cls()
            j.id     = job_id
            j.status = job_status
            j.arch   = job_arch
            b = Backport()
            b.pkg      = pkg
            b.dist     = dist
            b.origin   = origin
            b.bleeding = bleeding 
            b.official = official
            b.target   = target
            b.archs    = eval(archs)
            b.progress = progress
            b.policy   = policy
            j.backport = b
            jobs.append(j)
        return jobs
示例#6
0
 def join(cls, dist=None, package=None):
     cursor = Database().get_cnx().cursor()
     stmt='SELECT job.id, package.name, package.version, job.arch, job.status FROM job INNER JOIN package ON job.package_id=package.id'
     if dist != None and package != None:
         cursor.execute("%s WHERE job.dist='%s' and package.name='%s' ORDER BY job.id DESC" % (stmt, dist, package))
     elif dist != None:
         cursor.execute("%s WHERE job.dist='%s' ORDER BY job.id DESC" % (stmt, dist))
     else:
         cursor.execute("%s ORDER BY job.id DESC" % stmt)
     jobs = []
     for id, package, version, arch ,status in cursor:
         j = cls()
         j.id       = id
         j.package = package
         j.version = version
         j.arch = arch
         j.status = status
         jobs.append(j)
     return jobs